[PATCH v1] Allow getstate() on Ks main and shunting signal
Export this patch
Adds advtrains.getstate() function to Ks main and shunting signals. Returned values are tables containing full aspect.
Usecase? LuaATC provides get_aspect(pos) that allows you to get the
aspect of a signal.
---
advtrains_signals_ks/init.lua | 11 +++++++ ----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/advtrains_signals_ks/init.lua b/advtrains_signals_ks/init.lua
index 258b868..b842431 100755
--- a/advtrains_signals_ks/init.lua
+++ b/advtrains_signals_ks/init.lua
@@ -154,7 +154,7 @@ for _, rtab in ipairs({
local tile = "advtrains_signals_ks_ltm_"..typ..".png"
local afunc = prts.asp
if type(afunc) == "table" then
- afunc = function() return prts.asp end
+ afunc = function() return table.copy(prts.asp) end
end
if typ == "nextslow" then
tile = {
@@ -195,6 +195,7 @@ for _, rtab in ipairs({
set_aspect = setaspectf(rot),
supported_aspects = suppasp,
get_aspect = afunc,
+ getstate = afunc,
},
on_rightclick = advtrains.interlocking.signal_rc_handler,
can_dig = advtrains.interlocking.signal_can_dig,
@@ -210,6 +211,9 @@ for _, rtab in ipairs({
danger = {asp = { main = false, shunt = false }, n = "shuntd", ici=true},
shuntd = {asp = { main = false, shunt = true } , n = "danger"},
}) do
+ local function afunc()
+ return table.copy(prts.asp)
+ end
local sbox = table.copy(rtab.sbox)
sbox[5] = 0
minetest.register_node("advtrains_signals_ks:ra_"..typ.."_"..rot, {
@@ -243,9 +247,8 @@ for _, rtab in ipairs({
advtrains = {
set_aspect = setaspectf_ra(rot),
supported_aspects = suppasp_ra,
- get_aspect = function(pos, node)
- return prts.asp
- end,
+ get_aspect = afunc,
+ getstate = afunc,
},
on_rightclick = advtrains.interlocking.signal_rc_handler,
can_dig = advtrains.interlocking.signal_can_dig,
--
2.47.0