~gpcf/advtrains-devel

Allow getstate() on Ks main and shunting signal v1 UNKNOWN

1F616EMO: 1
 Allow getstate() on Ks main and shunting signal

 1 files changed, 7 insertions(+), 4 deletions(-)
Hi 1F616EMO,

ywang is right here. I added the get_aspect() function to query the signal aspect table. The main reason why it is a separate function is, because the old 2-lamp signals already use getstate() to return "red" and "green" and I didn't want to break that. The Ks signals don't have a setstate() and thus also no getstate().

Regards, orwell

Am Mon, 21 Oct 2024 20:35:14 +0000
schrieb "Y. Wang" <y5nw@protonmail.com>:
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~gpcf/advtrains-devel/patches/55484/mbox | git am -3
Learn more about email & git

[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.
---
 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