Skip to content

Commit 9a9df6c

Browse files
committedJun 5, 2013
Merge pull request #106 from Novatux/heat
Add an ABM function which resets heat to 0, ...
2 parents fa0cf15 + edc10da commit 9a9df6c

File tree

4 files changed

+33
-23
lines changed

4 files changed

+33
-23
lines changed
 

‎mesecons/services.lua

+10
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,15 @@ mesecon.on_dignode = function (pos, node)
2525
end
2626
end
2727

28+
minetest.register_abm({
29+
nodenames = {"group:overheat"},
30+
interval = 1.0,
31+
chance = 1,
32+
action = function(pos, node, active_object_count, active_object_count_wider)
33+
local meta = minetest.env:get_meta(pos)
34+
meta:set_int("heat",0)
35+
end,
36+
})
37+
2838
minetest.register_on_placenode(mesecon.on_placenode)
2939
minetest.register_on_dignode(mesecon.on_dignode)

‎mesecons_gates/init.lua

+3-3
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ function set_gate(pos, on)
4747
local meta = minetest.env:get_meta(pos)
4848
if on ~= gate_state(pos) then
4949
yc_heat(meta)
50-
minetest.after(0.5, yc_cool, meta)
50+
--minetest.after(0.5, yc_cool, meta)
5151
if yc_overheat(meta) then
5252
pop_gate(pos)
5353
else
@@ -112,13 +112,13 @@ for _, gate in ipairs(gates) do
112112
drop = nodename.."_off"
113113
nodename = nodename.."_"..onoff
114114
description = "You hacker you!"
115-
groups = {dig_immediate=2, not_in_creative_inventory=1}
115+
groups = {dig_immediate=2, not_in_creative_inventory=1, overheat = 1}
116116
else
117117
onoff = "off"
118118
drop = nil
119119
nodename = nodename.."_"..onoff
120120
description = gate.name.." Gate"
121-
groups = {dig_immediate=2}
121+
groups = {dig_immediate=2, overheat = 1}
122122
end
123123

124124
tiles = "jeija_microcontroller_bottom.png^"..

‎mesecons_luacontroller/init.lua

+10-10
Original file line numberDiff line numberDiff line change
@@ -100,17 +100,17 @@ local heat = function (meta) -- warm up
100100
end
101101
end
102102

103-
local cool = function (meta) -- cool down after a while
104-
h = meta:get_int("heat")
105-
if h ~= nil then
106-
meta:set_int("heat", h - 1)
107-
end
108-
end
103+
--local cool = function (meta) -- cool down after a while
104+
-- h = meta:get_int("heat")
105+
-- if h ~= nil then
106+
-- meta:set_int("heat", h - 1)
107+
-- end
108+
--end
109109

110110
local overheat = function (meta) -- determine if too hot
111111
h = meta:get_int("heat")
112112
if h == nil then return true end -- if nil then overheat
113-
if h > 20 then
113+
if h > 40 then
114114
return true
115115
else
116116
return false
@@ -258,7 +258,7 @@ end
258258
local do_overheat = function (pos, meta)
259259
-- Overheat protection
260260
heat(meta)
261-
minetest.after(0.5, cool, meta)
261+
--minetest.after(0.5, cool, meta)
262262
if overheat(meta) then
263263
mesecon:swap_node(pos, BASENAME.."_burnt")
264264
minetest.env:get_meta(pos):set_string("lc_interrupts", "")
@@ -412,9 +412,9 @@ if d == 1 then
412412
end
413413

414414
if a + b + c + d ~= 0 then
415-
groups = {dig_immediate=2, not_in_creative_inventory=1}
415+
groups = {dig_immediate=2, not_in_creative_inventory=1, overheat = 1}
416416
else
417-
groups = {dig_immediate=2}
417+
groups = {dig_immediate=2, overheat = 1}
418418
end
419419

420420
output_rules[cid] = {}

‎mesecons_microcontroller/init.lua

+10-10
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ if tostring(d) == "1" then
1919
top = top.."^jeija_microcontroller_LED_D.png"
2020
end
2121
if tostring(d)..tostring(c)..tostring(b)..tostring(a) ~= "0000" then
22-
groups = {dig_immediate=2, not_in_creative_inventory=1, mesecon = 3}
22+
groups = {dig_immediate=2, not_in_creative_inventory=1, mesecon = 3, overheat = 1}
2323
else
24-
groups = {dig_immediate=2, mesecon = 3}
24+
groups = {dig_immediate=2, mesecon = 3, overheat = 1}
2525
end
2626
local rules={}
2727
if (a == 1) then table.insert(rules, {x = -1, y = 0, z = 0}) end
@@ -162,7 +162,7 @@ end
162162
function update_yc(pos)
163163
local meta = minetest.env:get_meta(pos)
164164
yc_heat(meta)
165-
minetest.after(0.5, yc_cool, meta)
165+
--minetest.after(0.5, yc_cool, meta)
166166
if (yc_overheat(meta)) then
167167
minetest.env:remove_node(pos)
168168
minetest.after(0.2, yc_overheat_off, pos) --wait for pending parsings
@@ -674,17 +674,17 @@ function yc_heat(meta)
674674
end
675675
end
676676

677-
function yc_cool(meta)
678-
h = meta:get_int("heat")
679-
if h ~= nil then
680-
meta:set_int("heat", h - 1)
681-
end
682-
end
677+
--function yc_cool(meta)
678+
-- h = meta:get_int("heat")
679+
-- if h ~= nil then
680+
-- meta:set_int("heat", h - 1)
681+
-- end
682+
--end
683683

684684
function yc_overheat(meta)
685685
h = meta:get_int("heat")
686686
if h == nil then return true end -- if nil the overheat
687-
if h>30 then
687+
if h>60 then
688688
return true
689689
else
690690
return false

0 commit comments

Comments
 (0)
Please sign in to comment.