From b4996ee69b14f0d1218e49bf4ccf3768e26bdbc4 Mon Sep 17 00:00:00 2001 From: LeMagnesium Date: Sun, 16 Aug 2015 16:08:21 +0200 Subject: [PATCH] Removed useless chatcommands redifinition and moved eject system - The system controlling the items' ejection from a solid node is now in mods/builtin_items/init.lua - The file mods/_misc/chatcommands.lua has been cleared from its comments, and the chatcommands redefined but outdated (like /time) --- mods/_misc/chatcommands.lua | 104 +----------------------------------- mods/_misc/init.lua | 3 -- mods/builtin_item/init.lua | 19 +++++++ 3 files changed, 21 insertions(+), 105 deletions(-) diff --git a/mods/_misc/chatcommands.lua b/mods/_misc/chatcommands.lua index 82964ebe..815d90d7 100755 --- a/mods/_misc/chatcommands.lua +++ b/mods/_misc/chatcommands.lua @@ -2,44 +2,10 @@ -- Edited chat commands from core -- --- /me --- /help --- /privs --- /grant --- /revoke --- /setpassword --- /clearpassword --- /auth_reload --- /teleport --- /set --- /mods --- /give --- /giveme --- /spawnentity --- /pulverize --- /rollback_check --- /rollback --- /status +-- /shutdown +-- /ban -- /itemdb -minetest.register_chatcommand("time", { - params = "<0...24000>", - description = "set time of day", - privs = {settime=true}, - func = function(name, param) - if param == "" then - return false, "Missing time." - end - local newtime = tonumber(param) - if newtime == nil then - return false, "Invalid time." - end - minetest.set_timeofday((newtime % 24000) / 24000) - minetest.log("action", name .. " sets time " .. newtime) - minetest.chat_send_all(name .. " changed the time of day.") - end, -}) - minetest.register_chatcommand("shutdown", { description = "shutdown server", privs = {server=true}, @@ -93,69 +59,3 @@ minetest.register_chatcommand("itemdb", { end end }) - --- /unban --- /kick --- /clearobjects --- /msg - --- --- Other chat commands --- - --- Spawn command ---minetest.register_chatcommand("spawn", { --- params = "", --- description = "Teleport to the spawn location.", --- privs = {shout=true}, --- func = function(name, param) --- local player = minetest.get_player_by_name(name) --- minetest.chat_send_player(name, "Teleported to spawn!") --- player:setpos({x=0.0, y=5.0, z=0.0}) --- return true --- end, ---}) ---[[ --- Sethome command -minetest.register_chatcommand("sethome", { - params = "", - description = "Set your home location.", - privs = {shout=true}, - func = function(name, param) - player = minetest.get_player_by_name(name) - test = player:getpos() - local file = io.open(minetest.get_worldpath().."/home/"..player:get_player_name().."_home", "w") - if not file then - minetest.chat_send_player(name, "Il y a eut une erreur, s'il vous plait contactez le detenteur du serveur.") - return - end - file:write(minetest.pos_to_string(test)) - file:close() - minetest.chat_send_player(name, "Votre emplacement 'home' est definit ! Tapez /home pour vous y teleporter.") - end -}) - --- Home command -minetest.register_chatcommand("home", { - params = "", - description = "Vous teleporte a l'emplacement de votre 'home'.", - privs = {shout=true}, - func = function(name, param) - player = minetest.get_player_by_name(name) - local file = io.open(minetest.get_worldpath().."/home/"..player:get_player_name().."_home", "r") - if not file then - minetest.chat_send_player(name, "Vous devez definir votre emplacement 'home' ! Pour ce faire, utilisez la commande /sethome.") - return - end - local line = file:read("*line") - file:close() - local pos = minetest.string_to_pos(string.sub(line, 1, string.find(line, ")"))) - if not pos or type(pos) ~= "table" then - minetest.chat_send_player(name, "Il y a eut une erreur, s'il vous plait contactez le detenteur du serveur.") - return - end - minetest.get_player_by_name(name):setpos(pos) - minetest.chat_send_player(name, "Vous voilą chez vous.") - end -}) ---]] diff --git a/mods/_misc/init.lua b/mods/_misc/init.lua index 51707470..17497039 100755 --- a/mods/_misc/init.lua +++ b/mods/_misc/init.lua @@ -27,6 +27,3 @@ dofile(minetest.get_modpath("_misc").."/uncraft_woll.lua") -- List players dofile(minetest.get_modpath("_misc").."/list_players.lua") - --- Eject entites when putting a node -dofile(minetest.get_modpath("_misc").."/eject_entities.lua") diff --git a/mods/builtin_item/init.lua b/mods/builtin_item/init.lua index 79d742dc..7cf8e596 100755 --- a/mods/builtin_item/init.lua +++ b/mods/builtin_item/init.lua @@ -3,6 +3,15 @@ if not time then time = 600 end +unwalkable_nodes = {} + +minetest.after(0, function() + for itemname, node in pairs(minetest.registered_nodes) do + if node.walkable == false then + table.insert(unwalkable_nodes, 1, itemname) + end + end +end) minetest.register_entity(":__builtin:item", { initial_properties = { @@ -182,6 +191,16 @@ minetest.register_entity(":__builtin:item", { }) end end + + -- Eject if not walkable + local upnode = minetest.get_node({x = p.x, y = math.ceil(p.y), z = p.z}).name + if minetest.registered_nodes[upnode] and minetest.registered_nodes[upnode].walkable then + local minp, maxp = {x=p.x-1, y=math.ceil(p.y), z=p.z-1}, {x=p.x+1, y=math.ceil(p.y)+1, z=p.z+1} + local nodes = minetest.find_nodes_in_area(minp, maxp, unwalkable_nodes) + if table.getn(nodes) > 0 then + self.object:setpos(nodes[math.random(1,#nodes)]) + end + end end, --[[ This causes a duplication glitch if a player walks upon an item and clicks on it at the same time. on_punch = function(self, hitter)