|
122 | 122 | -- Overheat stuff --
|
123 | 123 | --------------------
|
124 | 124 |
|
125 |
| -local heat = function (meta) -- warm up |
126 |
| - h = meta:get_int("heat") |
127 |
| - if h ~= nil then |
128 |
| - meta:set_int("heat", h + 1) |
129 |
| - end |
130 |
| -end |
131 |
| - |
132 |
| ---local cool = function (meta) -- cool down after a while |
133 |
| --- h = meta:get_int("heat") |
134 |
| --- if h ~= nil then |
135 |
| --- meta:set_int("heat", h - 1) |
136 |
| --- end |
137 |
| ---end |
138 |
| - |
139 |
| -local overheat = function (meta) -- determine if too hot |
140 |
| - h = meta:get_int("heat") |
141 |
| - if h == nil then return true end -- if nil then overheat |
142 |
| - if h > 40 then |
143 |
| - return true |
144 |
| - else |
145 |
| - return false |
146 |
| - end |
147 |
| -end |
148 |
| - |
149 | 125 | local overheat_off = function(pos)
|
150 | 126 | mesecon:receptor_off(pos, mesecon.rules.flat)
|
151 | 127 | end
|
@@ -232,6 +208,8 @@ local create_environment = function(pos, mem, event)
|
232 | 208 | mem = mem,
|
233 | 209 | tostring = tostring,
|
234 | 210 | tonumber = tonumber,
|
| 211 | + heat = minetest.get_meta(pos):get_int("heat"), |
| 212 | + heat_max = OVERHEAT_MAX, |
235 | 213 | string = {
|
236 | 214 | byte = string.byte,
|
237 | 215 | char = string.char,
|
@@ -299,11 +277,8 @@ local create_sandbox = function (code, env)
|
299 | 277 | return f
|
300 | 278 | end
|
301 | 279 |
|
302 |
| -local do_overheat = function (pos, meta) |
303 |
| - -- Overheat protection |
304 |
| - heat(meta) |
305 |
| - --minetest.after(0.5, cool, meta) |
306 |
| - if overheat(meta) then |
| 280 | +local lc_overheat = function (pos, meta) |
| 281 | + if mesecon.do_overheat(pos) then -- if too hot |
307 | 282 | local node = minetest.get_node(pos)
|
308 | 283 | minetest.swap_node(pos, {name = BASENAME.."_burnt", param2 = node.param2})
|
309 | 284 | minetest.after(0.2, overheat_off, pos) -- wait for pending operations
|
|
332 | 307 |
|
333 | 308 | lc_update = function (pos, event)
|
334 | 309 | local meta = minetest.get_meta(pos)
|
335 |
| - if do_overheat(pos, meta) then return end |
| 310 | + if lc_overheat(pos) then return end |
336 | 311 |
|
337 | 312 | -- load code & mem from memory
|
338 | 313 | local mem = load_memory(meta)
|
@@ -507,9 +482,9 @@ minetest.register_node(nodename, {
|
507 | 482 | mesecons = mesecons,
|
508 | 483 | digiline = digiline,
|
509 | 484 | virtual_portstates = { a = a == 1, -- virtual portstates are
|
510 |
| - b = b == 1, -- the ports the the |
511 |
| - c = c == 1, -- controller powers itself |
512 |
| - d = d == 1},-- so those that light up |
| 485 | + b = b == 1, -- the ports the the |
| 486 | + c = c == 1, -- controller powers itself |
| 487 | + d = d == 1},-- so those that light up |
513 | 488 | after_dig_node = function (pos, node)
|
514 | 489 | mesecon:receptor_off(pos, output_rules)
|
515 | 490 | end,
|
|
520 | 495 | end
|
521 | 496 | end
|
522 | 497 |
|
523 |
| ---overheated luacontroller |
| 498 | +------------------------------ |
| 499 | +-- overheated luacontroller -- |
| 500 | +------------------------------ |
| 501 | + |
| 502 | +local mesecons_burnt = { |
| 503 | + effector = |
| 504 | + { |
| 505 | + rules = mesecon.rules.flat, |
| 506 | + action_change = function (pos, _, rulename, newstate) |
| 507 | + -- only update portstates when changes are triggered |
| 508 | + lc_update_real_portstates(pos, rulename, newstate) |
| 509 | + end |
| 510 | + } |
| 511 | +} |
| 512 | + |
524 | 513 | minetest.register_node(BASENAME .. "_burnt", {
|
525 | 514 | drawtype = "nodebox",
|
526 | 515 | tiles = {
|
@@ -553,6 +542,7 @@ minetest.register_node(BASENAME .. "_burnt", {
|
553 | 542 | end,
|
554 | 543 | sounds = default.node_sound_stone_defaults(),
|
555 | 544 | virtual_portstates = {a = false, b = false, c = false, d = false},
|
| 545 | + mesecons = mesecons_burnt, |
556 | 546 | })
|
557 | 547 |
|
558 | 548 | ------------------------
|
|
0 commit comments