diff options
-rw-r--r-- | mesecons_commandblock/init.lua | 10 | ||||
-rw-r--r-- | mesecons_movestones/init.lua | 6 | ||||
-rw-r--r-- | mesecons_mvps/init.lua | 21 |
3 files changed, 25 insertions, 12 deletions
diff --git a/mesecons_commandblock/init.lua b/mesecons_commandblock/init.lua index 9e868bc..7ec6312 100644 --- a/mesecons_commandblock/init.lua +++ b/mesecons_commandblock/init.lua @@ -16,6 +16,9 @@ minetest.register_chatcommand("tell", { minetest.chat_send_player(name, "Invalid usage: " .. param)
return
end
+ if not minetest.env:get_player_by_name(target) then
+ minetest.chat_send_player(name, "Invalid target: " .. target)
+ end
minetest.chat_send_player(target, name .. " whispers: " .. message)
end
})
@@ -38,7 +41,12 @@ minetest.register_chatcommand("hp", { minetest.chat_send_player(name, "Invalid usage: " .. param)
return
end
- minetest.get_player_by_name(target):set_hp(value)
+ local player = minetest.env:get_player_by_name(target)
+ if player then
+ player:set_hp(value)
+ else
+ minetest.chat_send_player(name, "Invalid target: " .. target)
+ end
end
})
diff --git a/mesecons_movestones/init.lua b/mesecons_movestones/init.lua index ede5211..1255c67 100644 --- a/mesecons_movestones/init.lua +++ b/mesecons_movestones/init.lua @@ -88,7 +88,7 @@ minetest.register_entity("mesecons_movestones:movestone_entity", { on_step = function(self, dtime) local pos = self.object:getpos() - pos.x, pos.y, pos.z = math.floor(pos.x), math.floor(pos.y), math.floor(pos.z) + pos.x, pos.y, pos.z = math.floor(pos.x+0.5), math.floor(pos.y+0.5), math.floor(pos.z+0.5) local direction = mesecon:get_movestone_direction(pos) if not direction then -- no mesecon power @@ -172,7 +172,7 @@ minetest.register_entity("mesecons_movestones:sticky_movestone_entity", { on_step = function(self, dtime) local pos = self.object:getpos() - pos.x, pos.y, pos.z = math.floor(pos.x), math.floor(pos.y), math.floor(pos.z) + pos.x, pos.y, pos.z = math.floor(pos.x+0.5), math.floor(pos.y+0.5), math.floor(pos.z+0.5) local direction = mesecon:get_movestone_direction(pos) if not direction then -- no mesecon power @@ -180,6 +180,8 @@ minetest.register_entity("mesecons_movestones:sticky_movestone_entity", { if name ~= "air" and name ~= "ignore" and minetest.registered_nodes[name].liquidtype == "none" then mesecon:mvps_push(pos, self.lastdir, MOVESTONE_MAXIMUM_PUSH) + --STICKY + mesecon:mvps_pull_all(pos, self.lastdir) end minetest.env:add_node(pos, {name="mesecons_movestones:sticky_movestone"}) self.object:remove() diff --git a/mesecons_mvps/init.lua b/mesecons_mvps/init.lua index 1e0d324..1176121 100644 --- a/mesecons_mvps/init.lua +++ b/mesecons_mvps/init.lua @@ -44,7 +44,7 @@ function mesecon:mvps_get_stack(pos, dir, maximum) local nn = minetest.env:get_node_or_nil(np) if not nn or #nodes > maximum then -- don't push at all, something is in the way (unloaded map or too many nodes) - return + return nil end if nn.name == "air" @@ -62,6 +62,7 @@ end function mesecon:mvps_push(pos, dir, maximum) -- pos: pos of mvps; dir: direction of push; maximum: maximum nodes to be pushed local nodes = mesecon:mvps_get_stack(pos, dir, maximum) + if not nodes then return end -- determine if one of the nodes blocks the push for id, n in ipairs(nodes) do if mesecon:is_mvps_stopper(n.node, dir, nodes, id) then @@ -139,6 +140,8 @@ function mesecon:mvps_pull_all(pos, direction) -- pos: pos of mvps; direction: d end function mesecon:mvps_move_objects(pos, dir, nodestack) + local objects_to_move = {} + -- Move object at tip of stack local pushpos = mesecon:addPosRule(pos, -- get pos at tip of stack {x = dir.x * (#nodestack), @@ -148,29 +151,29 @@ function mesecon:mvps_move_objects(pos, dir, nodestack) local objects = minetest.env:get_objects_inside_radius(pushpos, 1) for _, obj in ipairs(objects) do - local entity = obj:get_luaentity() - if not entity or not mesecon:is_mvps_unmov(entity.name) then - obj:setpos(mesecon:addPosRule(obj:getpos(), dir)) - end + table.insert(objects_to_move, obj) end -- Move objects lying/standing on the stack (before it was pushed - oldstack) - local objects_above = {} if tonumber(minetest.setting_get("movement_gravity")) > 0 and dir.y == 0 then -- If gravity positive and dir horizontal, push players standing on the stack for _, n in ipairs(nodestack) do local p_above = mesecon:addPosRule(n.pos, {x=0, y=1, z=0}) local objects = minetest.env:get_objects_inside_radius(p_above, 1) for _, obj in ipairs(objects) do - table.insert(objects_above, obj) + table.insert(objects_to_move, obj) end end end - for _, obj in ipairs(objects_above) do + for _, obj in ipairs(objects_to_move) do local entity = obj:get_luaentity() if not entity or not mesecon:is_mvps_unmov(entity.name) then - obj:setpos(mesecon:addPosRule(obj:getpos(), dir)) + local np = mesecon:addPosRule(obj:getpos(), dir) + local nn = minetest.env:get_node(np) + if not minetest.registered_nodes[nn.name].walkable then + obj:setpos(np) + end end end end |