From 72cae1327527672afe2bbb47662d42a44f086942 Mon Sep 17 00:00:00 2001 From: orwell Date: Tue, 11 Jun 2024 22:30:40 +0200 Subject: Fix more setstate stuff with new API (compat legacy) --- advtrains/p_mesecon_iface.lua | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) (limited to 'advtrains/p_mesecon_iface.lua') diff --git a/advtrains/p_mesecon_iface.lua b/advtrains/p_mesecon_iface.lua index 33fcecd..0b99891 100644 --- a/advtrains/p_mesecon_iface.lua +++ b/advtrains/p_mesecon_iface.lua @@ -14,13 +14,11 @@ minetest.override_item("mesecons_switch:mesecon_switch_off", { minetest.sound_play("mesecons_switch", {pos=pos}) end, advtrains = { - getstate = "off", - setstate = function(pos, node, newstate) - if newstate=="on" then - advtrains.ndb.swap_node(pos, {name="mesecons_switch:mesecon_switch_on", param2=node.param2}) - if advtrains.is_node_loaded(pos) then - mesecon.receptor_on(pos) - end + node_state = "off", + node_state_map = { on = "mesecons_switch:mesecon_switch_on", off = "mesecons_switch:mesecon_switch_off" }, + node_on_switch_state = function(pos, new_node, old_state, new_state) + if advtrains.is_node_loaded(pos) then + mesecon.receptor_on(pos) end end, on_updated_from_nodedb = function(pos, node) @@ -41,13 +39,11 @@ minetest.override_item("mesecons_switch:mesecon_switch_on", { minetest.sound_play("mesecons_switch", {pos=pos}) end, advtrains = { - getstate = "on", - setstate = function(pos, node, newstate) - if newstate=="off" then - advtrains.ndb.swap_node(pos, {name="mesecons_switch:mesecon_switch_off", param2=node.param2}) - if advtrains.is_node_loaded(pos) then - mesecon.receptor_off(pos) - end + node_state = "on", + node_state_map = { on = "mesecons_switch:mesecon_switch_on", off = "mesecons_switch:mesecon_switch_off" }, + node_on_switch_state = function(pos, new_node, old_state, new_state) + if advtrains.is_node_loaded(pos) then + mesecon.receptor_off(pos) end end, fallback_state = "off", -- cgit v1.2.3