forked from Mirrorlandia_minetest/mesecons
Port a lot more (basically everything apart from gates, pistons and extrawire crossing) to the new nodedef system. There are some problems with wall button and wall lever (in the way they visually connect to wires)
This commit is contained in:
parent
cf6080f723
commit
b37bdbf55c
@ -23,22 +23,5 @@ mesecon.rules.buttonlike =
|
|||||||
{x = 1, y =-1, z =-1},
|
{x = 1, y =-1, z =-1},
|
||||||
{x = 2, y = 0, z = 0}}
|
{x = 2, y = 0, z = 0}}
|
||||||
|
|
||||||
mesecon.rules.pressurplatelike =
|
|
||||||
{{x=0, y=1, 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=0, z=1},
|
|
||||||
{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=0, z=0},
|
|
||||||
{x=0, y=-1, z=0},
|
|
||||||
{x=0, y=-2, z=0},
|
|
||||||
{x=0, y=1, z=0}}
|
|
||||||
|
|
||||||
mesecon.state.on = "on"
|
mesecon.state.on = "on"
|
||||||
mesecon.state.off = "off"
|
mesecon.state.off = "off"
|
||||||
|
@ -32,7 +32,7 @@ minetest.register_node("mesecons_button:button_off", {
|
|||||||
description = "Button",
|
description = "Button",
|
||||||
on_punch = function (pos, node)
|
on_punch = function (pos, node)
|
||||||
mesecon:swap_node(pos, "mesecons_button:button_on")
|
mesecon:swap_node(pos, "mesecons_button:button_on")
|
||||||
local rules=mesecon.button_get_rules(node.param2)
|
local rules=mesecon.button_get_rules(node)
|
||||||
mesecon:receptor_on(pos, rules)
|
mesecon:receptor_on(pos, rules)
|
||||||
minetest.after(1, mesecon.button_turnoff, {pos=pos, param2=node.param2})
|
minetest.after(1, mesecon.button_turnoff, {pos=pos, param2=node.param2})
|
||||||
end,
|
end,
|
||||||
@ -81,7 +81,7 @@ minetest.register_node("mesecons_button:button_on", {
|
|||||||
mesecon.button_turnoff = function (params)
|
mesecon.button_turnoff = function (params)
|
||||||
if minetest.env:get_node(params.pos).name=="mesecons_button:button_on" then
|
if minetest.env:get_node(params.pos).name=="mesecons_button:button_on" then
|
||||||
mesecon:swap_node(params.pos, "mesecons_button:button_off")
|
mesecon:swap_node(params.pos, "mesecons_button:button_off")
|
||||||
local rules=mesecon.button_get_rules(params.param2)
|
local rules=mesecon.button_get_rules(params)
|
||||||
mesecon:receptor_off(params.pos, rules)
|
mesecon:receptor_off(params.pos, rules)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -40,7 +40,6 @@ local delayer_turnoff = function(params)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local delayer_update = function(pos, node)
|
local delayer_update = function(pos, node)
|
||||||
print("update")
|
|
||||||
if string.find(node.name, "mesecons_delayer:delayer_off")~=nil then
|
if string.find(node.name, "mesecons_delayer:delayer_off")~=nil then
|
||||||
local time = 0
|
local time = 0
|
||||||
if node.name=="mesecons_delayer:delayer_off_1" then
|
if node.name=="mesecons_delayer:delayer_off_1" then
|
||||||
|
@ -9,8 +9,7 @@ minetest.register_node("mesecons_detector:object_detector_off", {
|
|||||||
groups = {cracky=3},
|
groups = {cracky=3},
|
||||||
description="Player Detector",
|
description="Player Detector",
|
||||||
mesecons = {receptor = {
|
mesecons = {receptor = {
|
||||||
state = mesecon.state.off,
|
state = mesecon.state.off
|
||||||
rules = mesecon.rules.pressurplatelike
|
|
||||||
}}
|
}}
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -21,8 +20,7 @@ minetest.register_node("mesecons_detector:object_detector_on", {
|
|||||||
groups = {cracky=3,not_in_creative_inventory=1},
|
groups = {cracky=3,not_in_creative_inventory=1},
|
||||||
drop = 'mesecons_detector:object_detector_off',
|
drop = 'mesecons_detector:object_detector_off',
|
||||||
mesecons = {receptor = {
|
mesecons = {receptor = {
|
||||||
state = mesecon.state.on,
|
state = mesecon.state.on
|
||||||
rules = mesecon.rules.pressurplatelike
|
|
||||||
}}
|
}}
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -50,7 +48,7 @@ minetest.register_abm(
|
|||||||
end
|
end
|
||||||
local objpos=obj:getpos()
|
local objpos=obj:getpos()
|
||||||
minetest.env:add_node(pos, {name="mesecons_detector:object_detector_on"})
|
minetest.env:add_node(pos, {name="mesecons_detector:object_detector_on"})
|
||||||
mesecon:receptor_on(pos, mesecon:get_rules("pressureplate"))
|
mesecon:receptor_on(pos)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
@ -78,7 +76,7 @@ minetest.register_abm(
|
|||||||
end
|
end
|
||||||
if objectfound==0 then
|
if objectfound==0 then
|
||||||
minetest.env:add_node(pos, {name="mesecons_detector:object_detector_off"})
|
minetest.env:add_node(pos, {name="mesecons_detector:object_detector_off"})
|
||||||
mesecon:receptor_off(pos, mesecon:get_rules("pressureplate"))
|
mesecon:receptor_off(pos)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
-- MESELAMPS
|
-- MESELAMPS
|
||||||
|
-- A lamp is "is an electrical device used to create artificial light" (wikipedia)
|
||||||
|
-- guess what?
|
||||||
|
|
||||||
minetest.register_node("mesecons_lamp:lamp_on", {
|
minetest.register_node("mesecons_lamp:lamp_on", {
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
tiles = {"jeija_meselamp_on.png"},
|
tiles = {"jeija_meselamp_on.png"},
|
||||||
@ -20,8 +23,13 @@ minetest.register_node("mesecons_lamp:lamp_on", {
|
|||||||
wall_bottom = {-0.3125,-0.5,-0.3125,0.3125,-0.375,0.3125},
|
wall_bottom = {-0.3125,-0.5,-0.3125,0.3125,-0.375,0.3125},
|
||||||
wall_side = {-0.375,-0.3125,-0.3125,-0.5,0.3125,0.3125},
|
wall_side = {-0.375,-0.3125,-0.3125,-0.5,0.3125,0.3125},
|
||||||
},
|
},
|
||||||
groups = {dig_immediate=3,not_in_creative_inventory=1, mesecon_effector_on = 1, mesecon = 2},
|
groups = {dig_immediate=3,not_in_creative_inventory=1, mesecon_effector_on = 1},
|
||||||
drop='"mesecons_lamp:lamp_off" 1',
|
drop='"mesecons_lamp:lamp_off" 1',
|
||||||
|
mesecons = {effector = {
|
||||||
|
action_off = function (pos, node)
|
||||||
|
mesecon:swap_node(pos, "mesecons_lamp:lamp_off")
|
||||||
|
end
|
||||||
|
}}
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node("mesecons_lamp:lamp_off", {
|
minetest.register_node("mesecons_lamp:lamp_off", {
|
||||||
@ -45,8 +53,13 @@ minetest.register_node("mesecons_lamp:lamp_off", {
|
|||||||
wall_bottom = {-0.3125,-0.5,-0.3125,0.3125,-0.375,0.3125},
|
wall_bottom = {-0.3125,-0.5,-0.3125,0.3125,-0.375,0.3125},
|
||||||
wall_side = {-0.375,-0.3125,-0.3125,-0.5,0.3125,0.3125},
|
wall_side = {-0.375,-0.3125,-0.3125,-0.5,0.3125,0.3125},
|
||||||
},
|
},
|
||||||
groups = {dig_immediate=3, mesecon_receptor_off = 1, mesecon_effector_off = 1, mesecon = 2},
|
groups = {dig_immediate=3, mesecon_receptor_off = 1, mesecon_effector_off = 1},
|
||||||
description="Meselamp",
|
description="Meselamp",
|
||||||
|
mesecons = {effector = {
|
||||||
|
action_on = function (pos, node)
|
||||||
|
mesecon:swap_node(pos, "mesecons_lamp:lamp_on")
|
||||||
|
end
|
||||||
|
}}
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
@ -57,19 +70,3 @@ minetest.register_craft({
|
|||||||
{'', '"default:glass"', ''},
|
{'', '"default:glass"', ''},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
mesecon:register_on_signal_on(function(pos, node)
|
|
||||||
if node.name == "mesecons_lamp:lamp_off" then
|
|
||||||
minetest.env:add_node(pos, {name="mesecons_lamp:lamp_on", param2 = node.param2})
|
|
||||||
nodeupdate(pos)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
mesecon:register_on_signal_off(function(pos, node)
|
|
||||||
if node.name == "mesecons_lamp:lamp_on" then
|
|
||||||
minetest.env:add_node(pos, {name="mesecons_lamp:lamp_off", param2 = node.param2})
|
|
||||||
nodeupdate(pos)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
mesecon:register_effector("mesecons_lamp:lamp_on", "mesecons_lamp:lamp_off")
|
|
||||||
|
@ -23,6 +23,33 @@ if tostring(d)..tostring(c)..tostring(b)..tostring(a) ~= "0000" then
|
|||||||
else
|
else
|
||||||
groups = {dig_immediate=2, mesecon = 3}
|
groups = {dig_immediate=2, mesecon = 3}
|
||||||
end
|
end
|
||||||
|
local rules={}
|
||||||
|
if (a == 1) then table.insert(rules, {x = -1, y = 0, z = 0}) end
|
||||||
|
if (b == 1) then table.insert(rules, {x = 0, y = 0, z = 1}) end
|
||||||
|
if (c == 1) then table.insert(rules, {x = 1, y = 0, z = 0}) end
|
||||||
|
if (d == 1) then table.insert(rules, {x = 0, y = 0, z = -1}) end
|
||||||
|
|
||||||
|
local input_rules={}
|
||||||
|
if (a == 0) then table.insert(input_rules, {x = -1, y = 0, z = 0}) end
|
||||||
|
if (b == 0) then table.insert(input_rules, {x = 0, y = 0, z = 1}) end
|
||||||
|
if (c == 0) then table.insert(input_rules, {x = 1, y = 0, z = 0}) end
|
||||||
|
if (d == 0) then table.insert(input_rules, {x = 0, y = 0, z = -1}) end
|
||||||
|
mesecon:add_rules(nodename, rules)
|
||||||
|
|
||||||
|
local mesecons = {effector =
|
||||||
|
{
|
||||||
|
rules = input_rules,
|
||||||
|
action_change = function (pos, node)
|
||||||
|
update_yc(pos)
|
||||||
|
end
|
||||||
|
}}
|
||||||
|
if nodename ~= "mesecons_microcontroller:microcontroller0000" then
|
||||||
|
mesecons.receptor = {
|
||||||
|
state = mesecon.state.on,
|
||||||
|
rules = rules
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
minetest.register_node(nodename, {
|
minetest.register_node(nodename, {
|
||||||
description = "Microcontroller",
|
description = "Microcontroller",
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
@ -101,25 +128,12 @@ minetest.register_node(nodename, {
|
|||||||
yc_reset (pos)
|
yc_reset (pos)
|
||||||
update_yc(pos)
|
update_yc(pos)
|
||||||
end,
|
end,
|
||||||
|
mesecons = mesecons,
|
||||||
|
on_dig = function (pos, node)
|
||||||
|
rules = mesecon:get_rules(node.name)
|
||||||
|
mesecon:receptor_off(pos, rules)
|
||||||
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
local rules={}
|
|
||||||
if (a == 1) then table.insert(rules, {x = -1, y = 0, z = 0}) end
|
|
||||||
if (b == 1) then table.insert(rules, {x = 0, y = 0, z = 1}) end
|
|
||||||
if (c == 1) then table.insert(rules, {x = 1, y = 0, z = 0}) end
|
|
||||||
if (d == 1) then table.insert(rules, {x = 0, y = 0, z = -1}) end
|
|
||||||
|
|
||||||
local input_rules={}
|
|
||||||
if (a == 0) then table.insert(input_rules, {x = -1, y = 0, z = 0}) end
|
|
||||||
if (b == 0) then table.insert(input_rules, {x = 0, y = 0, z = 1}) end
|
|
||||||
if (c == 0) then table.insert(input_rules, {x = 1, y = 0, z = 0}) end
|
|
||||||
if (d == 0) then table.insert(input_rules, {x = 0, y = 0, z = -1}) end
|
|
||||||
mesecon:add_rules(nodename, rules)
|
|
||||||
|
|
||||||
mesecon:register_effector(nodename, nodename, input_rules)
|
|
||||||
if nodename ~= "mesecons_microcontroller:microcontroller0000" then
|
|
||||||
mesecon:add_receptor_node(nodename, rules)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -682,16 +696,3 @@ function yc_overheat_off(pos)
|
|||||||
rules = mesecon:get_rules("mesecons_microcontroller:microcontroller1111")
|
rules = mesecon:get_rules("mesecons_microcontroller:microcontroller1111")
|
||||||
mesecon:receptor_off(pos, rules)
|
mesecon:receptor_off(pos, rules)
|
||||||
end
|
end
|
||||||
|
|
||||||
mesecon:register_on_signal_change(function(pos, node)
|
|
||||||
if string.find(node.name, "mesecons_microcontroller:microcontroller")~=nil then
|
|
||||||
update_yc(pos)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
minetest.register_on_dignode(function(pos, node)
|
|
||||||
if string.find(node.name, "mesecons_microcontroller:microcontroller") then
|
|
||||||
rules = mesecon:get_rules(node.name)
|
|
||||||
mesecon:receptor_off(pos, rules)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
@ -1,10 +1,30 @@
|
|||||||
-- MOVESTONE
|
-- MOVESTONE
|
||||||
|
-- Non-sticky:
|
||||||
|
-- Moves along mesecon lines
|
||||||
|
-- Pushes all blocks in front of it
|
||||||
|
--
|
||||||
|
-- Sticky one
|
||||||
|
-- Moves along mesecon lines
|
||||||
|
-- Pushes all block in front of it
|
||||||
|
-- Pull all blocks in its back
|
||||||
|
|
||||||
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 = {
|
||||||
|
{x=0, y=1, 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=0, z=1},
|
||||||
|
{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=0, z=0}}
|
||||||
|
|
||||||
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
|
||||||
@ -41,8 +61,27 @@ minetest.register_node("mesecons_movestones:movestone", {
|
|||||||
legacy_facedir_simple = true,
|
legacy_facedir_simple = true,
|
||||||
groups = {cracky=3},
|
groups = {cracky=3},
|
||||||
description="Movestone",
|
description="Movestone",
|
||||||
|
mesecons = {effector = {
|
||||||
|
action_on = function (pos, node)
|
||||||
|
local direction=mesecon:get_movestone_direction(pos)
|
||||||
|
if not direction then return end
|
||||||
|
local checknode={}
|
||||||
|
local collpos={x=pos.x, y=pos.y, z=pos.z}
|
||||||
|
repeat -- Check if it collides with a stopper
|
||||||
|
collpos = addPosRule(collpos, direction)
|
||||||
|
checknode=minetest.env:get_node(collpos)
|
||||||
|
if mesecon:is_mvps_stopper(checknode.name) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
until checknode.name=="air"
|
||||||
|
or checknode.name=="ignore"
|
||||||
|
or not(minetest.registered_nodes[checknode.name].liquidtype == "none")
|
||||||
|
minetest.env:remove_node(pos)
|
||||||
|
mesecon:update_autoconnect(pos)
|
||||||
|
minetest.env:add_entity(pos, "mesecons_movestones:movestone_entity")
|
||||||
|
end
|
||||||
|
}}
|
||||||
})
|
})
|
||||||
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,
|
||||||
@ -50,10 +89,6 @@ minetest.register_entity("mesecons_movestones:movestone_entity", {
|
|||||||
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)
|
|
||||||
--self.object:setsprite({x=0,y=0}, 1, 0, true)
|
|
||||||
--self.object:setvelocity({x=-3, y=0, z=0})
|
|
||||||
--end,
|
|
||||||
|
|
||||||
on_punch = function(self, hitter)
|
on_punch = function(self, hitter)
|
||||||
self.object:remove()
|
self.object:remove()
|
||||||
@ -73,7 +108,7 @@ minetest.register_entity("mesecons_movestones:movestone_entity", {
|
|||||||
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({
|
||||||
@ -85,28 +120,6 @@ minetest.register_craft({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
mesecon:register_on_signal_on(function (pos, node)
|
|
||||||
if node.name=="mesecons_movestones:movestone" then
|
|
||||||
local direction=mesecon:get_movestone_direction(pos)
|
|
||||||
if not direction then return end
|
|
||||||
local checknode={}
|
|
||||||
local collpos={x=pos.x, y=pos.y, z=pos.z}
|
|
||||||
repeat -- Check if it collides with a stopper
|
|
||||||
collpos={x=collpos.x+direction.x, y=collpos.y+direction.y, z=collpos.z+direction.z}
|
|
||||||
checknode=minetest.env:get_node(collpos)
|
|
||||||
if mesecon:is_mvps_stopper(checknode.name) then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
until checknode.name=="air"
|
|
||||||
or checknode.name=="ignore"
|
|
||||||
or not(minetest.registered_nodes[checknode.name].liquidtype == "none")
|
|
||||||
minetest.env:remove_node(pos)
|
|
||||||
nodeupdate(pos)
|
|
||||||
minetest.env:add_entity(pos, "mesecons_movestones:movestone_entity")
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- STICKY_MOVESTONE
|
-- STICKY_MOVESTONE
|
||||||
@ -118,8 +131,36 @@ minetest.register_node("mesecons_movestones:sticky_movestone", {
|
|||||||
legacy_facedir_simple = true,
|
legacy_facedir_simple = true,
|
||||||
groups = {cracky=3},
|
groups = {cracky=3},
|
||||||
description="Sticky Movestone",
|
description="Sticky Movestone",
|
||||||
|
mesecons = {effector = {
|
||||||
|
action_on = function (pos, node)
|
||||||
|
local direction=mesecon:get_movestone_direction(pos)
|
||||||
|
if not direction then return end
|
||||||
|
local checknode={}
|
||||||
|
local collpos={x=pos.x, y=pos.y, z=pos.z}
|
||||||
|
repeat -- Check if it collides with a stopper
|
||||||
|
collpos = addPosRule(collpos, direction)
|
||||||
|
checknode=minetest.env:get_node(collpos)
|
||||||
|
if mesecon:is_mvps_stopper(checknode.name) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
until checknode.name=="air"
|
||||||
|
or checknode.name=="ignore"
|
||||||
|
or not(minetest.registered_nodes[checknode.name].liquidtype == "none")
|
||||||
|
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}
|
||||||
|
checknode=minetest.env:get_node(collpos)
|
||||||
|
if mesecon:is_mvps_stopper(checknode.name) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
until checknode.name=="air"
|
||||||
|
or checknode.name=="ignore"
|
||||||
|
or not(minetest.registered_nodes[checknode.name].liquidtype == "none")
|
||||||
|
minetest.env:remove_node(pos)
|
||||||
|
mesecon:update_autoconnect(pos)
|
||||||
|
minetest.env:add_entity(pos, "mesecons_movestones:sticky_movestone_entity")
|
||||||
|
end
|
||||||
|
}}
|
||||||
})
|
})
|
||||||
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',
|
||||||
@ -146,8 +187,6 @@ minetest.register_entity("mesecons_movestones:sticky_movestone_entity", {
|
|||||||
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"
|
|
||||||
--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
|
||||||
@ -159,49 +198,5 @@ minetest.register_entity("mesecons_movestones:sticky_movestone_entity", {
|
|||||||
|
|
||||||
--STICKY
|
--STICKY
|
||||||
mesecon:mvps_pull_all(pos, direction)
|
mesecon:mvps_pull_all(pos, direction)
|
||||||
end
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
mesecon:register_on_signal_on(function (pos, node)
|
|
||||||
if node.name=="mesecons_movestones:sticky_movestone" then
|
|
||||||
local direction=mesecon:get_movestone_direction(pos)
|
|
||||||
if not direction then return end
|
|
||||||
local checknode={}
|
|
||||||
local collpos={x=pos.x, y=pos.y, z=pos.z}
|
|
||||||
repeat -- Check if it collides with a stopper
|
|
||||||
collpos={x=collpos.x+direction.x, y=collpos.y+direction.y, z=collpos.z+direction.z}
|
|
||||||
checknode=minetest.env:get_node(collpos)
|
|
||||||
if mesecon:is_mvps_stopper(checknode.name) then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
until checknode.name=="air"
|
|
||||||
or checknode.name=="ignore"
|
|
||||||
or not(minetest.registered_nodes[checknode.name].liquidtype == "none")
|
|
||||||
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}
|
|
||||||
checknode=minetest.env:get_node(collpos)
|
|
||||||
if mesecon:is_mvps_stopper(checknode.name) then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
until checknode.name=="air"
|
|
||||||
or checknode.name=="ignore"
|
|
||||||
or not(minetest.registered_nodes[checknode.name].liquidtype == "none")
|
|
||||||
minetest.env:remove_node(pos)
|
|
||||||
nodeupdate(pos)
|
|
||||||
minetest.env:add_entity(pos, "mesecons_movestones:sticky_movestone_entity")
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
mesecon:add_rules("movestone", {
|
|
||||||
{x=0, y=1, 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=0, z=1},
|
|
||||||
{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=0, z=0}})
|
|
||||||
|
@ -1,15 +1,25 @@
|
|||||||
minetest.register_node("mesecons_noteblock:noteblock", {
|
minetest.register_node("mesecons_noteblock:noteblock", {
|
||||||
description = "Noteblock",
|
description = "Noteblock",
|
||||||
tiles = {"mesecons_noteblock.png"},
|
tiles = {"mesecons_noteblock.png"},
|
||||||
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon = 2},
|
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
|
||||||
drawtype = "allfaces_optional",
|
drawtype = "allfaces_optional",
|
||||||
visual_scale = 1.3,
|
visual_scale = 1.3,
|
||||||
paramtype="light",
|
paramtype="light",
|
||||||
after_place_node = function(pos)
|
after_place_node = function(pos)
|
||||||
minetest.env:add_node(pos, {name="mesecons_noteblock:noteblock", param2=0})
|
minetest.env:add_node(pos, {name="mesecons_noteblock:noteblock", param2=0})
|
||||||
|
end,
|
||||||
|
on_punch = function (pos, node) -- change sound when punched
|
||||||
|
local param2 = node.param2+1
|
||||||
|
if param2==12 then param2=0 end
|
||||||
|
minetest.env:add_node(pos, {name = node.name, param2 = param2})
|
||||||
|
mesecon.noteblock_play(pos, param2)
|
||||||
|
end,
|
||||||
|
mesecons = {effector = { -- play sound when activated
|
||||||
|
action_on = function (pos, node)
|
||||||
|
mesecon.noteblock_play(pos, node.param2)
|
||||||
end
|
end
|
||||||
|
}}
|
||||||
})
|
})
|
||||||
mesecon:register_effector("mesecons_noteblock:noteblock", "mesecons_noteblock:noteblock")
|
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = '"mesecons_noteblock:noteblock" 1',
|
output = '"mesecons_noteblock:noteblock" 1',
|
||||||
@ -20,15 +30,6 @@ minetest.register_craft({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_on_punchnode(function (pos, node)
|
|
||||||
if node.name=="mesecons_noteblock:noteblock" then
|
|
||||||
local param2 = node.param2+1
|
|
||||||
if param2==12 then param2=0 end
|
|
||||||
minetest.env:add_node(pos, {name=node.name, param2=param2})
|
|
||||||
mesecon.noteblock_play(pos, param2)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
mesecon.noteblock_play = function (pos, param2)
|
mesecon.noteblock_play = function (pos, param2)
|
||||||
local soundname
|
local soundname
|
||||||
if param2==8 then
|
if param2==8 then
|
||||||
@ -75,9 +76,3 @@ mesecon.noteblock_play = function (pos, param2)
|
|||||||
minetest.sound_play(soundname,
|
minetest.sound_play(soundname,
|
||||||
{pos = pos, gain = 1.0, max_hear_distance = 32,})
|
{pos = pos, gain = 1.0, max_hear_distance = 32,})
|
||||||
end
|
end
|
||||||
|
|
||||||
mesecon:register_on_signal_on(function(pos, node)
|
|
||||||
if node.name=="mesecons_noteblock:noteblock" then
|
|
||||||
mesecon.noteblock_play(pos, node.param2)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
@ -1,5 +1,11 @@
|
|||||||
--PISTONS
|
--PISTONS
|
||||||
|
|
||||||
|
local update = function(pos, node)
|
||||||
|
local timer = minetest.env:get_node_timer(pos)
|
||||||
|
timer:stop()
|
||||||
|
timer:start(0)
|
||||||
|
end
|
||||||
|
|
||||||
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"},
|
||||||
@ -25,8 +31,10 @@ minetest.register_node("mesecons_pistons:piston_normal", {
|
|||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end,
|
end,
|
||||||
|
mesecons = {effector={
|
||||||
|
action_change = update
|
||||||
|
}}
|
||||||
})
|
})
|
||||||
mesecon:register_effector("mesecons_pistons:piston_normal", "mesecons_pistons:piston_normal")
|
|
||||||
|
|
||||||
minetest.register_node("mesecons_pistons:piston_sticky", {
|
minetest.register_node("mesecons_pistons:piston_sticky", {
|
||||||
description = "Sticky Piston",
|
description = "Sticky Piston",
|
||||||
@ -53,8 +61,10 @@ minetest.register_node("mesecons_pistons:piston_sticky", {
|
|||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end,
|
end,
|
||||||
|
mesecons = {effector={
|
||||||
|
action_change = update
|
||||||
|
}}
|
||||||
})
|
})
|
||||||
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',
|
||||||
@ -127,18 +137,6 @@ minetest.register_node("mesecons_pistons:piston_pusher_sticky", {
|
|||||||
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")
|
||||||
|
|
||||||
local update = function(pos, node)
|
|
||||||
if node.name ~= "mesecons_pistons:piston_normal" and node.name ~= "mesecons_pistons:piston_sticky" then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local timer = minetest.env:get_node_timer(pos)
|
|
||||||
timer:stop()
|
|
||||||
timer:start(0)
|
|
||||||
end
|
|
||||||
mesecon:register_on_signal_on(update) --push action
|
|
||||||
mesecon:register_on_signal_off(update) --pull action
|
|
||||||
|
|
||||||
function mesecon:piston_push(pos)
|
function mesecon:piston_push(pos)
|
||||||
local node = minetest.env:get_node(pos)
|
local node = minetest.env:get_node(pos)
|
||||||
local dir = mesecon:piston_get_direction(node)
|
local dir = mesecon:piston_get_direction(node)
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
-- The POWER_PLANT
|
-- The POWER_PLANT
|
||||||
|
-- Just emits power. always.
|
||||||
|
|
||||||
minetest.register_node("mesecons_powerplant:power_plant", {
|
minetest.register_node("mesecons_powerplant:power_plant", {
|
||||||
drawtype = "plantlike",
|
drawtype = "plantlike",
|
||||||
@ -14,6 +15,9 @@ minetest.register_node("mesecons_powerplant:power_plant", {
|
|||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = {-0.1, -0.5, -0.1, 0.1, -0.5+0.6, 0.1},
|
fixed = {-0.1, -0.5, -0.1, 0.1, -0.5+0.6, 0.1},
|
||||||
},
|
},
|
||||||
|
mesecons = {receptor = {
|
||||||
|
state = mesecon.state.on
|
||||||
|
}}
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
@ -24,5 +28,3 @@ minetest.register_craft({
|
|||||||
{'"default:sapling"'},
|
{'"default:sapling"'},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
mesecon:add_receptor_node("mesecons_powerplant:power_plant")
|
|
||||||
|
@ -25,7 +25,7 @@ minetest.register_node("mesecons_pressureplates:pressure_plate_wood_off", {
|
|||||||
local objpos=obj:getpos()
|
local objpos=obj:getpos()
|
||||||
if objpos.y>pos.y-1 and objpos.y<pos.y then
|
if objpos.y>pos.y-1 and objpos.y<pos.y then
|
||||||
minetest.env:add_node(pos, {name="mesecons_pressureplates:pressure_plate_wood_on"})
|
minetest.env:add_node(pos, {name="mesecons_pressureplates:pressure_plate_wood_on"})
|
||||||
mesecon:receptor_on(pos, mesecon:get_rules("pressureplate"))
|
mesecon:receptor_on(pos)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
@ -57,7 +57,7 @@ minetest.register_node("mesecons_pressureplates:pressure_plate_wood_on", {
|
|||||||
local objs = minetest.env:get_objects_inside_radius(pos, 1)
|
local objs = minetest.env:get_objects_inside_radius(pos, 1)
|
||||||
if objs[1]==nil then
|
if objs[1]==nil then
|
||||||
minetest.env:add_node(pos, {name="mesecons_pressureplates:pressure_plate_wood_off"})
|
minetest.env:add_node(pos, {name="mesecons_pressureplates:pressure_plate_wood_off"})
|
||||||
mesecon:receptor_off(pos, mesecon:get_rules("pressureplate"))
|
mesecon:receptor_off(pos)
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
end,
|
end,
|
||||||
@ -92,7 +92,7 @@ minetest.register_node("mesecons_pressureplates:pressure_plate_stone_off", {
|
|||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = { -7/16, -8/16, -7/16, 7/16, -7/16, 7/16 },
|
fixed = { -7/16, -8/16, -7/16, 7/16, -7/16, 7/16 },
|
||||||
},
|
},
|
||||||
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=3, mesecon = 2},
|
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=3},
|
||||||
description="Stone Pressure Plate",
|
description="Stone Pressure Plate",
|
||||||
|
|
||||||
on_timer = function(pos, elapsed)
|
on_timer = function(pos, elapsed)
|
||||||
@ -101,7 +101,7 @@ minetest.register_node("mesecons_pressureplates:pressure_plate_stone_off", {
|
|||||||
local objpos=obj:getpos()
|
local objpos=obj:getpos()
|
||||||
if objpos.y>pos.y-1 and objpos.y<pos.y then
|
if objpos.y>pos.y-1 and objpos.y<pos.y then
|
||||||
minetest.env:add_node(pos, {name="mesecons_pressureplates:pressure_plate_stone_on"})
|
minetest.env:add_node(pos, {name="mesecons_pressureplates:pressure_plate_stone_on"})
|
||||||
mesecon:receptor_on(pos, mesecon:get_rules("pressureplate"))
|
mesecon:receptor_on(pos)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
@ -110,6 +110,10 @@ minetest.register_node("mesecons_pressureplates:pressure_plate_stone_off", {
|
|||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
minetest.env:get_node_timer(pos):start(PRESSURE_PLATE_INTERVAL)
|
minetest.env:get_node_timer(pos):start(PRESSURE_PLATE_INTERVAL)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
mesecons = {receptor = {
|
||||||
|
state = mesecon.state.off
|
||||||
|
}}
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node("mesecons_pressureplates:pressure_plate_stone_on", {
|
minetest.register_node("mesecons_pressureplates:pressure_plate_stone_on", {
|
||||||
@ -126,14 +130,14 @@ minetest.register_node("mesecons_pressureplates:pressure_plate_stone_on", {
|
|||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = { -7/16, -8/16, -7/16, 7/16, -31/64, 7/16 },
|
fixed = { -7/16, -8/16, -7/16, 7/16, -31/64, 7/16 },
|
||||||
},
|
},
|
||||||
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=3,not_in_creative_inventory=1, mesecon = 2},
|
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=3,not_in_creative_inventory=1},
|
||||||
drop='"mesecons_pressureplates:pressure_plate_stone_off" 1',
|
drop='"mesecons_pressureplates:pressure_plate_stone_off" 1',
|
||||||
|
|
||||||
on_timer = function(pos, elapsed)
|
on_timer = function(pos, elapsed)
|
||||||
local objs = minetest.env:get_objects_inside_radius(pos, 1)
|
local objs = minetest.env:get_objects_inside_radius(pos, 1)
|
||||||
if objs[1]==nil then
|
if objs[1]==nil then
|
||||||
minetest.env:add_node(pos, {name="mesecons_pressureplates:pressure_plate_stone_off"})
|
minetest.env:add_node(pos, {name="mesecons_pressureplates:pressure_plate_stone_off"})
|
||||||
mesecon:receptor_off(pos, mesecon:get_rules("pressureplate"))
|
mesecon:receptor_off(pos)
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
end,
|
end,
|
||||||
@ -141,6 +145,10 @@ minetest.register_node("mesecons_pressureplates:pressure_plate_stone_on", {
|
|||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
minetest.env:get_node_timer(pos):start(PRESSURE_PLATE_INTERVAL)
|
minetest.env:get_node_timer(pos):start(PRESSURE_PLATE_INTERVAL)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
mesecons = {receptor = {
|
||||||
|
state = mesecon.state.off
|
||||||
|
}}
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
@ -149,9 +157,3 @@ minetest.register_craft({
|
|||||||
{'"default:cobble"', '"default:cobble"'},
|
{'"default:cobble"', '"default:cobble"'},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
mesecon:add_receptor_node("mesecons_pressureplates:pressure_plate_wood_on", mesecon:get_rules("pressureplate"))
|
|
||||||
mesecon:add_receptor_node_off("mesecons_pressureplates:pressure_plate_wood_off", mesecon:get_rules("pressureplate"))
|
|
||||||
|
|
||||||
mesecon:add_receptor_node("mesecons_pressureplates:pressure_plate_stone_on", mesecon:get_rules("pressureplate"))
|
|
||||||
mesecon:add_receptor_node_off("mesecons_pressureplates:pressure_plate_stone_off", mesecon:get_rules("pressureplate"))
|
|
||||||
|
@ -3,12 +3,16 @@
|
|||||||
minetest.register_node("mesecons_random:removestone", {
|
minetest.register_node("mesecons_random:removestone", {
|
||||||
tiles = {"jeija_removestone.png"},
|
tiles = {"jeija_removestone.png"},
|
||||||
inventory_image = minetest.inventorycube("jeija_removestone_inv.png"),
|
inventory_image = minetest.inventorycube("jeija_removestone_inv.png"),
|
||||||
groups = {cracky=3, mesecon=2},
|
groups = {cracky=3},
|
||||||
description="Removestone",
|
description="Removestone",
|
||||||
|
mesecons = {effector = {
|
||||||
|
action_on = function (pos, node)
|
||||||
|
minetest.env:remove_node(pos)
|
||||||
|
mesecon:update_autoconnect(pos)
|
||||||
|
end
|
||||||
|
}}
|
||||||
})
|
})
|
||||||
|
|
||||||
mesecon:register_effector(nil, "mesecons_random:removestone")
|
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = 'mesecons_random:removestone 4',
|
output = 'mesecons_random:removestone 4',
|
||||||
recipe = {
|
recipe = {
|
||||||
@ -18,12 +22,6 @@ minetest.register_craft({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
mesecon:register_on_signal_on(function(pos, node)
|
|
||||||
if node.name == "mesecons_random:removestone" then
|
|
||||||
minetest.env:remove_node(pos)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
-- GHOSTSTONE
|
-- GHOSTSTONE
|
||||||
|
|
||||||
minetest.register_node("mesecons_random:ghoststone", {
|
minetest.register_node("mesecons_random:ghoststone", {
|
||||||
@ -31,8 +29,13 @@ minetest.register_node("mesecons_random:ghoststone", {
|
|||||||
tiles = {"jeija_ghoststone.png"},
|
tiles = {"jeija_ghoststone.png"},
|
||||||
is_ground_content = true,
|
is_ground_content = true,
|
||||||
inventory_image = minetest.inventorycube("jeija_ghoststone_inv.png"),
|
inventory_image = minetest.inventorycube("jeija_ghoststone_inv.png"),
|
||||||
groups = {cracky=3, mesecon=2},
|
groups = {cracky=3},
|
||||||
sounds = default.node_sound_stone_defaults(),
|
sounds = default.node_sound_stone_defaults(),
|
||||||
|
mesecons = {effector = {
|
||||||
|
action_on = function (pos, node)
|
||||||
|
minetest.env:add_node(pos, {name="mesecons_random:ghoststone_active"})
|
||||||
|
end
|
||||||
|
}}
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node("mesecons_random:ghoststone_active", {
|
minetest.register_node("mesecons_random:ghoststone_active", {
|
||||||
@ -41,10 +44,13 @@ minetest.register_node("mesecons_random:ghoststone_active", {
|
|||||||
walkable = false,
|
walkable = false,
|
||||||
diggable = false,
|
diggable = false,
|
||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
groups = {mesecon=2},
|
mesecons = {effector = {
|
||||||
|
action_off = function (pos, node)
|
||||||
|
minetest.env:add_node(pos, {name="mesecons_random:ghoststone"})
|
||||||
|
end
|
||||||
|
}}
|
||||||
})
|
})
|
||||||
|
|
||||||
mesecon:register_effector("mesecons_random:ghoststone_active", "mesecons_random:ghoststone")
|
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = 'mesecons_random:ghoststone 4',
|
output = 'mesecons_random:ghoststone 4',
|
||||||
@ -54,17 +60,3 @@ minetest.register_craft({
|
|||||||
{"default:steel_ingot", "default:cobble", "default:steel_ingot"},
|
{"default:steel_ingot", "default:cobble", "default:steel_ingot"},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
mesecon:register_on_signal_on(function(pos, node)
|
|
||||||
if node.name == "mesecons_random:ghoststone" then
|
|
||||||
minetest.env:add_node(pos, {name="mesecons_random:ghoststone_active"})
|
|
||||||
nodeupdate(pos)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
mesecon:register_on_signal_off(function(pos, node)
|
|
||||||
if node.name == "mesecons_random:ghoststone_active" then
|
|
||||||
minetest.env:add_node(pos, {name="mesecons_random:ghoststone"})
|
|
||||||
nodeupdate(pos)
|
|
||||||
end
|
|
||||||
end)
|
|
@ -5,6 +5,19 @@ rcvboxes = {
|
|||||||
{ -3/32, -17/32 , -7/16+0.002 , 3/32, -13/32, 16/32+0.001 } -- the horizontal wire
|
{ -3/32, -17/32 , -7/16+0.002 , 3/32, -13/32, 16/32+0.001 } -- the horizontal wire
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local receiver_get_rules = function (node)
|
||||||
|
local rules = { {x = 1, y = 0, z = 0},
|
||||||
|
{x = -2, y = 0, z = 0}}
|
||||||
|
if node.param2 == 2 then
|
||||||
|
rules = mesecon:rotate_rules_left(rules)
|
||||||
|
elseif node.param2 == 3 then
|
||||||
|
rules = mesecon:rotate_rules_right(mesecon:rotate_rules_right(rules))
|
||||||
|
elseif node.param2 == 0 then
|
||||||
|
rules = mesecon:rotate_rules_right(rules)
|
||||||
|
end
|
||||||
|
return rules
|
||||||
|
end
|
||||||
|
|
||||||
minetest.register_node("mesecons_receiver:receiver_on", {
|
minetest.register_node("mesecons_receiver:receiver_on", {
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
tiles = {
|
tiles = {
|
||||||
@ -26,9 +39,13 @@ minetest.register_node("mesecons_receiver:receiver_on", {
|
|||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = rcvboxes
|
fixed = rcvboxes
|
||||||
},
|
},
|
||||||
groups = {dig_immediate = 3, mesecon = 3, not_in_creative_inventory = 1},
|
groups = {dig_immediate = 3, not_in_creative_inventory = 1},
|
||||||
drop = "mesecons:wire_00000000_off",
|
drop = "mesecons:wire_00000000_off",
|
||||||
|
mesecons = {conductor = {
|
||||||
|
state = mesecon.state.on,
|
||||||
|
rules = receiver_get_rules,
|
||||||
|
offstate = "mesecons_receiver:receiver_off"
|
||||||
|
}}
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node("mesecons_receiver:receiver_off", {
|
minetest.register_node("mesecons_receiver:receiver_off", {
|
||||||
@ -53,8 +70,13 @@ minetest.register_node("mesecons_receiver:receiver_off", {
|
|||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = rcvboxes
|
fixed = rcvboxes
|
||||||
},
|
},
|
||||||
groups = {dig_immediate = 3, mesecon = 3, not_in_creative_inventory = 1},
|
groups = {dig_immediate = 3, not_in_creative_inventory = 1},
|
||||||
drop = "mesecons:wire_00000000_off",
|
drop = "mesecons:wire_00000000_off",
|
||||||
|
mesecons = {conductor = {
|
||||||
|
state = mesecon.state.off,
|
||||||
|
rules = receiver_get_rules,
|
||||||
|
onstate = "mesecons_receiver:receiver_on"
|
||||||
|
}}
|
||||||
})
|
})
|
||||||
|
|
||||||
mesecon:add_rules("receiver_pos", {{x = 2, y = 0, z = 0}})
|
mesecon:add_rules("receiver_pos", {{x = 2, y = 0, z = 0}})
|
||||||
@ -65,34 +87,6 @@ mesecon:add_rules("receiver_pos_all", {
|
|||||||
{x = 0, y = 0, z = 2},
|
{x = 0, y = 0, z = 2},
|
||||||
{x = 0, y = 0, z =-2}})
|
{x = 0, y = 0, z =-2}})
|
||||||
|
|
||||||
mesecon:add_rules("mesecon_receiver", {
|
|
||||||
{x = 1, y = 0, z = 0},
|
|
||||||
{x = -2, y = 0, z = 0},})
|
|
||||||
|
|
||||||
mesecon:add_rules("mesecon_receiver_all", {
|
|
||||||
{x = 1, y = 0, z = 0},
|
|
||||||
{x =-2, y = 0, z = 0},
|
|
||||||
{x =-1, y = 0, z = 0},
|
|
||||||
{x = 2, y = 0, z = 0},
|
|
||||||
{x = 0, y = 0, z = 1},
|
|
||||||
{x = 0, y = 0, z =-2},
|
|
||||||
{x = 1, y = 0, z =-1},
|
|
||||||
{x =-2, y = 0, z = 2},})
|
|
||||||
|
|
||||||
function receiver_get_rules(param2)
|
|
||||||
local rules = mesecon:get_rules("mesecon_receiver")
|
|
||||||
if param2 == 2 then
|
|
||||||
rules = mesecon:rotate_rules_left(rules)
|
|
||||||
elseif param2 == 3 then
|
|
||||||
rules = mesecon:rotate_rules_right(mesecon:rotate_rules_right(rules))
|
|
||||||
elseif param2 == 0 then
|
|
||||||
rules = mesecon:rotate_rules_right(rules)
|
|
||||||
end
|
|
||||||
return rules
|
|
||||||
end
|
|
||||||
|
|
||||||
mesecon:register_conductor("mesecons_receiver:receiver_on", "mesecons_receiver:receiver_off", mesecon:get_rules("mesecon_receiver_all"), receiver_get_rules)
|
|
||||||
|
|
||||||
function mesecon:receiver_get_pos_from_rcpt(pos, param2)
|
function mesecon:receiver_get_pos_from_rcpt(pos, param2)
|
||||||
local rules = mesecon:get_rules("receiver_pos")
|
local rules = mesecon:get_rules("receiver_pos")
|
||||||
if param2 == nil then param2 = minetest.env:get_node(pos).param2 end
|
if param2 == nil then param2 = minetest.env:get_node(pos).param2 end
|
||||||
|
@ -21,8 +21,10 @@ minetest.register_node("mesecons_solarpanel:solar_panel_on", {
|
|||||||
wall_side = { -8/16, -7/16, -7/16, -7/16, 7/16, 7/16 },
|
wall_side = { -8/16, -7/16, -7/16, -7/16, 7/16, 7/16 },
|
||||||
},
|
},
|
||||||
drop = "mesecons_solarpanel:solar_panel_off",
|
drop = "mesecons_solarpanel:solar_panel_off",
|
||||||
groups = {dig_immediate=3, mesecon = 2, not_in_creative_inventory = 1},
|
groups = {dig_immediate=3, not_in_creative_inventory = 1},
|
||||||
description="Solar Panel",
|
mesecons = {receptor = {
|
||||||
|
state = mesecon.state.on
|
||||||
|
}}
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Solar Panel
|
-- Solar Panel
|
||||||
@ -47,8 +49,11 @@ minetest.register_node("mesecons_solarpanel:solar_panel_off", {
|
|||||||
wall_top = { -7/16, 7/16, -7/16, 7/16, 8/16, 7/16 },
|
wall_top = { -7/16, 7/16, -7/16, 7/16, 8/16, 7/16 },
|
||||||
wall_side = { -8/16, -7/16, -7/16, -7/16, 7/16, 7/16 },
|
wall_side = { -8/16, -7/16, -7/16, -7/16, 7/16, 7/16 },
|
||||||
},
|
},
|
||||||
groups = {dig_immediate=3, mesecon = 2},
|
groups = {dig_immediate=3},
|
||||||
description="Solar Panel",
|
description="Solar Panel",
|
||||||
|
mesecons = {receptor = {
|
||||||
|
state = mesecon.state.off
|
||||||
|
}}
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
@ -86,6 +91,3 @@ minetest.register_abm(
|
|||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
mesecon:add_receptor_node("mesecons_solarpanel:solar_panel_on")
|
|
||||||
mesecon:add_receptor_node_off("mesecons_solarpanel:solar_panel_off")
|
|
||||||
|
@ -1,5 +1,45 @@
|
|||||||
--MESECON TORCHES
|
--MESECON TORCHES
|
||||||
|
|
||||||
|
local torch_get_rules = function(node)
|
||||||
|
local rules = {
|
||||||
|
{x=1, y=0, z=0},
|
||||||
|
{x=0, y=0, z=1},
|
||||||
|
{x=0, y=0, z=-1},
|
||||||
|
{x=0, y=1, z=0},
|
||||||
|
{x=0, y=-1, z=0}}
|
||||||
|
if node.param2 == 5 then
|
||||||
|
rules=mesecon:rotate_rules_right(rules)
|
||||||
|
elseif node.param2 == 2 then
|
||||||
|
rules=mesecon:rotate_rules_right(mesecon:rotate_rules_right(rules)) --180 degrees
|
||||||
|
elseif node.param2 == 4 then
|
||||||
|
rules=mesecon:rotate_rules_left(rules)
|
||||||
|
elseif node.param2 == 1 then
|
||||||
|
rules=mesecon:rotate_rules_down(rules)
|
||||||
|
elseif node.param2 == 0 then
|
||||||
|
rules=mesecon:rotate_rules_up(rules)
|
||||||
|
end
|
||||||
|
return rules
|
||||||
|
end
|
||||||
|
|
||||||
|
local torch_get_input_rules = function(node)
|
||||||
|
local rules = {x=0, y=0, z=0}
|
||||||
|
|
||||||
|
if node.param2 == 4 then
|
||||||
|
rules.z = -2
|
||||||
|
elseif node.param2 == 2 then
|
||||||
|
rules.x = -2
|
||||||
|
elseif node.param2 == 5 then
|
||||||
|
rules.z = 2
|
||||||
|
elseif node.param2 == 3 then
|
||||||
|
rules.x = 2
|
||||||
|
elseif node.param2 == 1 then
|
||||||
|
rules.y = 2
|
||||||
|
elseif node.param2 == 0 then
|
||||||
|
rules.y = -2
|
||||||
|
end
|
||||||
|
return rules
|
||||||
|
end
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = '"mesecons_torch:mesecon_torch_on" 4',
|
output = '"mesecons_torch:mesecon_torch_on" 4',
|
||||||
recipe = {
|
recipe = {
|
||||||
@ -22,9 +62,13 @@ minetest.register_node("mesecons_torch:mesecon_torch_off", {
|
|||||||
wall_side = {-0.5, -0.1, -0.1, -0.5+0.6, 0.1, 0.1},
|
wall_side = {-0.5, -0.1, -0.1, -0.5+0.6, 0.1, 0.1},
|
||||||
},
|
},
|
||||||
legacy_wallmounted = true,
|
legacy_wallmounted = true,
|
||||||
groups = {dig_immediate=3,not_in_creative_inventory=1, mesecon = 2},
|
groups = {dig_immediate=3,not_in_creative_inventory=1},
|
||||||
drop = '"mesecons_torch:mesecon_torch_on" 1',
|
drop = '"mesecons_torch:mesecon_torch_on" 1',
|
||||||
description="Mesecon Torch",
|
description="Mesecon Torch",
|
||||||
|
mesecons = {receptor = {
|
||||||
|
state = mesecon.state.off,
|
||||||
|
rules = torch_get_rules
|
||||||
|
}}
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node("mesecons_torch:mesecon_torch_on", {
|
minetest.register_node("mesecons_torch:mesecon_torch_on", {
|
||||||
@ -43,9 +87,13 @@ minetest.register_node("mesecons_torch:mesecon_torch_on", {
|
|||||||
wall_side = {-0.5, -0.1, -0.1, -0.5+0.6, 0.1, 0.1},
|
wall_side = {-0.5, -0.1, -0.1, -0.5+0.6, 0.1, 0.1},
|
||||||
},
|
},
|
||||||
legacy_wallmounted = true,
|
legacy_wallmounted = true,
|
||||||
groups = {dig_immediate=3, mesecon = 2},
|
groups = {dig_immediate=3},
|
||||||
light_source = LIGHT_MAX-5,
|
light_source = LIGHT_MAX-5,
|
||||||
description="Mesecon Torch",
|
description="Mesecon Torch",
|
||||||
|
mesecons = {receptor = {
|
||||||
|
state = mesecon.state.on,
|
||||||
|
rules = torch_get_rules
|
||||||
|
}}
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
@ -53,70 +101,24 @@ minetest.register_abm({
|
|||||||
interval = 1,
|
interval = 1,
|
||||||
chance = 1,
|
chance = 1,
|
||||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||||
local rules=mesecon.torch_get_rules(minetest.env:get_node(pos).param2)
|
local node = minetest.env:get_node(pos)
|
||||||
local pa = mesecon.torch_get_input_rules(node.param2)
|
local pa = torch_get_input_rules(node)
|
||||||
|
|
||||||
local postc = {x=pos.x-pa.x, y=pos.y-pa.y, z=pos.z-pa.z}
|
local postc = {x=pos.x-pa.x, y=pos.y-pa.y, z=pos.z-pa.z}
|
||||||
if mesecon:is_power_on(postc) then
|
if mesecon:is_power_on(postc) then
|
||||||
if node.name ~= "mesecons_torch:mesecon_torch_off" then
|
if node.name ~= "mesecons_torch:mesecon_torch_off" then
|
||||||
minetest.env:add_node(pos, {name="mesecons_torch:mesecon_torch_off",param2=node.param2})
|
minetest.env:add_node(pos, {name="mesecons_torch:mesecon_torch_off",param2=node.param2})
|
||||||
mesecon:receptor_off(pos, rules_string)
|
mesecon:receptor_off(pos, torch_get_rules(node))
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if node.name ~= "mesecons_torch:mesecon_torch_on" then
|
if node.name ~= "mesecons_torch:mesecon_torch_on" then
|
||||||
minetest.env:add_node(pos, {name="mesecons_torch:mesecon_torch_on",param2=node.param2})
|
minetest.env:add_node(pos, {name="mesecons_torch:mesecon_torch_on",param2=node.param2})
|
||||||
mesecon:receptor_on(pos, rules_string)
|
mesecon:receptor_on(pos, torch_get_rules(node))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
mesecon.torch_get_rules = function(param2)
|
|
||||||
local rules=mesecon:get_rules("mesecontorch")
|
|
||||||
if param2 == 5 then
|
|
||||||
rules=mesecon:rotate_rules_right(rules)
|
|
||||||
elseif param2 == 2 then
|
|
||||||
rules=mesecon:rotate_rules_right(mesecon:rotate_rules_right(rules)) --180 degrees
|
|
||||||
elseif param2 == 4 then
|
|
||||||
rules=mesecon:rotate_rules_left(rules)
|
|
||||||
elseif param2 == 1 then
|
|
||||||
rules=mesecon:rotate_rules_down(rules)
|
|
||||||
elseif param2 == 0 then
|
|
||||||
rules=mesecon:rotate_rules_up(rules)
|
|
||||||
end
|
|
||||||
return rules
|
|
||||||
end
|
|
||||||
|
|
||||||
mesecon.torch_get_input_rules = function(param2)
|
|
||||||
local rules = {x=0, y=0, z=0}
|
|
||||||
|
|
||||||
if param2 == 4 then
|
|
||||||
rules.z = -2
|
|
||||||
elseif param2 == 2 then
|
|
||||||
rules.x = -2
|
|
||||||
elseif param2 == 5 then
|
|
||||||
rules.z = 2
|
|
||||||
elseif param2 == 3 then
|
|
||||||
rules.x = 2
|
|
||||||
elseif param2 == 1 then
|
|
||||||
rules.y = 2
|
|
||||||
elseif param2 == 0 then
|
|
||||||
rules.y = -2
|
|
||||||
end
|
|
||||||
return rules
|
|
||||||
end
|
|
||||||
|
|
||||||
mesecon:add_rules("mesecontorch",
|
|
||||||
{{x=1, y=0, z=0},
|
|
||||||
{x=0, y=0, z=1},
|
|
||||||
{x=0, y=0, z=-1},
|
|
||||||
{x=0, y=1, z=0},
|
|
||||||
{x=0, y=-1, z=0}})
|
|
||||||
|
|
||||||
mesecon:add_receptor_node("mesecons_torch:mesecon_torch_on", nil, mesecon.torch_get_rules)
|
|
||||||
mesecon:add_receptor_node_off("mesecons_torch:mesecon_torch_off", nil, mesecon.torch_get_rules)
|
|
||||||
mesecon:register_effector("mesecons_torch:mesecon_torch_on","mesecons_torch:mesecon_torch_off", nil, mesecon.torch_get_input_rules)
|
|
||||||
|
|
||||||
-- Param2 Table (Block Attached To)
|
-- Param2 Table (Block Attached To)
|
||||||
-- 5 = z-1
|
-- 5 = z-1
|
||||||
-- 3 = x-1
|
-- 3 = x-1
|
||||||
|
@ -1,4 +1,22 @@
|
|||||||
-- WALL LEVER
|
-- WALL LEVER
|
||||||
|
local walllever_get_rules = function(node)
|
||||||
|
local rules = {
|
||||||
|
{x = 1, y = 0, z = 0},
|
||||||
|
{x = 1, y = 1, z = 0},
|
||||||
|
{x = 1, y =-1, z = 0},
|
||||||
|
{x = 1, y =-1, z = 1},
|
||||||
|
{x = 1, y =-1, z =-1},
|
||||||
|
{x = 2, y = 0, z = 0}}
|
||||||
|
if node.param2 == 2 then
|
||||||
|
rules=mesecon:rotate_rules_left(rules)
|
||||||
|
elseif node.param2 == 3 then
|
||||||
|
rules=mesecon:rotate_rules_right(mesecon:rotate_rules_right(rules))
|
||||||
|
elseif node.param2 == 0 then
|
||||||
|
rules=mesecon:rotate_rules_right(rules)
|
||||||
|
end
|
||||||
|
return rules
|
||||||
|
end
|
||||||
|
|
||||||
minetest.register_node("mesecons_walllever:wall_lever_off", {
|
minetest.register_node("mesecons_walllever:wall_lever_off", {
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
tiles = {
|
tiles = {
|
||||||
@ -27,8 +45,16 @@ minetest.register_node("mesecons_walllever:wall_lever_off", {
|
|||||||
{ -2/16, -1/16, 3/16, 2/16, 1/16, 4/16 }, -- the lever "hinge"
|
{ -2/16, -1/16, 3/16, 2/16, 1/16, 4/16 }, -- the lever "hinge"
|
||||||
{ -1/16, -8/16, 4/16, 1/16, 0, 6/16 }} -- the lever itself.
|
{ -1/16, -8/16, 4/16, 1/16, 0, 6/16 }} -- the lever itself.
|
||||||
},
|
},
|
||||||
groups = {dig_immediate=2, mesecon = 3, mesecon_needs_receiver = 1},
|
groups = {dig_immediate=2, mesecon_needs_receiver = 1},
|
||||||
description="Lever",
|
description="Lever",
|
||||||
|
on_punch = function (pos, node)
|
||||||
|
mesecon:swap_node(pos, "mesecons_walllever:wall_lever_on")
|
||||||
|
mesecon:receptor_on(pos, walllever_get_rules(node))
|
||||||
|
end,
|
||||||
|
mesecon = {receptor = {
|
||||||
|
rules = walllever_get_rules,
|
||||||
|
state = mesecon.state.off
|
||||||
|
}}
|
||||||
})
|
})
|
||||||
minetest.register_node("mesecons_walllever:wall_lever_on", {
|
minetest.register_node("mesecons_walllever:wall_lever_on", {
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
@ -61,19 +87,16 @@ minetest.register_node("mesecons_walllever:wall_lever_on", {
|
|||||||
groups = {dig_immediate=2,not_in_creative_inventory=1, mesecon = 3, mesecon_needs_receiver = 1},
|
groups = {dig_immediate=2,not_in_creative_inventory=1, mesecon = 3, mesecon_needs_receiver = 1},
|
||||||
drop = '"mesecons_walllever:wall_lever_off" 1',
|
drop = '"mesecons_walllever:wall_lever_off" 1',
|
||||||
description="Lever",
|
description="Lever",
|
||||||
|
on_punch = function (pos, node)
|
||||||
|
mesecon:swap_node(pos, "mesecons_walllever:wall_lever_off")
|
||||||
|
mesecon:receptor_off(pos, walllever_get_rules(node))
|
||||||
|
end,
|
||||||
|
mesecon = {receptor = {
|
||||||
|
rules = walllever_get_rules,
|
||||||
|
state = mesecon.state.on
|
||||||
|
}}
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_on_punchnode(function(pos, node, puncher)
|
|
||||||
if node.name == "mesecons_walllever:wall_lever_off" then
|
|
||||||
minetest.env:add_node(pos, {name="mesecons_walllever:wall_lever_on",param2=node.param2})
|
|
||||||
mesecon:receptor_on(pos, mesecon.walllever_get_rules(node.param2))
|
|
||||||
end
|
|
||||||
if node.name == "mesecons_walllever:wall_lever_on" then
|
|
||||||
minetest.env:add_node(pos, {name="mesecons_walllever:wall_lever_off",param2=node.param2})
|
|
||||||
mesecon:receptor_off(pos, mesecon.walllever_get_rules(node.param2))
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = '"mesecons_walllever:wall_lever_off" 2',
|
output = '"mesecons_walllever:wall_lever_off" 2',
|
||||||
recipe = {
|
recipe = {
|
||||||
@ -82,29 +105,3 @@ minetest.register_craft({
|
|||||||
{'"default:stick"'},
|
{'"default:stick"'},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
mesecon:add_rules("walllever", {
|
|
||||||
{x = 1, y = 0, z = 0},
|
|
||||||
{x = 1, y = 1, z = 0},
|
|
||||||
{x = 1, y =-1, z = 0},
|
|
||||||
{x = 1, y =-1, z = 1},
|
|
||||||
{x = 1, y =-1, z =-1},
|
|
||||||
{x = 2, y = 0, z = 0},})
|
|
||||||
|
|
||||||
|
|
||||||
mesecon.walllever_get_rules = function(param2)
|
|
||||||
local rules=mesecon:get_rules("walllever")
|
|
||||||
if param2 == 2 then
|
|
||||||
rules=mesecon:rotate_rules_left(rules)
|
|
||||||
end
|
|
||||||
if param2 == 3 then
|
|
||||||
rules=mesecon:rotate_rules_right(mesecon:rotate_rules_right(rules))
|
|
||||||
end
|
|
||||||
if param2 == 0 then
|
|
||||||
rules=mesecon:rotate_rules_right(rules)
|
|
||||||
end
|
|
||||||
return rules
|
|
||||||
end
|
|
||||||
|
|
||||||
mesecon:add_receptor_node("mesecons_walllever:wall_lever_on", nil, mesecon.walllever_get_rules)
|
|
||||||
mesecon:add_receptor_node_off("mesecons_walllever:wall_lever_off", nil, mesecon.walllever_get_rules)
|
|
||||||
|
Loading…
Reference in New Issue
Block a user