mirror of
https://github.com/minetest-mods/mesecons.git
synced 2025-03-30 08:50:27 +02:00
Modified movestone pistons mvps for all liquid
This commit is contained in:
parent
bcd6634811
commit
4996c9045c
@ -1,211 +1,211 @@
|
|||||||
-- MOVESTONE
|
-- MOVESTONE
|
||||||
|
|
||||||
function mesecon:get_movestone_direction(pos)
|
function mesecon:get_movestone_direction(pos)
|
||||||
getactivated=0
|
getactivated=0
|
||||||
local lpos
|
local lpos
|
||||||
local getactivated=0
|
local getactivated=0
|
||||||
local rules=mesecon:get_rules("movestone")
|
local rules=mesecon:get_rules("movestone")
|
||||||
|
|
||||||
lpos={x=pos.x+1, y=pos.y, z=pos.z}
|
lpos={x=pos.x+1, y=pos.y, z=pos.z}
|
||||||
for n=1, 3 do
|
for n=1, 3 do
|
||||||
if mesecon:is_power_on(lpos, rules[n].x, rules[n].y, rules[n].z) then
|
if mesecon:is_power_on(lpos, rules[n].x, rules[n].y, rules[n].z) then
|
||||||
return {x=0, y=0, z=-1}
|
return {x=0, y=0, z=-1}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
lpos={x=pos.x-1, y=pos.y, z=pos.z}
|
lpos={x=pos.x-1, y=pos.y, z=pos.z}
|
||||||
for n=4, 6 do
|
for n=4, 6 do
|
||||||
if mesecon:is_power_on(lpos, rules[n].x, rules[n].y, rules[n].z) then
|
if mesecon:is_power_on(lpos, rules[n].x, rules[n].y, rules[n].z) then
|
||||||
return {x=0, y=0, z=1}
|
return {x=0, y=0, z=1}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
lpos={x=pos.x, y=pos.y, z=pos.z+1}
|
lpos={x=pos.x, y=pos.y, z=pos.z+1}
|
||||||
for n=7, 9 do
|
for n=7, 9 do
|
||||||
if mesecon:is_power_on(lpos, rules[n].x, rules[n].y, rules[n].z) then
|
if mesecon:is_power_on(lpos, rules[n].x, rules[n].y, rules[n].z) then
|
||||||
return {x=-1, y=0, z=0}
|
return {x=-1, y=0, z=0}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
lpos={x=pos.x, y=pos.y, z=pos.z-1}
|
lpos={x=pos.x, y=pos.y, z=pos.z-1}
|
||||||
for n=10, 12 do
|
for n=10, 12 do
|
||||||
if mesecon:is_power_on(lpos, rules[n].x, rules[n].y, rules[n].z) then
|
if mesecon:is_power_on(lpos, rules[n].x, rules[n].y, rules[n].z) then
|
||||||
return {x=1, y=0, z=0}
|
return {x=1, y=0, z=0}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_node("mesecons_movestones:movestone", {
|
minetest.register_node("mesecons_movestones:movestone", {
|
||||||
tiles = {"jeija_movestone_side.png", "jeija_movestone_side.png", "jeija_movestone_side.png", "jeija_movestone_side.png", "jeija_movestone_arrows.png", "jeija_movestone_arrows.png"},
|
tiles = {"jeija_movestone_side.png", "jeija_movestone_side.png", "jeija_movestone_side.png", "jeija_movestone_side.png", "jeija_movestone_arrows.png", "jeija_movestone_arrows.png"},
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
legacy_facedir_simple = true,
|
legacy_facedir_simple = true,
|
||||||
groups = {cracky=3},
|
groups = {cracky=3},
|
||||||
description="Movestone",
|
description="Movestone",
|
||||||
})
|
})
|
||||||
mesecon:register_effector("mesecons_movestones:movestone", "mesecons_movestones:movestone")
|
mesecon:register_effector("mesecons_movestones:movestone", "mesecons_movestones:movestone")
|
||||||
|
|
||||||
minetest.register_entity("mesecons_movestones:movestone_entity", {
|
minetest.register_entity("mesecons_movestones:movestone_entity", {
|
||||||
physical = false,
|
physical = false,
|
||||||
visual = "sprite",
|
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"},
|
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",
|
visual = "cube",
|
||||||
--on_activate = function(self, staticdata)
|
--on_activate = function(self, staticdata)
|
||||||
--self.object:setsprite({x=0,y=0}, 1, 0, true)
|
--self.object:setsprite({x=0,y=0}, 1, 0, true)
|
||||||
--self.object:setvelocity({x=-3, y=0, z=0})
|
--self.object:setvelocity({x=-3, y=0, z=0})
|
||||||
--end,
|
--end,
|
||||||
|
|
||||||
on_punch = function(self, hitter)
|
on_punch = function(self, hitter)
|
||||||
self.object:remove()
|
self.object:remove()
|
||||||
hitter:get_inventory():add_item("main", "mesecons_movestones:movestone")
|
hitter:get_inventory():add_item("main", "mesecons_movestones:movestone")
|
||||||
end,
|
end,
|
||||||
|
|
||||||
on_step = function(self, dtime)
|
on_step = function(self, dtime)
|
||||||
local pos = self.object:getpos()
|
local pos = self.object:getpos()
|
||||||
local direction=mesecon:get_movestone_direction(pos)
|
local direction=mesecon:get_movestone_direction(pos)
|
||||||
|
|
||||||
if not direction then
|
if not direction then
|
||||||
minetest.env:add_node(pos, {name="mesecons_movestones:movestone"})
|
minetest.env:add_node(pos, {name="mesecons_movestones:movestone"})
|
||||||
self.object:remove()
|
self.object:remove()
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
self.object:setvelocity({x=direction.x*3, y=direction.y*3, z=direction.z*3})
|
self.object:setvelocity({x=direction.x*3, y=direction.y*3, z=direction.z*3})
|
||||||
|
|
||||||
mesecon:mvps_push(pos, direction)
|
mesecon:mvps_push(pos, direction)
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = '"mesecons_movestones:movestone" 2',
|
output = '"mesecons_movestones:movestone" 2',
|
||||||
recipe = {
|
recipe = {
|
||||||
{'"default:stone"', '"default:stone"', '"default:stone"'},
|
{'"default:stone"', '"default:stone"', '"default:stone"'},
|
||||||
{'"group:mesecon_conductor_craftable"', '"group:mesecon_conductor_craftable"', '"group:mesecon_conductor_craftable"'},
|
{'"group:mesecon_conductor_craftable"', '"group:mesecon_conductor_craftable"', '"group:mesecon_conductor_craftable"'},
|
||||||
{'"default:stone"', '"default:stone"', '"default:stone"'},
|
{'"default:stone"', '"default:stone"', '"default:stone"'},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
mesecon:register_on_signal_on(function (pos, node)
|
mesecon:register_on_signal_on(function (pos, node)
|
||||||
if node.name=="mesecons_movestones:movestone" then
|
if node.name=="mesecons_movestones:movestone" then
|
||||||
local direction=mesecon:get_movestone_direction(pos)
|
local direction=mesecon:get_movestone_direction(pos)
|
||||||
if not direction then return end
|
if not direction then return end
|
||||||
local checknode={}
|
local checknode={}
|
||||||
local collpos={x=pos.x, y=pos.y, z=pos.z}
|
local collpos={x=pos.x, y=pos.y, z=pos.z}
|
||||||
repeat -- Check if it collides with a stopper
|
repeat -- Check if it collides with a stopper
|
||||||
collpos={x=collpos.x+direction.x, y=collpos.y+direction.y, z=collpos.z+direction.z}
|
collpos={x=collpos.x+direction.x, y=collpos.y+direction.y, z=collpos.z+direction.z}
|
||||||
checknode=minetest.env:get_node(collpos)
|
checknode=minetest.env:get_node(collpos)
|
||||||
if mesecon:is_mvps_stopper(checknode.name) then
|
if mesecon:is_mvps_stopper(checknode.name) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
until checknode.name=="air"
|
until checknode.name=="air"
|
||||||
or checknode.name=="ignore"
|
or checknode.name=="ignore"
|
||||||
or checknode.name=="default:water"
|
or string.find(checknode.name, "_source")
|
||||||
or checknode.name=="default:water_flowing"
|
or string.find(checknode.name, "_flowing")
|
||||||
minetest.env:remove_node(pos)
|
minetest.env:remove_node(pos)
|
||||||
nodeupdate(pos)
|
nodeupdate(pos)
|
||||||
minetest.env:add_entity(pos, "mesecons_movestones:movestone_entity")
|
minetest.env:add_entity(pos, "mesecons_movestones:movestone_entity")
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- STICKY_MOVESTONE
|
-- STICKY_MOVESTONE
|
||||||
|
|
||||||
minetest.register_node("mesecons_movestones:sticky_movestone", {
|
minetest.register_node("mesecons_movestones:sticky_movestone", {
|
||||||
tiles = {"jeija_movestone_side.png", "jeija_movestone_side.png", "jeija_movestone_side.png", "jeija_movestone_side.png", "jeija_sticky_movestone.png", "jeija_sticky_movestone.png"},
|
tiles = {"jeija_movestone_side.png", "jeija_movestone_side.png", "jeija_movestone_side.png", "jeija_movestone_side.png", "jeija_sticky_movestone.png", "jeija_sticky_movestone.png"},
|
||||||
inventory_image = minetest.inventorycube("jeija_sticky_movestone.png", "jeija_movestone_side.png", "jeija_movestone_side.png"),
|
inventory_image = minetest.inventorycube("jeija_sticky_movestone.png", "jeija_movestone_side.png", "jeija_movestone_side.png"),
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
legacy_facedir_simple = true,
|
legacy_facedir_simple = true,
|
||||||
groups = {cracky=3},
|
groups = {cracky=3},
|
||||||
description="Sticky Movestone",
|
description="Sticky Movestone",
|
||||||
})
|
})
|
||||||
mesecon:register_effector("mesecons_movestones:sticky_movestone", "mesecons_movestones:sticky_movestone")
|
mesecon:register_effector("mesecons_movestones:sticky_movestone", "mesecons_movestones:sticky_movestone")
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = '"mesecons_movestones:sticky_movestone" 2',
|
output = '"mesecons_movestones:sticky_movestone" 2',
|
||||||
recipe = {
|
recipe = {
|
||||||
{'"mesecons_materials:glue"', '"mesecons_movestones:movestone"', '"mesecons_materials:glue"'},
|
{'"mesecons_materials:glue"', '"mesecons_movestones:movestone"', '"mesecons_materials:glue"'},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_entity("mesecons_movestones:sticky_movestone_entity", {
|
minetest.register_entity("mesecons_movestones:sticky_movestone_entity", {
|
||||||
physical = false,
|
physical = false,
|
||||||
visual = "sprite",
|
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"},
|
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",
|
visual = "cube",
|
||||||
|
|
||||||
on_punch = function(self, hitter)
|
on_punch = function(self, hitter)
|
||||||
self.object:remove()
|
self.object:remove()
|
||||||
hitter:get_inventory():add_item("main", 'mesecons_movestones:sticky_movestone')
|
hitter:get_inventory():add_item("main", 'mesecons_movestones:sticky_movestone')
|
||||||
end,
|
end,
|
||||||
|
|
||||||
on_step = function(self, dtime)
|
on_step = function(self, dtime)
|
||||||
local pos = self.object:getpos()
|
local pos = self.object:getpos()
|
||||||
local colp = pos
|
local colp = pos
|
||||||
local direction=mesecon:get_movestone_direction(colp)
|
local direction=mesecon:get_movestone_direction(colp)
|
||||||
|
|
||||||
if not direction then
|
if not direction then
|
||||||
--or (minetest.env:get_node_or_nil(pos).name ~="air"
|
--or (minetest.env:get_node_or_nil(pos).name ~="air"
|
||||||
--and minetest.env:get_node_or_nil(pos).name ~= nil) then
|
--and minetest.env:get_node_or_nil(pos).name ~= nil) then
|
||||||
minetest.env:add_node(pos, {name="mesecons_movestones:sticky_movestone"})
|
minetest.env:add_node(pos, {name="mesecons_movestones:sticky_movestone"})
|
||||||
self.object:remove()
|
self.object:remove()
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
self.object:setvelocity({x=direction.x*3, y=direction.y*3, z=direction.z*3})
|
self.object:setvelocity({x=direction.x*3, y=direction.y*3, z=direction.z*3})
|
||||||
|
|
||||||
mesecon:mvps_push(pos, direction)
|
mesecon:mvps_push(pos, direction)
|
||||||
|
|
||||||
--STICKY
|
--STICKY
|
||||||
mesecon:mvps_pull_all(pos, direction)
|
mesecon:mvps_pull_all(pos, direction)
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
mesecon:register_on_signal_on(function (pos, node)
|
mesecon:register_on_signal_on(function (pos, node)
|
||||||
if node.name=="mesecons_movestones:sticky_movestone" then
|
if node.name=="mesecons_movestones:sticky_movestone" then
|
||||||
local direction=mesecon:get_movestone_direction(pos)
|
local direction=mesecon:get_movestone_direction(pos)
|
||||||
if not direction then return end
|
if not direction then return end
|
||||||
local checknode={}
|
local checknode={}
|
||||||
local collpos={x=pos.x, y=pos.y, z=pos.z}
|
local collpos={x=pos.x, y=pos.y, z=pos.z}
|
||||||
repeat -- Check if it collides with a stopper
|
repeat -- Check if it collides with a stopper
|
||||||
collpos={x=collpos.x+direction.x, y=collpos.y+direction.y, z=collpos.z+direction.z}
|
collpos={x=collpos.x+direction.x, y=collpos.y+direction.y, z=collpos.z+direction.z}
|
||||||
checknode=minetest.env:get_node(collpos)
|
checknode=minetest.env:get_node(collpos)
|
||||||
if mesecon:is_mvps_stopper(checknode.name) then
|
if mesecon:is_mvps_stopper(checknode.name) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
until checknode.name=="air"
|
until checknode.name=="air"
|
||||||
or checknode.name=="ignore"
|
or checknode.name=="ignore"
|
||||||
or checknode.name=="default:water"
|
or string.find(checknode.name, "_source")
|
||||||
or checknode.name=="default:water_flowing"
|
or string.find(checknode.name, "_flowing")
|
||||||
repeat -- Check if it collides with a stopper (pull direction)
|
repeat -- Check if it collides with a stopper (pull direction)
|
||||||
collpos={x=collpos.x-direction.x, y=collpos.y-direction.y, z=collpos.z-direction.z}
|
collpos={x=collpos.x-direction.x, y=collpos.y-direction.y, z=collpos.z-direction.z}
|
||||||
checknode=minetest.env:get_node(collpos)
|
checknode=minetest.env:get_node(collpos)
|
||||||
if mesecon:is_mvps_stopper(checknode.name) then
|
if mesecon:is_mvps_stopper(checknode.name) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
until checknode.name=="air"
|
until checknode.name=="air"
|
||||||
or checknode.name=="ignore"
|
or checknode.name=="ignore"
|
||||||
or checknode.name=="default:water"
|
or string.find(checknode.name, "_source")
|
||||||
or checknode.name=="default:water_flowing"
|
or string.find(checknode.name, "_flowing")
|
||||||
|
|
||||||
minetest.env:remove_node(pos)
|
minetest.env:remove_node(pos)
|
||||||
nodeupdate(pos)
|
nodeupdate(pos)
|
||||||
minetest.env:add_entity(pos, "mesecons_movestones:sticky_movestone_entity")
|
minetest.env:add_entity(pos, "mesecons_movestones:sticky_movestone_entity")
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
mesecon:add_rules("movestone", {
|
mesecon:add_rules("movestone", {
|
||||||
{x=0, y=1, z=-1},
|
{x=0, y=1, z=-1},
|
||||||
{x=0, y=0, z=-1},
|
{x=0, y=0, z=-1},
|
||||||
{x=0, y=-1, z=-1},
|
{x=0, y=-1, z=-1},
|
||||||
{x=0, y=1, z=1},
|
{x=0, y=1, z=1},
|
||||||
{x=0, y=-1, z=1},
|
{x=0, y=-1, z=1},
|
||||||
{x=0, y=0, z=1},
|
{x=0, y=0, z=1},
|
||||||
{x=1, y=0, z=0},
|
{x=1, y=0, z=0},
|
||||||
{x=1, y=1, z=0},
|
{x=1, y=1, z=0},
|
||||||
{x=1, y=-1, z=0},
|
{x=1, y=-1, z=0},
|
||||||
{x=-1, y=1, z=0},
|
{x=-1, y=1, z=0},
|
||||||
{x=-1, y=-1, z=0},
|
{x=-1, y=-1, z=0},
|
||||||
{x=-1, y=0, z=0}})
|
{x=-1, y=0, z=0}})
|
||||||
|
@ -1,67 +1,67 @@
|
|||||||
--register stoppers for movestones/pistons
|
--register stoppers for movestones/pistons
|
||||||
|
|
||||||
mesecon.mvps_stoppers={}
|
mesecon.mvps_stoppers={}
|
||||||
|
|
||||||
function mesecon:is_mvps_stopper(nodename)
|
function mesecon:is_mvps_stopper(nodename)
|
||||||
local i=1
|
local i=1
|
||||||
repeat
|
repeat
|
||||||
i=i+1
|
i=i+1
|
||||||
if mesecon.mvps_stoppers[i]==nodename then return true end
|
if mesecon.mvps_stoppers[i]==nodename then return true end
|
||||||
until mesecon.mvps_stoppers[i]==nil
|
until mesecon.mvps_stoppers[i]==nil
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
function mesecon:register_mvps_stopper(nodename)
|
function mesecon:register_mvps_stopper(nodename)
|
||||||
local i=1
|
local i=1
|
||||||
repeat
|
repeat
|
||||||
i=i+1
|
i=i+1
|
||||||
if mesecon.mvps_stoppers[i]==nil then break end
|
if mesecon.mvps_stoppers[i]==nil then break end
|
||||||
until false
|
until false
|
||||||
mesecon.mvps_stoppers[i]=nodename
|
mesecon.mvps_stoppers[i]=nodename
|
||||||
end
|
end
|
||||||
|
|
||||||
function mesecon:mvps_push(pos, direction) -- pos: pos of mvps; direction: direction of push
|
function mesecon:mvps_push(pos, direction) -- pos: pos of mvps; direction: direction of push
|
||||||
pos.x=pos.x+direction.x
|
pos.x=pos.x+direction.x
|
||||||
pos.y=pos.y+direction.y
|
pos.y=pos.y+direction.y
|
||||||
pos.z=pos.z+direction.z
|
pos.z=pos.z+direction.z
|
||||||
|
|
||||||
local lpos = {x=pos.x, y=pos.y, z=pos.z}
|
local lpos = {x=pos.x, y=pos.y, z=pos.z}
|
||||||
local lnode = minetest.env:get_node(lpos)
|
local lnode = minetest.env:get_node(lpos)
|
||||||
local newnode
|
local newnode
|
||||||
minetest.env:remove_node(lpos)
|
minetest.env:remove_node(lpos)
|
||||||
while not(lnode.name == "ignore" or lnode.name == "air" or lnode.name == "default:water" or lnode.name == "default:water_flowing") do
|
while not(lnode.name == "ignore" or lnode.name == "air" or string.find(lnode.name, "_source") or string.find(lnode.name, "_flowing") do
|
||||||
lpos.x=lpos.x+direction.x
|
lpos.x=lpos.x+direction.x
|
||||||
lpos.y=lpos.y+direction.y
|
lpos.y=lpos.y+direction.y
|
||||||
lpos.z=lpos.z+direction.z
|
lpos.z=lpos.z+direction.z
|
||||||
newnode = lnode
|
newnode = lnode
|
||||||
lnode = minetest.env:get_node(lpos)
|
lnode = minetest.env:get_node(lpos)
|
||||||
minetest.env:add_node(lpos, newnode)
|
minetest.env:add_node(lpos, newnode)
|
||||||
nodeupdate(lpos)
|
nodeupdate(lpos)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function mesecon:mvps_pull_all(pos, direction) -- pos: pos of mvps; direction: direction of pull
|
function mesecon:mvps_pull_all(pos, direction) -- pos: pos of mvps; direction: direction of pull
|
||||||
local lpos = {x=pos.x-direction.x, y=pos.y-direction.y, z=pos.z-direction.z} -- 1 away
|
local lpos = {x=pos.x-direction.x, y=pos.y-direction.y, z=pos.z-direction.z} -- 1 away
|
||||||
local lnode = minetest.env:get_node(lpos)
|
local lnode = minetest.env:get_node(lpos)
|
||||||
local lpos2 = {x=pos.x-direction.x*2, y=pos.y-direction.y*2, z=pos.z-direction.z*2} -- 2 away
|
local lpos2 = {x=pos.x-direction.x*2, y=pos.y-direction.y*2, z=pos.z-direction.z*2} -- 2 away
|
||||||
local lnode2 = minetest.env:get_node(lpos2)
|
local lnode2 = minetest.env:get_node(lpos2)
|
||||||
|
|
||||||
if lnode.name ~= "ignore" and lnode.name ~= "air" and lnode.name ~= "default:water" and lnode.name ~= "default:water_flowing" then return end
|
if lnode.name ~= "ignore" and lnode.name ~= "air" and not(string.find(lnode.name, "_flowing")) and not(string.find(lnode.name, "_source")) then return end
|
||||||
if lnode2.name == "ignore" or lnode2.name == "air" or lnode2.name == "default:water" or lnode2.name == "default:water_flowing" then return end
|
if lnode2.name == "ignore" or lnode2.name == "air" or string.find(lnode2.name, "_source") or string.find(lnode.name, "_flowing") then return end
|
||||||
|
|
||||||
local oldpos = {x=lpos2.x+direction.x, y=lpos2.y+direction.y, z=lpos2.z+direction.z}
|
local oldpos = {x=lpos2.x+direction.x, y=lpos2.y+direction.y, z=lpos2.z+direction.z}
|
||||||
repeat
|
repeat
|
||||||
minetest.env:add_node(oldpos, {name=minetest.env:get_node(lpos2).name})
|
minetest.env:add_node(oldpos, {name=minetest.env:get_node(lpos2).name})
|
||||||
nodeupdate(oldpos)
|
nodeupdate(oldpos)
|
||||||
oldpos = {x=lpos2.x, y=lpos2.y, z=lpos2.z}
|
oldpos = {x=lpos2.x, y=lpos2.y, z=lpos2.z}
|
||||||
lpos2.x = lpos2.x-direction.x
|
lpos2.x = lpos2.x-direction.x
|
||||||
lpos2.y = lpos2.y-direction.y
|
lpos2.y = lpos2.y-direction.y
|
||||||
lpos2.z = lpos2.z-direction.z
|
lpos2.z = lpos2.z-direction.z
|
||||||
lnode = minetest.env:get_node(lpos2)
|
lnode = minetest.env:get_node(lpos2)
|
||||||
until lnode.name=="air" or lnode.name=="ignore" or lnode.name=="default:water" or lnode.name=="default:water_flowing"
|
until lnode.name=="air" or lnode.name=="ignore" or string.find(lnode.name, "_source") or string.find(lnode.name, "_flowing")
|
||||||
minetest.env:remove_node(oldpos)
|
minetest.env:remove_node(oldpos)
|
||||||
end
|
end
|
||||||
|
|
||||||
mesecon:register_mvps_stopper("default:chest")
|
mesecon:register_mvps_stopper("default:chest")
|
||||||
mesecon:register_mvps_stopper("default:chest_locked")
|
mesecon:register_mvps_stopper("default:chest_locked")
|
||||||
mesecon:register_mvps_stopper("default:furnace")
|
mesecon:register_mvps_stopper("default:furnace")
|
||||||
|
@ -1,235 +1,231 @@
|
|||||||
--PISTONS
|
--PISTONS
|
||||||
--registration normal one:
|
--registration normal one:
|
||||||
minetest.register_node("mesecons_pistons:piston_normal", {
|
minetest.register_node("mesecons_pistons:piston_normal", {
|
||||||
description = "Piston",
|
description = "Piston",
|
||||||
tiles = {"jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_side.png"},
|
tiles = {"jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_side.png"},
|
||||||
groups = {cracky=3, mesecon = 2},
|
groups = {cracky=3, mesecon = 2},
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
after_dig_node = function(pos, oldnode)
|
after_dig_node = function(pos, oldnode)
|
||||||
local dir = mesecon:piston_get_direction(oldnode)
|
local dir = mesecon:piston_get_direction(oldnode)
|
||||||
pos.x, pos.y, pos.z = pos.x + dir.x, pos.y + dir.y, pos.z + dir.z --move to first node to check
|
pos.x, pos.y, pos.z = pos.x + dir.x, pos.y + dir.y, pos.z + dir.z --move to first node to check
|
||||||
|
|
||||||
--ensure piston is extended
|
--ensure piston is extended
|
||||||
local checknode = minetest.env:get_node(pos)
|
local checknode = minetest.env:get_node(pos)
|
||||||
if checknode.name == "mesecons_pistons:piston_pusher_normal" then
|
if checknode.name == "mesecons_pistons:piston_pusher_normal" then
|
||||||
if checknode.param2 == oldnode.param2 then --pusher is facing the same direction as the piston
|
if checknode.param2 == oldnode.param2 then --pusher is facing the same direction as the piston
|
||||||
minetest.env:remove_node(pos) --remove the pusher
|
minetest.env:remove_node(pos) --remove the pusher
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
mesecon:register_effector("mesecons_pistons:piston_normal", "mesecons_pistons:piston_normal")
|
mesecon:register_effector("mesecons_pistons:piston_normal", "mesecons_pistons:piston_normal")
|
||||||
|
|
||||||
--registration sticky one:
|
--registration sticky one:
|
||||||
minetest.register_node("mesecons_pistons:piston_sticky", {
|
minetest.register_node("mesecons_pistons:piston_sticky", {
|
||||||
description = "Sticky Piston",
|
description = "Sticky Piston",
|
||||||
tiles = {"jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_sticky_side.png"},
|
tiles = {"jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_sticky_side.png"},
|
||||||
groups = {cracky=3, mesecon = 2},
|
groups = {cracky=3, mesecon = 2},
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
after_dig_node = function(pos, oldnode)
|
after_dig_node = function(pos, oldnode)
|
||||||
local dir = mesecon:piston_get_direction(oldnode)
|
local dir = mesecon:piston_get_direction(oldnode)
|
||||||
pos.x, pos.y, pos.z = pos.x + dir.x, pos.y + dir.y, pos.z + dir.z --move to first node to check
|
pos.x, pos.y, pos.z = pos.x + dir.x, pos.y + dir.y, pos.z + dir.z --move to first node to check
|
||||||
|
|
||||||
--ensure piston is extended
|
--ensure piston is extended
|
||||||
local checknode = minetest.env:get_node(pos)
|
local checknode = minetest.env:get_node(pos)
|
||||||
if checknode.name == "mesecons_pistons:piston_pusher_sticky" then
|
if checknode.name == "mesecons_pistons:piston_pusher_sticky" then
|
||||||
if checknode.param2 == oldnode.param2 then --pusher is facing the same direction as the piston
|
if checknode.param2 == oldnode.param2 then --pusher is facing the same direction as the piston
|
||||||
minetest.env:remove_node(pos) --remove the pusher
|
minetest.env:remove_node(pos) --remove the pusher
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
mesecon:register_effector("mesecons_pistons:piston_sticky", "mesecons_pistons:piston_sticky")
|
mesecon:register_effector("mesecons_pistons:piston_sticky", "mesecons_pistons:piston_sticky")
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = '"mesecons_pistons:piston_normal" 2',
|
output = '"mesecons_pistons:piston_normal" 2',
|
||||||
recipe = {
|
recipe = {
|
||||||
{"default:wood", "default:wood", "default:wood"},
|
{"default:wood", "default:wood", "default:wood"},
|
||||||
{"default:cobble", "default:steel_ingot", "default:cobble"},
|
{"default:cobble", "default:steel_ingot", "default:cobble"},
|
||||||
{"default:cobble", "group:mesecon_conductor_craftable", "default:cobble"},
|
{"default:cobble", "group:mesecon_conductor_craftable", "default:cobble"},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = "mesecons_pistons:piston_sticky",
|
output = "mesecons_pistons:piston_sticky",
|
||||||
recipe = {
|
recipe = {
|
||||||
{"mesecons_materials:glue"},
|
{"mesecons_materials:glue"},
|
||||||
{"mesecons_pistons:piston_normal"},
|
{"mesecons_pistons:piston_normal"},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node("mesecons_pistons:piston_pusher_normal", {
|
minetest.register_node("mesecons_pistons:piston_pusher_normal", {
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
tiles = {"jeija_piston_pusher_normal.png"},
|
tiles = {"jeija_piston_pusher_normal.png"},
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
diggable = false,
|
diggable = false,
|
||||||
selection_box = {
|
selection_box = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = {
|
fixed = {
|
||||||
{-0.2, -0.2, -0.3, 0.2, 0.2, 0.5},
|
{-0.2, -0.2, -0.3, 0.2, 0.2, 0.5},
|
||||||
{-0.5, -0.5, -0.5, 0.5, 0.5, -0.3},
|
{-0.5, -0.5, -0.5, 0.5, 0.5, -0.3},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
node_box = {
|
node_box = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = {
|
fixed = {
|
||||||
{-0.2, -0.2, -0.3, 0.2, 0.2, 0.5},
|
{-0.2, -0.2, -0.3, 0.2, 0.2, 0.5},
|
||||||
{-0.5, -0.5, -0.5, 0.5, 0.5, -0.3},
|
{-0.5, -0.5, -0.5, 0.5, 0.5, -0.3},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
mesecon:register_mvps_stopper("mesecons_pistons:piston_pusher_normal")
|
mesecon:register_mvps_stopper("mesecons_pistons:piston_pusher_normal")
|
||||||
mesecon:register_mvps_stopper("mesecons_pistons:piston_pusher_sticky")
|
mesecon:register_mvps_stopper("mesecons_pistons:piston_pusher_sticky")
|
||||||
|
|
||||||
minetest.register_node("mesecons_pistons:piston_pusher_sticky", {
|
minetest.register_node("mesecons_pistons:piston_pusher_sticky", {
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
tiles = {
|
tiles = {
|
||||||
"jeija_piston_pusher_normal.png",
|
"jeija_piston_pusher_normal.png",
|
||||||
"jeija_piston_pusher_normal.png",
|
"jeija_piston_pusher_normal.png",
|
||||||
"jeija_piston_pusher_normal.png",
|
"jeija_piston_pusher_normal.png",
|
||||||
"jeija_piston_pusher_normal.png",
|
"jeija_piston_pusher_normal.png",
|
||||||
"jeija_piston_pusher_normal.png",
|
"jeija_piston_pusher_normal.png",
|
||||||
"jeija_piston_pusher_sticky.png"
|
"jeija_piston_pusher_sticky.png"
|
||||||
},
|
},
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
diggable = false,
|
diggable = false,
|
||||||
selection_box = {
|
selection_box = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = {
|
fixed = {
|
||||||
{-0.2, -0.2, -0.3, 0.2, 0.2, 0.5},
|
{-0.2, -0.2, -0.3, 0.2, 0.2, 0.5},
|
||||||
{-0.5, -0.5, -0.5, 0.5, 0.5, -0.3},
|
{-0.5, -0.5, -0.5, 0.5, 0.5, -0.3},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
node_box = {
|
node_box = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = {
|
fixed = {
|
||||||
{-0.2, -0.2, -0.3, 0.2, 0.2, 0.5},
|
{-0.2, -0.2, -0.3, 0.2, 0.2, 0.5},
|
||||||
{-0.5, -0.5, -0.5, 0.5, 0.5, -0.3},
|
{-0.5, -0.5, -0.5, 0.5, 0.5, -0.3},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Push action
|
-- Push action
|
||||||
mesecon:register_on_signal_on(function(pos, node)
|
mesecon:register_on_signal_on(function(pos, node)
|
||||||
if node.name ~= "mesecons_pistons:piston_normal" and node.name ~= "mesecons_pistons:piston_sticky" then
|
if node.name ~= "mesecons_pistons:piston_normal" and node.name ~= "mesecons_pistons:piston_sticky" then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local dir = mesecon:piston_get_direction(node)
|
local dir = mesecon:piston_get_direction(node)
|
||||||
pos.x, pos.y, pos.z = pos.x + dir.x, pos.y + dir.y, pos.z + dir.z --move to first node being pushed
|
pos.x, pos.y, pos.z = pos.x + dir.x, pos.y + dir.y, pos.z + dir.z --move to first node being pushed
|
||||||
|
|
||||||
--determine the number of nodes that need to be pushed
|
--determine the number of nodes that need to be pushed
|
||||||
local count = 0
|
local count = 0
|
||||||
local checkpos = {x=pos.x, y=pos.y, z=pos.z} --first node being pushed
|
local checkpos = {x=pos.x, y=pos.y, z=pos.z} --first node being pushed
|
||||||
while true do
|
while true do
|
||||||
local checknode = minetest.env:get_node(checkpos)
|
local checknode = minetest.env:get_node(checkpos)
|
||||||
|
|
||||||
--check for collision with stopper
|
--check for collision with stopper
|
||||||
if mesecon:is_mvps_stopper(checknode.name) then
|
if mesecon:is_mvps_stopper(checknode.name) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
--check for column end
|
--check for column end
|
||||||
if checknode.name == "air"
|
if checknode.name == "air"
|
||||||
or checknode.name == "ignore"
|
or checknode.name == "ignore"
|
||||||
or checknode.name == "default:water_source"
|
or string.find(checknode.name, "_source")
|
||||||
or checknode.name == "default:water_flowing"
|
or string.find(checknode.name, "_flowing") then
|
||||||
or checknode.name == "default:lava_source"
|
break
|
||||||
or checknode.name == "default:lava_flowing" then
|
end
|
||||||
break
|
|
||||||
end
|
--limit piston pushing capacity
|
||||||
|
count = count + 1
|
||||||
--limit piston pushing capacity
|
if count > 15 then
|
||||||
count = count + 1
|
return
|
||||||
if count > 15 then
|
end
|
||||||
return
|
|
||||||
end
|
checkpos.x, checkpos.y, checkpos.z = checkpos.x + dir.x, checkpos.y + dir.y, checkpos.z + dir.z
|
||||||
|
end
|
||||||
checkpos.x, checkpos.y, checkpos.z = checkpos.x + dir.x, checkpos.y + dir.y, checkpos.z + dir.z
|
|
||||||
end
|
local checknode = minetest.env:get_node(pos)
|
||||||
|
minetest.env:remove_node(pos) --remove the first node
|
||||||
local checknode = minetest.env:get_node(pos)
|
mesecon:updatenode(pos)
|
||||||
minetest.env:remove_node(pos) --remove the first node
|
|
||||||
mesecon:updatenode(pos)
|
--add pusher
|
||||||
|
if node.name == "mesecons_pistons:piston_normal" then
|
||||||
--add pusher
|
minetest.env:add_node(pos, {name="mesecons_pistons:piston_pusher_normal", param2=node.param2})
|
||||||
if node.name == "mesecons_pistons:piston_normal" then
|
else
|
||||||
minetest.env:add_node(pos, {name="mesecons_pistons:piston_pusher_normal", param2=node.param2})
|
minetest.env:add_node(pos, {name="mesecons_pistons:piston_pusher_sticky", param2=node.param2})
|
||||||
else
|
end
|
||||||
minetest.env:add_node(pos, {name="mesecons_pistons:piston_pusher_sticky", param2=node.param2})
|
|
||||||
end
|
--move nodes forward
|
||||||
|
for i = 1, count do
|
||||||
--move nodes forward
|
pos.x, pos.y, pos.z = pos.x + dir.x, pos.y + dir.y, pos.z + dir.z --move to the next node
|
||||||
for i = 1, count do
|
|
||||||
pos.x, pos.y, pos.z = pos.x + dir.x, pos.y + dir.y, pos.z + dir.z --move to the next node
|
--move the node forward
|
||||||
|
local nextnode = minetest.env:get_node(pos)
|
||||||
--move the node forward
|
--minetest.env:dig_node(pos)
|
||||||
local nextnode = minetest.env:get_node(pos)
|
minetest.env:set_node(pos, checknode)
|
||||||
--minetest.env:dig_node(pos)
|
mesecon:updatenode(pos)
|
||||||
minetest.env:set_node(pos, checknode)
|
checknode = nextnode
|
||||||
mesecon:updatenode(pos)
|
end
|
||||||
checknode = nextnode
|
end)
|
||||||
end
|
|
||||||
end)
|
--Pull action
|
||||||
|
mesecon:register_on_signal_off(function(pos, node)
|
||||||
--Pull action
|
if node.name ~= "mesecons_pistons:piston_normal" and node.name ~= "mesecons_pistons:piston_sticky" then
|
||||||
mesecon:register_on_signal_off(function(pos, node)
|
return
|
||||||
if node.name ~= "mesecons_pistons:piston_normal" and node.name ~= "mesecons_pistons:piston_sticky" then
|
end
|
||||||
return
|
|
||||||
end
|
local dir = mesecon:piston_get_direction(node)
|
||||||
|
pos.x, pos.y, pos.z = pos.x + dir.x, pos.y + dir.y, pos.z + dir.z --move to the node to be replaced
|
||||||
local dir = mesecon:piston_get_direction(node)
|
|
||||||
pos.x, pos.y, pos.z = pos.x + dir.x, pos.y + dir.y, pos.z + dir.z --move to the node to be replaced
|
--ensure piston is extended
|
||||||
|
local checknode = minetest.env:get_node(pos)
|
||||||
--ensure piston is extended
|
if checknode.name ~= "mesecons_pistons:piston_pusher_normal" and checknode.name ~= "mesecons_pistons:piston_pusher_sticky" then
|
||||||
local checknode = minetest.env:get_node(pos)
|
return
|
||||||
if checknode.name ~= "mesecons_pistons:piston_pusher_normal" and checknode.name ~= "mesecons_pistons:piston_pusher_sticky" then
|
end
|
||||||
return
|
if checknode.param2 ~= node.param2 then --pusher is not facing the same direction as the piston
|
||||||
end
|
return --piston is not extended
|
||||||
if checknode.param2 ~= node.param2 then --pusher is not facing the same direction as the piston
|
end
|
||||||
return --piston is not extended
|
|
||||||
end
|
--retract piston
|
||||||
|
minetest.env:remove_node(pos) --remove pusher
|
||||||
--retract piston
|
if node.name ~= "mesecons_pistons:piston_sticky" then
|
||||||
minetest.env:remove_node(pos) --remove pusher
|
nodeupdate(pos)
|
||||||
if node.name ~= "mesecons_pistons:piston_sticky" then
|
end
|
||||||
nodeupdate(pos)
|
if node.name == "mesecons_pistons:piston_sticky" then --retract block
|
||||||
end
|
local checkpos = {x=pos.x + dir.x, y=pos.y + dir.y, z=pos.z + dir.z} --move to the node to be retracted
|
||||||
if node.name == "mesecons_pistons:piston_sticky" then --retract block
|
checknode = minetest.env:get_node(checkpos)
|
||||||
local checkpos = {x=pos.x + dir.x, y=pos.y + dir.y, z=pos.z + dir.z} --move to the node to be retracted
|
if checknode.name ~= "air"
|
||||||
checknode = minetest.env:get_node(checkpos)
|
and checknode.name ~= "ignore"
|
||||||
if checknode.name ~= "air"
|
and string.find(checknode.name, "_source")
|
||||||
and checknode.name ~= "ignore"
|
and string.find(checknode.name, "_flowing")
|
||||||
and checknode.name ~= "default:water_source"
|
and not mesecon:is_mvps_stopper(checknode.name) then
|
||||||
and checknode.name ~= "default:water_flowing"
|
minetest.env:set_node(pos, checknode)
|
||||||
and checknode.name ~= "default:lava_source"
|
minetest.env:remove_node(checkpos)
|
||||||
and checknode.name ~= "default:lava_flowing"
|
mesecon:updatenode(checkpos)
|
||||||
and not mesecon:is_mvps_stopper(checknode.name) then
|
end
|
||||||
minetest.env:set_node(pos, checknode)
|
end
|
||||||
minetest.env:remove_node(checkpos)
|
if node.name == "mesecons_pistons:piston_sticky" then
|
||||||
mesecon:updatenode(checkpos)
|
nodeupdate(pos)
|
||||||
end
|
end
|
||||||
end
|
end)
|
||||||
if node.name == "mesecons_pistons:piston_sticky" then
|
|
||||||
nodeupdate(pos)
|
-- get push direction
|
||||||
end
|
function mesecon:piston_get_direction(node)
|
||||||
end)
|
if node.param2 == 3 then
|
||||||
|
return {x=1, y=0, z=0}
|
||||||
-- get push direction
|
elseif node.param2 == 2 then
|
||||||
function mesecon:piston_get_direction(node)
|
return {x=0, y=0, z=1}
|
||||||
if node.param2 == 3 then
|
elseif node.param2 == 1 then
|
||||||
return {x=1, y=0, z=0}
|
return {x=-1, y=0, z=0}
|
||||||
elseif node.param2 == 2 then
|
else --node.param2 == 0
|
||||||
return {x=0, y=0, z=1}
|
return {x=0, y=0, z=-1}
|
||||||
elseif node.param2 == 1 then
|
end
|
||||||
return {x=-1, y=0, z=0}
|
end
|
||||||
else --node.param2 == 0
|
|
||||||
return {x=0, y=0, z=-1}
|
dofile(minetest.get_modpath("mesecons_pistons").."/pistons_down.lua")
|
||||||
end
|
dofile(minetest.get_modpath("mesecons_pistons").."/pistons_up.lua")
|
||||||
end
|
|
||||||
|
|
||||||
dofile(minetest.get_modpath("mesecons_pistons").."/pistons_down.lua")
|
|
||||||
dofile(minetest.get_modpath("mesecons_pistons").."/pistons_up.lua")
|
|
||||||
|
@ -1,226 +1,222 @@
|
|||||||
--PISTONS
|
--PISTONS
|
||||||
--registration normal one:
|
--registration normal one:
|
||||||
minetest.register_node("mesecons_pistons:piston_down_normal", {
|
minetest.register_node("mesecons_pistons:piston_down_normal", {
|
||||||
description = "Piston DOWN",
|
description = "Piston DOWN",
|
||||||
tiles = {"jeija_piston_tb.png", "jeija_piston_side.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png"},
|
tiles = {"jeija_piston_tb.png", "jeija_piston_side.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png"},
|
||||||
groups = {cracky=3, mesecon = 2},
|
groups = {cracky=3, mesecon = 2},
|
||||||
after_dig_node = function(pos, oldnode)
|
after_dig_node = function(pos, oldnode)
|
||||||
local dir = {x=0, y=-1, z=0}
|
local dir = {x=0, y=-1, z=0}
|
||||||
pos.x, pos.y, pos.z = pos.x + dir.x, pos.y + dir.y, pos.z + dir.z --move to first node to check
|
pos.x, pos.y, pos.z = pos.x + dir.x, pos.y + dir.y, pos.z + dir.z --move to first node to check
|
||||||
|
|
||||||
--ensure piston is extended
|
--ensure piston is extended
|
||||||
local checknode = minetest.env:get_node(pos)
|
local checknode = minetest.env:get_node(pos)
|
||||||
if checknode.name == "mesecons_pistons:piston_down_pusher_normal" then
|
if checknode.name == "mesecons_pistons:piston_down_pusher_normal" then
|
||||||
if checknode.param2 == oldnode.param2 then --pusher is facing the same direction as the piston
|
if checknode.param2 == oldnode.param2 then --pusher is facing the same direction as the piston
|
||||||
minetest.env:remove_node(pos) --remove the pusher
|
minetest.env:remove_node(pos) --remove the pusher
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
mesecon:register_effector("mesecons_pistons:piston_down_normal", "mesecons_pistons:piston_down_normal")
|
mesecon:register_effector("mesecons_pistons:piston_down_normal", "mesecons_pistons:piston_down_normal")
|
||||||
|
|
||||||
--registration sticky one:
|
--registration sticky one:
|
||||||
minetest.register_node("mesecons_pistons:piston_down_sticky", {
|
minetest.register_node("mesecons_pistons:piston_down_sticky", {
|
||||||
description = "Sticky Piston DOWN",
|
description = "Sticky Piston DOWN",
|
||||||
tiles = {"jeija_piston_tb.png", "jeija_piston_sticky_side.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png"},
|
tiles = {"jeija_piston_tb.png", "jeija_piston_sticky_side.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png"},
|
||||||
groups = {cracky=3, mesecon = 2},
|
groups = {cracky=3, mesecon = 2},
|
||||||
after_dig_node = function(pos, oldnode)
|
after_dig_node = function(pos, oldnode)
|
||||||
local dir = {x=0, y=-1, z=0}
|
local dir = {x=0, y=-1, z=0}
|
||||||
pos.x, pos.y, pos.z = pos.x + dir.x, pos.y + dir.y, pos.z + dir.z --move to first node to check
|
pos.x, pos.y, pos.z = pos.x + dir.x, pos.y + dir.y, pos.z + dir.z --move to first node to check
|
||||||
|
|
||||||
--ensure piston is extended
|
--ensure piston is extended
|
||||||
local checknode = minetest.env:get_node(pos)
|
local checknode = minetest.env:get_node(pos)
|
||||||
if checknode.name == "mesecons_pistons:piston_down_pusher_sticky" then
|
if checknode.name == "mesecons_pistons:piston_down_pusher_sticky" then
|
||||||
if checknode.param2 == oldnode.param2 then --pusher is facing the same direction as the piston
|
if checknode.param2 == oldnode.param2 then --pusher is facing the same direction as the piston
|
||||||
minetest.env:remove_node(pos) --remove the pusher
|
minetest.env:remove_node(pos) --remove the pusher
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
mesecon:register_effector("mesecons_pistons:piston_down_sticky", "mesecons_pistons:piston_down_sticky")
|
mesecon:register_effector("mesecons_pistons:piston_down_sticky", "mesecons_pistons:piston_down_sticky")
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = "mesecons_pistons:piston_down_normal",
|
output = "mesecons_pistons:piston_down_normal",
|
||||||
recipe = {
|
recipe = {
|
||||||
{"mesecons_pistons:piston_up_normal"},
|
{"mesecons_pistons:piston_up_normal"},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = "mesecons_pistons:piston_normal",
|
output = "mesecons_pistons:piston_normal",
|
||||||
recipe = {
|
recipe = {
|
||||||
{"mesecons_pistons:piston_down_normal"},
|
{"mesecons_pistons:piston_down_normal"},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = "mesecons_pistons:piston_down_sticky",
|
output = "mesecons_pistons:piston_down_sticky",
|
||||||
recipe = {
|
recipe = {
|
||||||
{"mesecons_pistons:piston_up_sticky"},
|
{"mesecons_pistons:piston_up_sticky"},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = "mesecons_pistons:piston_sticky",
|
output = "mesecons_pistons:piston_sticky",
|
||||||
recipe = {
|
recipe = {
|
||||||
{"mesecons_pistons:piston_down_sticky"},
|
{"mesecons_pistons:piston_down_sticky"},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node("mesecons_pistons:piston_down_pusher_normal", {
|
minetest.register_node("mesecons_pistons:piston_down_pusher_normal", {
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
tiles = {"jeija_piston_pusher_normal.png"},
|
tiles = {"jeija_piston_pusher_normal.png"},
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
diggable = false,
|
diggable = false,
|
||||||
selection_box = {
|
selection_box = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = {
|
fixed = {
|
||||||
{-0.2, -0.3, -0.2, 0.2, 0.5, 0.2},
|
{-0.2, -0.3, -0.2, 0.2, 0.5, 0.2},
|
||||||
{-0.5, -0.5, -0.5, 0.5, -0.3, 0.5},
|
{-0.5, -0.5, -0.5, 0.5, -0.3, 0.5},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
node_box = {
|
node_box = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = {
|
fixed = {
|
||||||
{-0.2, -0.3, -0.2, 0.2, 0.5, 0.2},
|
{-0.2, -0.3, -0.2, 0.2, 0.5, 0.2},
|
||||||
{-0.5, -0.5, -0.5, 0.5, -0.3, 0.5},
|
{-0.5, -0.5, -0.5, 0.5, -0.3, 0.5},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
mesecon:register_mvps_stopper("mesecons_pistons:piston_down_pusher_normal")
|
mesecon:register_mvps_stopper("mesecons_pistons:piston_down_pusher_normal")
|
||||||
mesecon:register_mvps_stopper("mesecons_pistons:piston_down_pusher_sticky")
|
mesecon:register_mvps_stopper("mesecons_pistons:piston_down_pusher_sticky")
|
||||||
|
|
||||||
minetest.register_node("mesecons_pistons:piston_down_pusher_sticky", {
|
minetest.register_node("mesecons_pistons:piston_down_pusher_sticky", {
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
tiles = {
|
tiles = {
|
||||||
"jeija_piston_pusher_sticky.png",
|
"jeija_piston_pusher_sticky.png",
|
||||||
"jeija_piston_pusher_normal.png",
|
"jeija_piston_pusher_normal.png",
|
||||||
"jeija_piston_pusher_normal.png",
|
"jeija_piston_pusher_normal.png",
|
||||||
"jeija_piston_pusher_normal.png",
|
"jeija_piston_pusher_normal.png",
|
||||||
"jeija_piston_pusher_normal.png",
|
"jeija_piston_pusher_normal.png",
|
||||||
"jeija_piston_pusher_normal.png"
|
"jeija_piston_pusher_normal.png"
|
||||||
},
|
},
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
diggable = false,
|
diggable = false,
|
||||||
selection_box = {
|
selection_box = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = {
|
fixed = {
|
||||||
{-0.2, -0.3, -0.2, 0.2, 0.5, 0.2},
|
{-0.2, -0.3, -0.2, 0.2, 0.5, 0.2},
|
||||||
{-0.5, -0.5, -0.5, 0.5, -0.3, 0.5},
|
{-0.5, -0.5, -0.5, 0.5, -0.3, 0.5},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
node_box = {
|
node_box = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = {
|
fixed = {
|
||||||
{-0.2, -0.3, -0.2, 0.2, 0.5, 0.2},
|
{-0.2, -0.3, -0.2, 0.2, 0.5, 0.2},
|
||||||
{-0.5, -0.5, -0.5, 0.5, -0.3, 0.5},
|
{-0.5, -0.5, -0.5, 0.5, -0.3, 0.5},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Push action
|
-- Push action
|
||||||
mesecon:register_on_signal_on(function(pos, node)
|
mesecon:register_on_signal_on(function(pos, node)
|
||||||
if node.name ~= "mesecons_pistons:piston_down_normal" and node.name ~= "mesecons_pistons:piston_down_sticky" then
|
if node.name ~= "mesecons_pistons:piston_down_normal" and node.name ~= "mesecons_pistons:piston_down_sticky" then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local dir = {x=0, y=-1, z=0}
|
local dir = {x=0, y=-1, z=0}
|
||||||
pos.x, pos.y, pos.z = pos.x + dir.x, pos.y + dir.y, pos.z + dir.z --move to first node being pushed
|
pos.x, pos.y, pos.z = pos.x + dir.x, pos.y + dir.y, pos.z + dir.z --move to first node being pushed
|
||||||
|
|
||||||
--determine the number of nodes that need to be pushed
|
--determine the number of nodes that need to be pushed
|
||||||
local count = 0
|
local count = 0
|
||||||
local checkpos = {x=pos.x, y=pos.y, z=pos.z} --first node being pushed
|
local checkpos = {x=pos.x, y=pos.y, z=pos.z} --first node being pushed
|
||||||
while true do
|
while true do
|
||||||
local checknode = minetest.env:get_node(checkpos)
|
local checknode = minetest.env:get_node(checkpos)
|
||||||
|
|
||||||
--check for collision with stopper
|
--check for collision with stopper
|
||||||
if mesecon:is_mvps_stopper(checknode.name) then
|
if mesecon:is_mvps_stopper(checknode.name) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
--check for column end
|
--check for column end
|
||||||
if checknode.name == "air"
|
if checknode.name == "air"
|
||||||
or checknode.name == "ignore"
|
or checknode.name == "ignore"
|
||||||
or checknode.name == "default:water_source"
|
or string.find(checknode.name, "_flowing")
|
||||||
or checknode.name == "default:water_flowing"
|
or string.find(checknode.name, "_source") then
|
||||||
or checknode.name == "default:lava_source"
|
break
|
||||||
or checknode.name == "default:lava_flowing" then
|
end
|
||||||
break
|
|
||||||
end
|
--limit piston pushing capacity
|
||||||
|
count = count + 1
|
||||||
--limit piston pushing capacity
|
if count > 15 then
|
||||||
count = count + 1
|
return
|
||||||
if count > 15 then
|
end
|
||||||
return
|
|
||||||
end
|
checkpos.x, checkpos.y, checkpos.z = checkpos.x + dir.x, checkpos.y + dir.y, checkpos.z + dir.z
|
||||||
|
end
|
||||||
checkpos.x, checkpos.y, checkpos.z = checkpos.x + dir.x, checkpos.y + dir.y, checkpos.z + dir.z
|
|
||||||
end
|
local checknode = minetest.env:get_node(pos)
|
||||||
|
minetest.env:remove_node(pos) --remove the first node
|
||||||
local checknode = minetest.env:get_node(pos)
|
mesecon:updatenode(pos)
|
||||||
minetest.env:remove_node(pos) --remove the first node
|
|
||||||
mesecon:updatenode(pos)
|
--add pusher
|
||||||
|
if node.name == "mesecons_pistons:piston_down_normal" then
|
||||||
--add pusher
|
minetest.env:add_node(pos, {name="mesecons_pistons:piston_down_pusher_normal", param2=node.param2})
|
||||||
if node.name == "mesecons_pistons:piston_down_normal" then
|
else
|
||||||
minetest.env:add_node(pos, {name="mesecons_pistons:piston_down_pusher_normal", param2=node.param2})
|
minetest.env:add_node(pos, {name="mesecons_pistons:piston_down_pusher_sticky", param2=node.param2})
|
||||||
else
|
end
|
||||||
minetest.env:add_node(pos, {name="mesecons_pistons:piston_down_pusher_sticky", param2=node.param2})
|
|
||||||
end
|
--move nodes forward
|
||||||
|
for i = 1, count do
|
||||||
--move nodes forward
|
pos.x, pos.y, pos.z = pos.x + dir.x, pos.y + dir.y, pos.z + dir.z --move to the next node
|
||||||
for i = 1, count do
|
|
||||||
pos.x, pos.y, pos.z = pos.x + dir.x, pos.y + dir.y, pos.z + dir.z --move to the next node
|
--move the node forward
|
||||||
|
local nextnode = minetest.env:get_node(pos)
|
||||||
--move the node forward
|
--minetest.env:dig_node(pos)
|
||||||
local nextnode = minetest.env:get_node(pos)
|
minetest.env:set_node(pos, checknode)
|
||||||
--minetest.env:dig_node(pos)
|
mesecon:updatenode(pos)
|
||||||
minetest.env:set_node(pos, checknode)
|
checknode = nextnode
|
||||||
mesecon:updatenode(pos)
|
end
|
||||||
checknode = nextnode
|
end)
|
||||||
end
|
|
||||||
end)
|
--Pull action
|
||||||
|
mesecon:register_on_signal_off(function(pos, node)
|
||||||
--Pull action
|
if node.name ~= "mesecons_pistons:piston_down_normal" and node.name ~= "mesecons_pistons:piston_down_sticky" then
|
||||||
mesecon:register_on_signal_off(function(pos, node)
|
return
|
||||||
if node.name ~= "mesecons_pistons:piston_down_normal" and node.name ~= "mesecons_pistons:piston_down_sticky" then
|
end
|
||||||
return
|
|
||||||
end
|
local dir = {x=0, y=-1, z=0}
|
||||||
|
pos.x, pos.y, pos.z = pos.x + dir.x, pos.y + dir.y, pos.z + dir.z --move to the node to be replaced
|
||||||
local dir = {x=0, y=-1, z=0}
|
|
||||||
pos.x, pos.y, pos.z = pos.x + dir.x, pos.y + dir.y, pos.z + dir.z --move to the node to be replaced
|
--ensure piston is extended
|
||||||
|
local checknode = minetest.env:get_node(pos)
|
||||||
--ensure piston is extended
|
if checknode.name ~= "mesecons_pistons:piston_down_pusher_normal" and checknode.name ~= "mesecons_pistons:piston_down_pusher_sticky" then
|
||||||
local checknode = minetest.env:get_node(pos)
|
return
|
||||||
if checknode.name ~= "mesecons_pistons:piston_down_pusher_normal" and checknode.name ~= "mesecons_pistons:piston_down_pusher_sticky" then
|
end
|
||||||
return
|
if checknode.param2 ~= node.param2 then --pusher is not facing the same direction as the piston
|
||||||
end
|
return --piston is not extended
|
||||||
if checknode.param2 ~= node.param2 then --pusher is not facing the same direction as the piston
|
end
|
||||||
return --piston is not extended
|
|
||||||
end
|
--retract piston
|
||||||
|
minetest.env:remove_node(pos) --remove pusher
|
||||||
--retract piston
|
if node.name ~= "mesecons_pistons:piston_down_sticky" then
|
||||||
minetest.env:remove_node(pos) --remove pusher
|
nodeupdate(pos)
|
||||||
if node.name ~= "mesecons_pistons:piston_down_sticky" then
|
end
|
||||||
nodeupdate(pos)
|
if node.name == "mesecons_pistons:piston_down_sticky" then --retract block
|
||||||
end
|
local checkpos = {x=pos.x + dir.x, y=pos.y + dir.y, z=pos.z + dir.z} --move to the node to be retracted
|
||||||
if node.name == "mesecons_pistons:piston_down_sticky" then --retract block
|
checknode = minetest.env:get_node(checkpos)
|
||||||
local checkpos = {x=pos.x + dir.x, y=pos.y + dir.y, z=pos.z + dir.z} --move to the node to be retracted
|
if checknode.name ~= "air"
|
||||||
checknode = minetest.env:get_node(checkpos)
|
and checknode.name ~= "ignore"
|
||||||
if checknode.name ~= "air"
|
and string.find(checknode.name, "_source")
|
||||||
and checknode.name ~= "ignore"
|
and string.find(checknode.name, "_flowing")
|
||||||
and checknode.name ~= "default:water_source"
|
and not mesecon:is_mvps_stopper(checknode.name) then
|
||||||
and checknode.name ~= "default:water_flowing"
|
minetest.env:remove_node(checkpos)
|
||||||
and checknode.name ~= "default:lava_source"
|
mesecon:updatenode(checkpos)
|
||||||
and checknode.name ~= "default:lava_flowing"
|
minetest.env:set_node(pos, checknode)
|
||||||
and not mesecon:is_mvps_stopper(checknode.name) then
|
mesecon:updatenode(pos)
|
||||||
minetest.env:remove_node(checkpos)
|
end
|
||||||
mesecon:updatenode(checkpos)
|
end
|
||||||
minetest.env:set_node(pos, checknode)
|
if node.name == "mesecons_pistons:piston_down_sticky" then
|
||||||
mesecon:updatenode(pos)
|
nodeupdate(pos)
|
||||||
end
|
end
|
||||||
end
|
end)
|
||||||
if node.name == "mesecons_pistons:piston_down_sticky" then
|
|
||||||
nodeupdate(pos)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
@ -1,214 +1,210 @@
|
|||||||
--PISTONS
|
--PISTONS
|
||||||
--registration normal one:
|
--registration normal one:
|
||||||
minetest.register_node("mesecons_pistons:piston_up_normal", {
|
minetest.register_node("mesecons_pistons:piston_up_normal", {
|
||||||
description = "Piston UP",
|
description = "Piston UP",
|
||||||
tiles = {"jeija_piston_side.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png"},
|
tiles = {"jeija_piston_side.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png"},
|
||||||
groups = {cracky=3, mesecon = 2},
|
groups = {cracky=3, mesecon = 2},
|
||||||
after_dig_node = function(pos, oldnode)
|
after_dig_node = function(pos, oldnode)
|
||||||
local dir = {x=0, y=1, z=0}
|
local dir = {x=0, y=1, z=0}
|
||||||
pos.x, pos.y, pos.z = pos.x + dir.x, pos.y + dir.y, pos.z + dir.z --move to first node to check
|
pos.x, pos.y, pos.z = pos.x + dir.x, pos.y + dir.y, pos.z + dir.z --move to first node to check
|
||||||
|
|
||||||
--ensure piston is extended
|
--ensure piston is extended
|
||||||
local checknode = minetest.env:get_node(pos)
|
local checknode = minetest.env:get_node(pos)
|
||||||
if checknode.name == "mesecons_pistons:piston_up_pusher_normal" then
|
if checknode.name == "mesecons_pistons:piston_up_pusher_normal" then
|
||||||
if checknode.param2 == oldnode.param2 then --pusher is facing the same direction as the piston
|
if checknode.param2 == oldnode.param2 then --pusher is facing the same direction as the piston
|
||||||
minetest.env:remove_node(pos) --remove the pusher
|
minetest.env:remove_node(pos) --remove the pusher
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
mesecon:register_effector("mesecons_pistons:piston_up_normal", "mesecons_pistons:piston_up_normal")
|
mesecon:register_effector("mesecons_pistons:piston_up_normal", "mesecons_pistons:piston_up_normal")
|
||||||
|
|
||||||
--registration sticky one:
|
--registration sticky one:
|
||||||
minetest.register_node("mesecons_pistons:piston_up_sticky", {
|
minetest.register_node("mesecons_pistons:piston_up_sticky", {
|
||||||
description = "Sticky Piston UP",
|
description = "Sticky Piston UP",
|
||||||
tiles = {"jeija_piston_sticky_side.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png"},
|
tiles = {"jeija_piston_sticky_side.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png"},
|
||||||
groups = {cracky=3, mesecon = 2},
|
groups = {cracky=3, mesecon = 2},
|
||||||
after_dig_node = function(pos, oldnode)
|
after_dig_node = function(pos, oldnode)
|
||||||
local dir = {x=0, y=1, z=0}
|
local dir = {x=0, y=1, z=0}
|
||||||
pos.x, pos.y, pos.z = pos.x + dir.x, pos.y + dir.y, pos.z + dir.z --move to first node to check
|
pos.x, pos.y, pos.z = pos.x + dir.x, pos.y + dir.y, pos.z + dir.z --move to first node to check
|
||||||
|
|
||||||
--ensure piston is extended
|
--ensure piston is extended
|
||||||
local checknode = minetest.env:get_node(pos)
|
local checknode = minetest.env:get_node(pos)
|
||||||
if checknode.name == "mesecons_pistons:piston_up_pusher_sticky" then
|
if checknode.name == "mesecons_pistons:piston_up_pusher_sticky" then
|
||||||
if checknode.param2 == oldnode.param2 then --pusher is facing the same direction as the piston
|
if checknode.param2 == oldnode.param2 then --pusher is facing the same direction as the piston
|
||||||
minetest.env:remove_node(pos) --remove the pusher
|
minetest.env:remove_node(pos) --remove the pusher
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
mesecon:register_effector("mesecons_pistons:piston_up_sticky", "mesecons_pistons:piston_up_sticky")
|
mesecon:register_effector("mesecons_pistons:piston_up_sticky", "mesecons_pistons:piston_up_sticky")
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = "mesecons_pistons:piston_up_normal",
|
output = "mesecons_pistons:piston_up_normal",
|
||||||
recipe = {
|
recipe = {
|
||||||
{"mesecons_pistons:piston_normal"},
|
{"mesecons_pistons:piston_normal"},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = "mesecons_pistons:piston_up_sticky",
|
output = "mesecons_pistons:piston_up_sticky",
|
||||||
recipe = {
|
recipe = {
|
||||||
{"mesecons_pistons:piston_sticky"},
|
{"mesecons_pistons:piston_sticky"},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node("mesecons_pistons:piston_up_pusher_normal", {
|
minetest.register_node("mesecons_pistons:piston_up_pusher_normal", {
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
tiles = {"jeija_piston_pusher_normal.png"},
|
tiles = {"jeija_piston_pusher_normal.png"},
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
diggable = false,
|
diggable = false,
|
||||||
selection_box = {
|
selection_box = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = {
|
fixed = {
|
||||||
{-0.2, -0.5, -0.2, 0.2, 0.3, 0.2},
|
{-0.2, -0.5, -0.2, 0.2, 0.3, 0.2},
|
||||||
{-0.5, 0.3, -0.5, 0.5, 0.5, 0.5},
|
{-0.5, 0.3, -0.5, 0.5, 0.5, 0.5},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
node_box = {
|
node_box = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = {
|
fixed = {
|
||||||
{-0.2, -0.5, -0.2, 0.2, 0.3, 0.2},
|
{-0.2, -0.5, -0.2, 0.2, 0.3, 0.2},
|
||||||
{-0.5, 0.3, -0.5, 0.5, 0.5, 0.5},
|
{-0.5, 0.3, -0.5, 0.5, 0.5, 0.5},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
mesecon:register_mvps_stopper("mesecons_pistons:piston_up_pusher_normal")
|
mesecon:register_mvps_stopper("mesecons_pistons:piston_up_pusher_normal")
|
||||||
mesecon:register_mvps_stopper("mesecons_pistons:piston_up_pusher_sticky")
|
mesecon:register_mvps_stopper("mesecons_pistons:piston_up_pusher_sticky")
|
||||||
|
|
||||||
minetest.register_node("mesecons_pistons:piston_up_pusher_sticky", {
|
minetest.register_node("mesecons_pistons:piston_up_pusher_sticky", {
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
tiles = {
|
tiles = {
|
||||||
"jeija_piston_pusher_normal.png",
|
"jeija_piston_pusher_normal.png",
|
||||||
"jeija_piston_pusher_sticky.png",
|
"jeija_piston_pusher_sticky.png",
|
||||||
"jeija_piston_pusher_normal.png",
|
"jeija_piston_pusher_normal.png",
|
||||||
"jeija_piston_pusher_normal.png",
|
"jeija_piston_pusher_normal.png",
|
||||||
"jeija_piston_pusher_normal.png",
|
"jeija_piston_pusher_normal.png",
|
||||||
"jeija_piston_pusher_normal.png"
|
"jeija_piston_pusher_normal.png"
|
||||||
},
|
},
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
diggable = false,
|
diggable = false,
|
||||||
selection_box = {
|
selection_box = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = {
|
fixed = {
|
||||||
{-0.2, -0.5, -0.2, 0.2, 0.3, 0.2},
|
{-0.2, -0.5, -0.2, 0.2, 0.3, 0.2},
|
||||||
{-0.5, 0.3, -0.5, 0.5, 0.5, 0.5},
|
{-0.5, 0.3, -0.5, 0.5, 0.5, 0.5},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
node_box = {
|
node_box = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = {
|
fixed = {
|
||||||
{-0.2, -0.5, -0.2, 0.2, 0.3, 0.2},
|
{-0.2, -0.5, -0.2, 0.2, 0.3, 0.2},
|
||||||
{-0.5, 0.3, -0.5, 0.5, 0.5, 0.5},
|
{-0.5, 0.3, -0.5, 0.5, 0.5, 0.5},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Push action
|
-- Push action
|
||||||
mesecon:register_on_signal_on(function(pos, node)
|
mesecon:register_on_signal_on(function(pos, node)
|
||||||
if node.name ~= "mesecons_pistons:piston_up_normal" and node.name ~= "mesecons_pistons:piston_up_sticky" then
|
if node.name ~= "mesecons_pistons:piston_up_normal" and node.name ~= "mesecons_pistons:piston_up_sticky" then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local dir = {x=0, y=1, z=0}
|
local dir = {x=0, y=1, z=0}
|
||||||
pos.x, pos.y, pos.z = pos.x + dir.x, pos.y + dir.y, pos.z + dir.z --move to first node being pushed
|
pos.x, pos.y, pos.z = pos.x + dir.x, pos.y + dir.y, pos.z + dir.z --move to first node being pushed
|
||||||
|
|
||||||
--determine the number of nodes that need to be pushed
|
--determine the number of nodes that need to be pushed
|
||||||
local count = 0
|
local count = 0
|
||||||
local checkpos = {x=pos.x, y=pos.y, z=pos.z} --first node being pushed
|
local checkpos = {x=pos.x, y=pos.y, z=pos.z} --first node being pushed
|
||||||
while true do
|
while true do
|
||||||
local checknode = minetest.env:get_node(checkpos)
|
local checknode = minetest.env:get_node(checkpos)
|
||||||
|
|
||||||
--check for collision with stopper
|
--check for collision with stopper
|
||||||
if mesecon:is_mvps_stopper(checknode.name) then
|
if mesecon:is_mvps_stopper(checknode.name) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
--check for column end
|
--check for column end
|
||||||
if checknode.name == "air"
|
if checknode.name == "air"
|
||||||
or checknode.name == "ignore"
|
or checknode.name == "ignore"
|
||||||
or checknode.name == "default:water_source"
|
or string.find(checknode.name, "_source")
|
||||||
or checknode.name == "default:water_flowing"
|
or string.find(checknode.name, "_flowing") then
|
||||||
or checknode.name == "default:lava_source"
|
break
|
||||||
or checknode.name == "default:lava_flowing" then
|
end
|
||||||
break
|
|
||||||
end
|
--limit piston pushing capacity
|
||||||
|
count = count + 1
|
||||||
--limit piston pushing capacity
|
if count > 15 then
|
||||||
count = count + 1
|
return
|
||||||
if count > 15 then
|
end
|
||||||
return
|
|
||||||
end
|
checkpos.x, checkpos.y, checkpos.z = checkpos.x + dir.x, checkpos.y + dir.y, checkpos.z + dir.z
|
||||||
|
end
|
||||||
checkpos.x, checkpos.y, checkpos.z = checkpos.x + dir.x, checkpos.y + dir.y, checkpos.z + dir.z
|
|
||||||
end
|
local checknode = minetest.env:get_node(pos)
|
||||||
|
minetest.env:remove_node(pos) --remove the first node
|
||||||
local checknode = minetest.env:get_node(pos)
|
mesecon:updatenode(pos)
|
||||||
minetest.env:remove_node(pos) --remove the first node
|
|
||||||
mesecon:updatenode(pos)
|
--add pusher
|
||||||
|
if node.name == "mesecons_pistons:piston_up_normal" then
|
||||||
--add pusher
|
minetest.env:add_node(pos, {name="mesecons_pistons:piston_up_pusher_normal", param2=node.param2})
|
||||||
if node.name == "mesecons_pistons:piston_up_normal" then
|
else
|
||||||
minetest.env:add_node(pos, {name="mesecons_pistons:piston_up_pusher_normal", param2=node.param2})
|
minetest.env:add_node(pos, {name="mesecons_pistons:piston_up_pusher_sticky", param2=node.param2})
|
||||||
else
|
end
|
||||||
minetest.env:add_node(pos, {name="mesecons_pistons:piston_up_pusher_sticky", param2=node.param2})
|
|
||||||
end
|
--move nodes forward
|
||||||
|
for i = 1, count do
|
||||||
--move nodes forward
|
pos.x, pos.y, pos.z = pos.x + dir.x, pos.y + dir.y, pos.z + dir.z --move to the next node
|
||||||
for i = 1, count do
|
|
||||||
pos.x, pos.y, pos.z = pos.x + dir.x, pos.y + dir.y, pos.z + dir.z --move to the next node
|
--move the node forward
|
||||||
|
local nextnode = minetest.env:get_node(pos)
|
||||||
--move the node forward
|
--minetest.env:dig_node(pos)
|
||||||
local nextnode = minetest.env:get_node(pos)
|
minetest.env:set_node(pos, checknode)
|
||||||
--minetest.env:dig_node(pos)
|
mesecon:updatenode(pos)
|
||||||
minetest.env:set_node(pos, checknode)
|
checknode = nextnode
|
||||||
mesecon:updatenode(pos)
|
end
|
||||||
checknode = nextnode
|
end)
|
||||||
end
|
|
||||||
end)
|
--Pull action
|
||||||
|
mesecon:register_on_signal_off(function(pos, node)
|
||||||
--Pull action
|
if node.name ~= "mesecons_pistons:piston_up_normal" and node.name ~= "mesecons_pistons:piston_up_sticky" then
|
||||||
mesecon:register_on_signal_off(function(pos, node)
|
return
|
||||||
if node.name ~= "mesecons_pistons:piston_up_normal" and node.name ~= "mesecons_pistons:piston_up_sticky" then
|
end
|
||||||
return
|
|
||||||
end
|
local dir = {x=0, y=1, z=0}
|
||||||
|
pos.x, pos.y, pos.z = pos.x + dir.x, pos.y + dir.y, pos.z + dir.z --move to the node to be replaced
|
||||||
local dir = {x=0, y=1, z=0}
|
|
||||||
pos.x, pos.y, pos.z = pos.x + dir.x, pos.y + dir.y, pos.z + dir.z --move to the node to be replaced
|
--ensure piston is extended
|
||||||
|
local checknode = minetest.env:get_node(pos)
|
||||||
--ensure piston is extended
|
if checknode.name ~= "mesecons_pistons:piston_up_pusher_normal" and checknode.name ~= "mesecons_pistons:piston_up_pusher_sticky" then
|
||||||
local checknode = minetest.env:get_node(pos)
|
return
|
||||||
if checknode.name ~= "mesecons_pistons:piston_up_pusher_normal" and checknode.name ~= "mesecons_pistons:piston_up_pusher_sticky" then
|
end
|
||||||
return
|
if checknode.param2 ~= node.param2 then --pusher is not facing the same direction as the piston
|
||||||
end
|
return --piston is not extended
|
||||||
if checknode.param2 ~= node.param2 then --pusher is not facing the same direction as the piston
|
end
|
||||||
return --piston is not extended
|
|
||||||
end
|
--retract piston
|
||||||
|
minetest.env:remove_node(pos) --remove pusher
|
||||||
--retract piston
|
if node.name ~= "mesecons_pistons:piston_up_sticky" then
|
||||||
minetest.env:remove_node(pos) --remove pusher
|
nodeupdate(pos)
|
||||||
if node.name ~= "mesecons_pistons:piston_up_sticky" then
|
end
|
||||||
nodeupdate(pos)
|
if node.name == "mesecons_pistons:piston_up_sticky" then --retract block
|
||||||
end
|
local checkpos = {x=pos.x + dir.x, y=pos.y + dir.y, z=pos.z + dir.z} --move to the node to be retracted
|
||||||
if node.name == "mesecons_pistons:piston_up_sticky" then --retract block
|
checknode = minetest.env:get_node(checkpos)
|
||||||
local checkpos = {x=pos.x + dir.x, y=pos.y + dir.y, z=pos.z + dir.z} --move to the node to be retracted
|
if checknode.name ~= "air"
|
||||||
checknode = minetest.env:get_node(checkpos)
|
and checknode.name ~= "ignore"
|
||||||
if checknode.name ~= "air"
|
and string.find(checknode.name, "_source")
|
||||||
and checknode.name ~= "ignore"
|
and string.find(checknode.name, "_flowing")
|
||||||
and checknode.name ~= "default:water_source"
|
and not mesecon:is_mvps_stopper(checknode.name) then
|
||||||
and checknode.name ~= "default:water_flowing"
|
minetest.env:remove_node(checkpos)
|
||||||
and checknode.name ~= "default:lava_source"
|
mesecon:updatenode(checkpos)
|
||||||
and checknode.name ~= "default:lava_flowing"
|
minetest.env:set_node(pos, checknode)
|
||||||
and not mesecon:is_mvps_stopper(checknode.name) then
|
mesecon:updatenode(pos)
|
||||||
minetest.env:remove_node(checkpos)
|
end
|
||||||
mesecon:updatenode(checkpos)
|
end
|
||||||
minetest.env:set_node(pos, checknode)
|
if node.name == "mesecons_pistons:piston_up_sticky" then
|
||||||
mesecon:updatenode(pos)
|
nodeupdate(pos)
|
||||||
end
|
end
|
||||||
end
|
end)
|
||||||
if node.name == "mesecons_pistons:piston_up_sticky" then
|
|
||||||
nodeupdate(pos)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user