summaryrefslogtreecommitdiff
path: root/games
diff options
context:
space:
mode:
authorNovatux <nathanael.courant@laposte.net>2013-11-23 15:35:49 +0100
committerNovatux <nathanael.courant@laposte.net>2013-11-30 18:37:56 +0100
commitd879a539cd19ddd1ee34afec2512fb2238de2822 (patch)
tree68105678426cb1a498bfe3ba4354506a9a560409 /games
parent752e11e11411d72868a406d35538adc5d1126655 (diff)
downloadminetest-d879a539cd19ddd1ee34afec2512fb2238de2822.tar.gz
minetest-d879a539cd19ddd1ee34afec2512fb2238de2822.tar.bz2
minetest-d879a539cd19ddd1ee34afec2512fb2238de2822.zip
Add minetest.swap_node
Diffstat (limited to 'games')
-rw-r--r--games/minimal/mods/default/init.lua15
1 files changed, 5 insertions, 10 deletions
diff --git a/games/minimal/mods/default/init.lua b/games/minimal/mods/default/init.lua
index 8cef3fcc0..038bf9abc 100644
--- a/games/minimal/mods/default/init.lua
+++ b/games/minimal/mods/default/init.lua
@@ -1318,18 +1318,13 @@ minetest.register_node("default:furnace_active", {
end,
})
-function hacky_swap_node(pos,name)
+function swap_node(pos,name)
local node = minetest.get_node(pos)
- local meta = minetest.get_meta(pos)
- local meta0 = meta:to_table()
if node.name == name then
return
end
node.name = name
- local meta0 = meta:to_table()
- minetest.set_node(pos,node)
- meta = minetest.get_meta(pos)
- meta:from_table(meta0)
+ minetest.swap_node(pos, node)
end
minetest.register_abm({
@@ -1384,7 +1379,7 @@ minetest.register_abm({
local percent = math.floor(meta:get_float("fuel_time") /
meta:get_float("fuel_totaltime") * 100)
meta:set_string("infotext","Furnace active: "..percent.."%")
- hacky_swap_node(pos,"default:furnace_active")
+ swap_node(pos,"default:furnace_active")
meta:set_string("formspec",
"size[8,9]"..
"image[2,2;1,1;default_furnace_fire_bg.png^[lowpart:"..
@@ -1410,7 +1405,7 @@ minetest.register_abm({
if fuel.time <= 0 then
meta:set_string("infotext","Furnace out of fuel")
- hacky_swap_node(pos,"default:furnace")
+ swap_node(pos,"default:furnace")
meta:set_string("formspec", default.furnace_inactive_formspec)
return
end
@@ -1418,7 +1413,7 @@ minetest.register_abm({
if cooked.item:is_empty() then
if was_active then
meta:set_string("infotext","Furnace is empty")
- hacky_swap_node(pos,"default:furnace")
+ swap_node(pos,"default:furnace")
meta:set_string("formspec", default.furnace_inactive_formspec)
end
return