mirror of
https://github.com/minetest-mods/mesecons.git
synced 2024-12-26 10:20:19 +01:00
Add burnt luacontroller (so you don't lose your program after an overheat) and prevent interrupts from piling up (fixes #101, metadata trashing). Idea for burnt luacontroller comes from ShadowNinja.
This commit is contained in:
parent
6f83f4cf1e
commit
682cf34792
@ -149,8 +149,17 @@ local getinterrupt = function(pos)
|
|||||||
local iid = iid or math.random()
|
local iid = iid or math.random()
|
||||||
local meta = minetest.env:get_meta(pos)
|
local meta = minetest.env:get_meta(pos)
|
||||||
local interrupts = minetest.deserialize(meta:get_string("lc_interrupts")) or {}
|
local interrupts = minetest.deserialize(meta:get_string("lc_interrupts")) or {}
|
||||||
|
local found = false
|
||||||
|
for _, i in ipairs(interrupts) do
|
||||||
|
if minetest.serialize(i) == minetest.serialize(event.iid) then
|
||||||
|
found = true
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if not found then
|
||||||
table.insert(interrupts, iid)
|
table.insert(interrupts, iid)
|
||||||
meta:set_string("lc_interrupts", minetest.serialize(interrupts))
|
meta:set_string("lc_interrupts", minetest.serialize(interrupts))
|
||||||
|
end
|
||||||
minetest.after(time, interrupt, {pos=pos, iid = iid})
|
minetest.after(time, interrupt, {pos=pos, iid = iid})
|
||||||
end
|
end
|
||||||
return interrupt
|
return interrupt
|
||||||
@ -251,9 +260,9 @@ local do_overheat = function (pos, meta)
|
|||||||
heat(meta)
|
heat(meta)
|
||||||
minetest.after(0.5, cool, meta)
|
minetest.after(0.5, cool, meta)
|
||||||
if overheat(meta) then
|
if overheat(meta) then
|
||||||
minetest.env:remove_node(pos)
|
mesecon:swap_node(pos, BASENAME.."_burnt")
|
||||||
|
minetest.env:get_meta(pos):set_string("lc_interrupts", "")
|
||||||
minetest.after(0.2, overheat_off, pos) -- wait for pending operations
|
minetest.after(0.2, overheat_off, pos) -- wait for pending operations
|
||||||
minetest.env:add_item(pos, BASENAME.."0000")
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -479,6 +488,37 @@ end
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--overheated luacontroller
|
||||||
|
minetest.register_node(BASENAME .. "_burnt", {
|
||||||
|
drawtype = "nodebox",
|
||||||
|
tiles = {
|
||||||
|
"jeija_luacontroller_burnt_top.png",
|
||||||
|
"jeija_microcontroller_bottom.png",
|
||||||
|
"jeija_microcontroller_sides.png",
|
||||||
|
"jeija_microcontroller_sides.png",
|
||||||
|
"jeija_microcontroller_sides.png",
|
||||||
|
"jeija_microcontroller_sides.png"
|
||||||
|
},
|
||||||
|
inventory_image = "jeija_luacontroller_burnt_top.png",
|
||||||
|
paramtype = "light",
|
||||||
|
groups = {dig_immediate=2, not_in_creative_inventory=1},
|
||||||
|
drop = BASENAME.."0000",
|
||||||
|
sunlight_propagates = true,
|
||||||
|
selection_box = selectionbox,
|
||||||
|
node_box = nodebox,
|
||||||
|
on_construct = reset_meta,
|
||||||
|
on_receive_fields = function(pos, formname, fields)
|
||||||
|
reset(pos)
|
||||||
|
reset_meta(pos, fields.code)
|
||||||
|
local err = lc_update(pos, {type="program"})
|
||||||
|
if err then print(err) end
|
||||||
|
reset_meta(pos, fields.code, err)
|
||||||
|
end,
|
||||||
|
sounds = default.node_sound_stone_defaults(),
|
||||||
|
is_luacontroller = true,
|
||||||
|
virtual_portstates = {a = false, b = false, c = false, d = false},
|
||||||
|
})
|
||||||
|
|
||||||
------------------------
|
------------------------
|
||||||
-- Craft Registration --
|
-- Craft Registration --
|
||||||
------------------------
|
------------------------
|
||||||
|
BIN
mesecons_textures/textures/jeija_luacontroller_burnt_top.png
Normal file
BIN
mesecons_textures/textures/jeija_luacontroller_burnt_top.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.5 KiB |
Loading…
Reference in New Issue
Block a user