-- "I'll stop calling it Minetest when it stops being one." minetest = core -- Override properties of a table from those of another table function extend(dst, src) for k, v in pairs(src) do dst[k] = v end return dst end -- PHP-style helper verb function include(file) return dofile(minetest.get_modpath(minetest.get_current_modname()).."/"..file) end function include_all(dir) for _, x in pairs(minetest.get_dir_list(minetest.get_modpath(minetest.get_current_modname()).."/"..dir)) do include(dir.."/"..x) end end function warn(str) minetest.log("warning", str) end function err(str) minetest.log("error", str.."\n"..debug.traceback()) end function tell(p, msg) minetest.chat_send_player(p, "# Server: "..msg) end function say(msg) minetest.chat_send_all("# Server: "..msg) end rgt = {} local ns = rgt function ns.register_node(name, def) def._name = name local alias if not name:find(":") then alias = name name = "red_glazed_terracotta:"..name end if def.groups then if def.groups.interactable then def.on_rightclick = function(pos, _, p) rgt.players[p:get_player_name()].interacting_with = pos end end end if def._variants then if type(def._variants) == "string" then rgt_world["register_"..def._variants](def) else for _, x in ipairs(def._variants) do rgt_world["register_"..x](def) end end end minetest.register_node(":"..name, def) if alias then minetest.register_alias(alias, name) end end function ns.register_item(name, def) def._name = name local alias if not name:find(":") then alias = name name = "red_glazed_terracotta:"..name end minetest.register_craftitem(":"..name, def) if alias then minetest.register_alias(alias, name) end end function ns.register_tool(name, def) def._name = name local alias if not name:find(":") then alias = name name = "red_glazed_terracotta:"..name end minetest.register_tool(":"..name, def) if alias then minetest.register_alias(alias, name) end end -- Allow nodes to provide a callback to run on activation without -- needing to register a bunch of mostly identical LBMs. minetest.register_lbm { name = ":red_glazed_terracotta:on_activate", nodenames = {"group:run_on_activate"}, action = function(pos, node) minetest.registered_nodes[node.name].on_activate(pos) end } minetest.register_on_joinplayer(function(p) if p:get_player_name() == "singleplayer" then minetest.change_player_privs(p:get_player_name(), { fast = true, fly = true, noclip = true, server = true, give = true, }) end end)