forked from mrkubax10/industrialtest
Mesecons compatibility: Nuclear Reactor and Nuclear Reactor Chamber
This commit is contained in:
parent
28040db868
commit
96c9fe164a
@ -16,31 +16,107 @@
|
||||
|
||||
-- Rotary Macerator
|
||||
local override={
|
||||
mesecons={
|
||||
effector={
|
||||
action_on=function(pos,node)
|
||||
if node.name~="industrialtest:rotary_macerator" then
|
||||
return
|
||||
end
|
||||
|
||||
local meta=minetest.get_meta(pos)
|
||||
meta:set_int("maintainSpeed",1)
|
||||
mesecons={
|
||||
effector={
|
||||
action_on=function(pos,node)
|
||||
if node.name~="industrialtest:rotary_macerator" then
|
||||
return
|
||||
end
|
||||
|
||||
local def=minetest.registered_nodes[node.name]
|
||||
def._industrialtest_updateFormspec(pos)
|
||||
local meta=minetest.get_meta(pos)
|
||||
meta:set_int("maintainSpeed",1)
|
||||
|
||||
minetest.get_node_timer(pos):start(industrialtest.updateDelay)
|
||||
end,
|
||||
action_off=function(pos,node)
|
||||
local meta=minetest.get_meta(pos)
|
||||
meta:set_int("maintainSpeed",0)
|
||||
local def=minetest.registered_nodes[node.name]
|
||||
def._industrialtest_updateFormspec(pos)
|
||||
|
||||
local def=minetest.registered_nodes[node.name]
|
||||
def._industrialtest_updateFormspec(pos)
|
||||
end
|
||||
}
|
||||
}
|
||||
minetest.get_node_timer(pos):start(industrialtest.updateDelay)
|
||||
end,
|
||||
action_off=function(pos,node)
|
||||
local meta=minetest.get_meta(pos)
|
||||
meta:set_int("maintainSpeed",0)
|
||||
|
||||
local def=minetest.registered_nodes[node.name]
|
||||
def._industrialtest_updateFormspec(pos)
|
||||
end
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
minetest.override_item("industrialtest:rotary_macerator",override)
|
||||
minetest.override_item("industrialtest:rotary_macerator_active",override)
|
||||
|
||||
-- Nuclear Reactor
|
||||
override={
|
||||
mesecons={
|
||||
effector={
|
||||
action_on=function(pos,node)
|
||||
local isChamber=node.name=="industrialtest:nuclear_reactor_chamber"
|
||||
if node.name~="industrialtest:nuclear_reactor" and not isChamber then
|
||||
return
|
||||
end
|
||||
|
||||
local originalPos
|
||||
local meta=minetest.get_meta(pos)
|
||||
meta:set_int("meseconPowered",1)
|
||||
if isChamber then
|
||||
originalPos=pos
|
||||
pos=minetest.deserialize(meta:get_string("reactor"))
|
||||
node=minetest.get_node(pos)
|
||||
meta=minetest.get_meta(pos)
|
||||
end
|
||||
|
||||
meta:set_int("enabled",1)
|
||||
meta:set_int("stateChanged",1)
|
||||
|
||||
local def=minetest.registered_nodes[node.name]
|
||||
def._industrialtest_updateFormspec(pos)
|
||||
|
||||
if isChamber then
|
||||
def._industrialtest_synchronizeToChamber(originalPos)
|
||||
end
|
||||
|
||||
minetest.get_node_timer(pos):start(industrialtest.updateDelay)
|
||||
end,
|
||||
action_off=function(pos,node)
|
||||
local isChamber=node.name=="industrialtest:nuclear_reactor_chamber"
|
||||
|
||||
local originalPos
|
||||
local meta=minetest.get_meta(pos)
|
||||
meta:set_int("meseconPowered",0)
|
||||
if isChamber then
|
||||
originalPos=pos
|
||||
pos=minetest.deserialize(meta:get_string("reactor"))
|
||||
node=minetest.get_node(pos)
|
||||
meta=minetest.get_meta(pos)
|
||||
end
|
||||
|
||||
if meta:get_int("meseconPowered")==1 then
|
||||
return
|
||||
end
|
||||
local chambers=minetest.deserialize(meta:get_string("chambers"))
|
||||
for _,chamber in ipairs(chambers) do
|
||||
local chamberMeta=minetest.get_meta(chamber)
|
||||
if chamberMeta:get_int("meseconPowered")==1 then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
meta:set_int("enabled",0)
|
||||
meta:set_int("stateChanged",1)
|
||||
|
||||
local def=minetest.registered_nodes[node.name]
|
||||
def._industrialtest_updateFormspec(pos)
|
||||
|
||||
if isChamber then
|
||||
def._industrialtest_synchronizeToChamber(originalPos)
|
||||
end
|
||||
end
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
minetest.override_item("industrialtest:nuclear_reactor",override)
|
||||
minetest.override_item("industrialtest:nuclear_reactor_active",override)
|
||||
|
||||
-- Nuclear Reactor Chamber
|
||||
minetest.override_item("industrialtest:nuclear_reactor_chamber",override)
|
||||
|
@ -454,7 +454,8 @@ industrialtest.internal.registerMachine({
|
||||
},
|
||||
paramtype2="facedir",
|
||||
legacy_facedir_simple=true,
|
||||
on_receive_fields=reactor.handleFormspecFields
|
||||
on_receive_fields=reactor.handleFormspecFields,
|
||||
_industrialtest_synchronizeToChamber=reactor.synchronizeToChamber
|
||||
},
|
||||
activeCustomKeys={
|
||||
tiles={
|
||||
|
Loading…
Reference in New Issue
Block a user