Advertisement
Guest User

Minetest /update Command Update

a guest
May 24th, 2016
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.40 KB | None | 0 0
  1. -- Update Block
  2. function server_tools.update_node(name, param, x, y, z)
  3.   -- variables
  4.   local player = minetest.get_player_by_name(name) -- player name
  5.     local item_string_type = minetest.registered_items[param].type -- item string type
  6.     -- confirm node param
  7.     if minetest.registered_items[param] == nil or minetest.registered_items[param] == "" then
  8.         minetest.chat_send_player(name, "Invalid item string. Please try again.") --print to chat
  9.         minetest.log("action", "[Server_Tools] "..name.." tried to update a node with invalid item string: "..param) --print to log
  10.     else
  11.         -- make sure item string is not a craftitem of tool
  12.         if item_string_type == "tool" or item_string_type == "craftitem" then
  13.             minetest.chat_send_player(name, "Item string cannot be a "..item_string_type) --print to chat
  14.             minetest.log("action", "[Server_Tools] "..name.." tried to update a node to "..item_string_type) --print to log
  15.         else
  16.             -- confirm position params
  17.           if x == "" or x == nil or y == "" or z == nil or z == "" or z == nil then
  18.             -- print error to chat and log
  19.             minetest.chat_send_player(name, "Invalid position coordinates. Please try again.") -- print to chat
  20.             minetest.log("action", "[Server_Tools] "..name.." tried to update a node using invalid coordinates, "..x..", "..y..", "..z..".") --print to log
  21.           else
  22.             -- update node
  23.                 minetest.set_node(x y z, param)
  24.           end
  25.         end
  26.     end
  27. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement