forked from minetest-mods/mesecons
Merge pull request #106 from Novatux/heat
Add an ABM function which resets heat to 0, ...
This commit is contained in:
commit
9a9df6cabf
@ -25,5 +25,15 @@ mesecon.on_dignode = function (pos, node)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
minetest.register_abm({
|
||||||
|
nodenames = {"group:overheat"},
|
||||||
|
interval = 1.0,
|
||||||
|
chance = 1,
|
||||||
|
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||||
|
local meta = minetest.env:get_meta(pos)
|
||||||
|
meta:set_int("heat",0)
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
minetest.register_on_placenode(mesecon.on_placenode)
|
minetest.register_on_placenode(mesecon.on_placenode)
|
||||||
minetest.register_on_dignode(mesecon.on_dignode)
|
minetest.register_on_dignode(mesecon.on_dignode)
|
||||||
|
@ -47,7 +47,7 @@ function set_gate(pos, on)
|
|||||||
local meta = minetest.env:get_meta(pos)
|
local meta = minetest.env:get_meta(pos)
|
||||||
if on ~= gate_state(pos) then
|
if on ~= gate_state(pos) then
|
||||||
yc_heat(meta)
|
yc_heat(meta)
|
||||||
minetest.after(0.5, yc_cool, meta)
|
--minetest.after(0.5, yc_cool, meta)
|
||||||
if yc_overheat(meta) then
|
if yc_overheat(meta) then
|
||||||
pop_gate(pos)
|
pop_gate(pos)
|
||||||
else
|
else
|
||||||
@ -112,13 +112,13 @@ for _, gate in ipairs(gates) do
|
|||||||
drop = nodename.."_off"
|
drop = nodename.."_off"
|
||||||
nodename = nodename.."_"..onoff
|
nodename = nodename.."_"..onoff
|
||||||
description = "You hacker you!"
|
description = "You hacker you!"
|
||||||
groups = {dig_immediate=2, not_in_creative_inventory=1}
|
groups = {dig_immediate=2, not_in_creative_inventory=1, overheat = 1}
|
||||||
else
|
else
|
||||||
onoff = "off"
|
onoff = "off"
|
||||||
drop = nil
|
drop = nil
|
||||||
nodename = nodename.."_"..onoff
|
nodename = nodename.."_"..onoff
|
||||||
description = gate.name.." Gate"
|
description = gate.name.." Gate"
|
||||||
groups = {dig_immediate=2}
|
groups = {dig_immediate=2, overheat = 1}
|
||||||
end
|
end
|
||||||
|
|
||||||
tiles = "jeija_microcontroller_bottom.png^"..
|
tiles = "jeija_microcontroller_bottom.png^"..
|
||||||
|
@ -100,17 +100,17 @@ local heat = function (meta) -- warm up
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local cool = function (meta) -- cool down after a while
|
--local cool = function (meta) -- cool down after a while
|
||||||
h = meta:get_int("heat")
|
-- h = meta:get_int("heat")
|
||||||
if h ~= nil then
|
-- if h ~= nil then
|
||||||
meta:set_int("heat", h - 1)
|
-- meta:set_int("heat", h - 1)
|
||||||
end
|
-- end
|
||||||
end
|
--end
|
||||||
|
|
||||||
local overheat = function (meta) -- determine if too hot
|
local overheat = function (meta) -- determine if too hot
|
||||||
h = meta:get_int("heat")
|
h = meta:get_int("heat")
|
||||||
if h == nil then return true end -- if nil then overheat
|
if h == nil then return true end -- if nil then overheat
|
||||||
if h > 20 then
|
if h > 40 then
|
||||||
return true
|
return true
|
||||||
else
|
else
|
||||||
return false
|
return false
|
||||||
@ -258,7 +258,7 @@ end
|
|||||||
local do_overheat = function (pos, meta)
|
local do_overheat = function (pos, meta)
|
||||||
-- Overheat protection
|
-- Overheat protection
|
||||||
heat(meta)
|
heat(meta)
|
||||||
minetest.after(0.5, cool, meta)
|
--minetest.after(0.5, cool, meta)
|
||||||
if overheat(meta) then
|
if overheat(meta) then
|
||||||
mesecon:swap_node(pos, BASENAME.."_burnt")
|
mesecon:swap_node(pos, BASENAME.."_burnt")
|
||||||
minetest.env:get_meta(pos):set_string("lc_interrupts", "")
|
minetest.env:get_meta(pos):set_string("lc_interrupts", "")
|
||||||
@ -412,9 +412,9 @@ if d == 1 then
|
|||||||
end
|
end
|
||||||
|
|
||||||
if a + b + c + d ~= 0 then
|
if a + b + c + d ~= 0 then
|
||||||
groups = {dig_immediate=2, not_in_creative_inventory=1}
|
groups = {dig_immediate=2, not_in_creative_inventory=1, overheat = 1}
|
||||||
else
|
else
|
||||||
groups = {dig_immediate=2}
|
groups = {dig_immediate=2, overheat = 1}
|
||||||
end
|
end
|
||||||
|
|
||||||
output_rules[cid] = {}
|
output_rules[cid] = {}
|
||||||
|
@ -19,9 +19,9 @@ if tostring(d) == "1" then
|
|||||||
top = top.."^jeija_microcontroller_LED_D.png"
|
top = top.."^jeija_microcontroller_LED_D.png"
|
||||||
end
|
end
|
||||||
if tostring(d)..tostring(c)..tostring(b)..tostring(a) ~= "0000" then
|
if tostring(d)..tostring(c)..tostring(b)..tostring(a) ~= "0000" then
|
||||||
groups = {dig_immediate=2, not_in_creative_inventory=1, mesecon = 3}
|
groups = {dig_immediate=2, not_in_creative_inventory=1, mesecon = 3, overheat = 1}
|
||||||
else
|
else
|
||||||
groups = {dig_immediate=2, mesecon = 3}
|
groups = {dig_immediate=2, mesecon = 3, overheat = 1}
|
||||||
end
|
end
|
||||||
local rules={}
|
local rules={}
|
||||||
if (a == 1) then table.insert(rules, {x = -1, y = 0, z = 0}) end
|
if (a == 1) then table.insert(rules, {x = -1, y = 0, z = 0}) end
|
||||||
@ -162,7 +162,7 @@ end
|
|||||||
function update_yc(pos)
|
function update_yc(pos)
|
||||||
local meta = minetest.env:get_meta(pos)
|
local meta = minetest.env:get_meta(pos)
|
||||||
yc_heat(meta)
|
yc_heat(meta)
|
||||||
minetest.after(0.5, yc_cool, meta)
|
--minetest.after(0.5, yc_cool, meta)
|
||||||
if (yc_overheat(meta)) then
|
if (yc_overheat(meta)) then
|
||||||
minetest.env:remove_node(pos)
|
minetest.env:remove_node(pos)
|
||||||
minetest.after(0.2, yc_overheat_off, pos) --wait for pending parsings
|
minetest.after(0.2, yc_overheat_off, pos) --wait for pending parsings
|
||||||
@ -674,17 +674,17 @@ function yc_heat(meta)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function yc_cool(meta)
|
--function yc_cool(meta)
|
||||||
h = meta:get_int("heat")
|
-- h = meta:get_int("heat")
|
||||||
if h ~= nil then
|
-- if h ~= nil then
|
||||||
meta:set_int("heat", h - 1)
|
-- meta:set_int("heat", h - 1)
|
||||||
end
|
-- end
|
||||||
end
|
--end
|
||||||
|
|
||||||
function yc_overheat(meta)
|
function yc_overheat(meta)
|
||||||
h = meta:get_int("heat")
|
h = meta:get_int("heat")
|
||||||
if h == nil then return true end -- if nil the overheat
|
if h == nil then return true end -- if nil the overheat
|
||||||
if h>30 then
|
if h>60 then
|
||||||
return true
|
return true
|
||||||
else
|
else
|
||||||
return false
|
return false
|
||||||
|
Loading…
Reference in New Issue
Block a user