Skip to content

Commit 47a49ec

Browse files
committed
Use minetest.swap_node instead of hacky_swap_node
1 parent ba4c806 commit 47a49ec

File tree

3 files changed

+8
-21
lines changed

3 files changed

+8
-21
lines changed

mods/default/nodes.lua

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -960,18 +960,13 @@ minetest.register_node("default:furnace_active", {
960960
end,
961961
})
962962

963-
function hacky_swap_node(pos,name)
963+
local function swap_node(pos,name)
964964
local node = minetest.get_node(pos)
965-
local meta = minetest.get_meta(pos)
966-
local meta0 = meta:to_table()
967965
if node.name == name then
968966
return
969967
end
970968
node.name = name
971-
local meta0 = meta:to_table()
972-
minetest.set_node(pos,node)
973-
meta = minetest.get_meta(pos)
974-
meta:from_table(meta0)
969+
minetest.swap_node(pos,node)
975970
end
976971

977972
minetest.register_abm({
@@ -1025,7 +1020,7 @@ minetest.register_abm({
10251020
local percent = math.floor(meta:get_float("fuel_time") /
10261021
meta:get_float("fuel_totaltime") * 100)
10271022
meta:set_string("infotext","Furnace active: "..percent.."%")
1028-
hacky_swap_node(pos,"default:furnace_active")
1023+
swap_node(pos,"default:furnace_active")
10291024
meta:set_string("formspec",default.get_furnace_active_formspec(pos, percent))
10301025
return
10311026
end
@@ -1045,15 +1040,15 @@ minetest.register_abm({
10451040

10461041
if fuel.time <= 0 then
10471042
meta:set_string("infotext","Furnace out of fuel")
1048-
hacky_swap_node(pos,"default:furnace")
1043+
swap_node(pos,"default:furnace")
10491044
meta:set_string("formspec", default.furnace_inactive_formspec)
10501045
return
10511046
end
10521047

10531048
if cooked.item:is_empty() then
10541049
if was_active then
10551050
meta:set_string("infotext","Furnace is empty")
1056-
hacky_swap_node(pos,"default:furnace")
1051+
swap_node(pos,"default:furnace")
10571052
meta:set_string("formspec", default.furnace_inactive_formspec)
10581053
end
10591054
return

mods/doors/init.lua

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,10 @@ function doors:register_door(name, def)
113113
local p2 = minetest.get_node(pos).param2
114114
p2 = params[p2+1]
115115

116-
local meta = minetest.get_meta(pos):to_table()
117-
minetest.set_node(pos, {name=replace_dir, param2=p2})
118-
minetest.get_meta(pos):from_table(meta)
116+
minetest.swap_node(pos, {name=replace_dir, param2=p2})
119117

120118
pos.y = pos.y-dir
121-
meta = minetest.get_meta(pos):to_table()
122-
minetest.set_node(pos, {name=replace, param2=p2})
123-
minetest.get_meta(pos):from_table(meta)
119+
minetest.swap_node(pos, {name=replace, param2=p2})
124120
end
125121

126122
local function check_player_priv(pos, player)

mods/screwdriver/init.lua

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,8 @@ function screwdriver_handler (itemstack,user,pointed_thing)
113113
end
114114
end
115115
--print (dump(axisdir..", "..rotation))
116-
local meta = minetest.get_meta(pos)
117-
local meta0 = meta:to_table()
118116
node.param2 = n
119-
minetest.set_node(pos,node)
120-
meta = minetest.get_meta(pos)
121-
meta:from_table(meta0)
117+
minetest.swap_node(pos,node)
122118
local item=itemstack:to_table()
123119
local item_wear=tonumber((item["wear"]))
124120
item_wear=item_wear+327

0 commit comments

Comments
 (0)