summaryrefslogtreecommitdiff
path: root/mesecons_movestones
diff options
context:
space:
mode:
authorJeija <norrepli@gmail.com>2013-04-02 11:56:37 +0200
committerJeija <norrepli@gmail.com>2013-04-02 11:57:28 +0200
commit57e15475151032322329391dfca252a625b82ae3 (patch)
tree6b65ea5dd6f7c238a339800d73a334fa254e19f8 /mesecons_movestones
parent2cc38909a12ad2ea9a62eac35eb66bcecd721b9f (diff)
downloadmesecons-57e15475151032322329391dfca252a625b82ae3.tar
mesecons-57e15475151032322329391dfca252a625b82ae3.tar.gz
mesecons-57e15475151032322329391dfca252a625b82ae3.tar.bz2
mesecons-57e15475151032322329391dfca252a625b82ae3.tar.xz
mesecons-57e15475151032322329391dfca252a625b82ae3.zip
Make pistons and movestones move objects (push only yet)
Diffstat (limited to 'mesecons_movestones')
-rw-r--r--mesecons_movestones/init.lua42
1 files changed, 30 insertions, 12 deletions
diff --git a/mesecons_movestones/init.lua b/mesecons_movestones/init.lua
index cd19ec2..ede5211 100644
--- a/mesecons_movestones/init.lua
+++ b/mesecons_movestones/init.lua
@@ -77,8 +77,9 @@ minetest.register_entity("mesecons_movestones:movestone_entity", {
physical = false,
visual = "sprite",
textures = {"jeija_movestone_side.png", "jeija_movestone_side.png", "jeija_movestone_side.png", "jeija_movestone_side.png", "jeija_movestone_arrows.png", "jeija_movestone_arrows.png"},
- collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5},
+ collisionbox = {-0.5,-0.5,-0.5, 0.5, 0.5, 0.5},
visual = "cube",
+ lastdir = {x=0, y=0, z=0},
on_punch = function(self, hitter)
self.object:remove()
@@ -90,21 +91,27 @@ minetest.register_entity("mesecons_movestones:movestone_entity", {
pos.x, pos.y, pos.z = math.floor(pos.x), math.floor(pos.y), math.floor(pos.z)
local direction = mesecon:get_movestone_direction(pos)
- if not direction then
+ if not direction then -- no mesecon power
local name = minetest.env:get_node(pos).name
- if name ~= "air" and name ~= "ignore" and minetest.registered_nodes[name].liquidtype == "none" then
- mesecon:mvps_push(pos, direction, MOVESTONE_MAXIMUM_PUSH)
+ if name ~= "air" and name ~= "ignore"
+ and minetest.registered_nodes[name].liquidtype == "none" then
+ mesecon:mvps_push(pos, self.lastdir, MOVESTONE_MAXIMUM_PUSH)
end
minetest.env:add_node(pos, {name="mesecons_movestones:movestone"})
self.object:remove()
return
end
- local np = mesecon:addPosRule(pos, direction)
- if not mesecon:mvps_push(np, direction, MOVESTONE_MAXIMUM_PUSH) then
+ local success, stack, oldstack =
+ mesecon:mvps_push(pos, direction, MOVESTONE_MAXIMUM_PUSH)
+ if not success then -- Too large stack/stopper in the way
minetest.env:add_node(pos, {name="mesecons_movestones:movestone"})
self.object:remove()
return
+ else
+ mesecon:mvps_process_stack (stack)
+ mesecon:mvps_move_objects (pos, direction, oldstack)
+ self.lastdir = direction
end
self.object:setvelocity({x=direction.x*2, y=direction.y*2, z=direction.z*2})
@@ -154,8 +161,9 @@ minetest.register_entity("mesecons_movestones:sticky_movestone_entity", {
physical = false,
visual = "sprite",
textures = {"jeija_movestone_side.png", "jeija_movestone_side.png", "jeija_movestone_side.png", "jeija_movestone_side.png", "jeija_sticky_movestone.png", "jeija_sticky_movestone.png"},
- collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5},
+ collisionbox = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
visual = "cube",
+ lastdir = {x=0, y=0, z=0},
on_punch = function(self, hitter)
self.object:remove()
@@ -167,21 +175,27 @@ minetest.register_entity("mesecons_movestones:sticky_movestone_entity", {
pos.x, pos.y, pos.z = math.floor(pos.x), math.floor(pos.y), math.floor(pos.z)
local direction = mesecon:get_movestone_direction(pos)
- if not direction then
+ if not direction then -- no mesecon power
local name = minetest.env:get_node(pos).name
- if name ~= "air" and name ~= "ignore" and minetest.registered_nodes[name].liquidtype == "none" then
- mesecon:mvps_push(pos, direction, MOVESTONE_MAXIMUM_PUSH)
+ if name ~= "air" and name ~= "ignore"
+ and minetest.registered_nodes[name].liquidtype == "none" then
+ mesecon:mvps_push(pos, self.lastdir, MOVESTONE_MAXIMUM_PUSH)
end
minetest.env:add_node(pos, {name="mesecons_movestones:sticky_movestone"})
self.object:remove()
return
end
- local np = mesecon:addPosRule(pos, direction)
- if not mesecon:mvps_push(np, direction, MOVESTONE_MAXIMUM_PUSH) then
+ local success, stack, oldstack =
+ mesecon:mvps_push(pos, direction, MOVESTONE_MAXIMUM_PUSH)
+ if not success then -- Too large stack/stopper in the way
minetest.env:add_node(pos, {name="mesecons_movestones:sticky_movestone"})
self.object:remove()
return
+ else
+ mesecon:mvps_process_stack (stack)
+ mesecon:mvps_move_objects (pos, direction, oldstack)
+ self.lastdir = direction
end
self.object:setvelocity({x=direction.x*2, y=direction.y*2, z=direction.z*2})
@@ -190,3 +204,7 @@ minetest.register_entity("mesecons_movestones:sticky_movestone_entity", {
mesecon:mvps_pull_all(pos, direction)
end,
})
+
+
+mesecon:register_mvps_unmov("mesecons_movestones:movestone_entity")
+mesecon:register_mvps_unmov("mesecons_movestones:sticky_movestone_entity")