~gpcf/advtrains-devel

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
2 2

[PATCH v1] Allow getstate() on Ks main and shunting signal

Details
Message ID
<20241015122454.146775-1-root@1f616emo.xyz>
DKIM signature
pass
Download raw message
Patch: +7 -4
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
Details
Message ID
<07ecd502-60bb-429a-b1bb-5e97eb604d60@protonmail.com>
In-Reply-To
<20241015122454.146775-1-root@1f616emo.xyz> (view parent)
DKIM signature
pass
Download raw message
> 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.
Details
Message ID
<20241109222923.3fd005e1@BARIUM>
In-Reply-To
<07ecd502-60bb-429a-b1bb-5e97eb604d60@protonmail.com> (view parent)
DKIM signature
pass
Download raw message
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>:

> > 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.
> 
Reply to thread Export thread (mbox)