HASHEAD signal function How, if at all, can it be used?
#1
Posted 13 May 2019 - 01:42 PM
#2
Posted 14 May 2019 - 05:33 AM
You will use a shape with a optional third Signalhead and if the third Head is in use, the signal has to show different aspects?
Yes for that you can use HASHEAD
In the signalshape-definition in the sigcfg.dat You will have the optional Signalhead which, as example, has the name HEAD3:
SignalSubObj ( 4 "HEAD3" "Signalkopf Ausfahrvorsignal" SigSubType ( SIGNAL_HEAD ) SignalFlags ( DEFAULT OPTIONAL ) SigSubSType ( "ChLVorsignal" ) )
In the script of this signal in the sigscr.dat
you need the following code:
float test; test = HASHEAD(HEAD3); If test = 1 ; { code a; } else { code b; }
so you can write different code for zwo and three-Head-Signals
See Manual Chapter 10.15.6
#3
Posted 14 May 2019 - 07:56 AM
Those code snippets might be useful in the Manual, as I wasn't really sure how to use it.
Oh, and is that supposed to be a normal colon after HASHEAD(HEAD3)?
#4
Posted 14 May 2019 - 08:52 AM
ebnertra000, on 14 May 2019 - 07:56 AM, said:
Those code snippets might be useful in the Manual, as I wasn't really sure how to use it.
Oh, and is that supposed to be a normal colon after HASHEAD(HEAD3)?
No, semicolon as usual, It was an error, sorry.
I have not used this as multiple test, but I don't see a problem. As you have written, just separate floats.
You can use this feature also, if you need more then the four USER1...4 in this case you use a signalhead-name that doesn't exist in the shape.
#5
Posted 16 May 2019 - 02:49 AM
eugenR, on 14 May 2019 - 08:52 AM, said:
Correct - you can add 'flags' to a signal definition by defining an optional 'head', with SigSubType 'DECOR'. The head does not need to exist in the shape. A signal definition can have upto 32 heads, that's the maximum.
Here is an example of a banner repeater signal (light display, not semaphore), which has a set of options which define when the banner is to show the 'clear' aspect :
SignalShape ( "NF_Theatre_Banner.s" "NF Banner Light" SignalSubObjs ( 9 SignalSubObj ( 0 "HEAD1" "Signal" SigSubType ( SIGNAL_HEAD ) SignalFlags ( DEFAULT ) SigSubSType ( "NF_THEATRE_Banner_Clear" ) ) SignalSubObj ( 1 "HEAD2" "Signal" SigSubType ( SIGNAL_HEAD ) SignalFlags ( DEFAULT ) SigSubSType ( "NF_THEATRE_Banner_Stop" ) ) SignalSubObj ( 2 "USECL2" "Display on CLEAR_2" SigSubType ( DECOR ) SignalFlags ( DEFAULT OPTIONAL ) ) SignalSubObj ( 3 "USECL1" "Display on CLEAR_1" SigSubType ( DECOR ) SignalFlags ( DEFAULT OPTIONAL ) ) SignalSubObj ( 4 "USEAP3" "Display on APPROACH_3" SigSubType ( DECOR ) SignalFlags ( DEFAULT OPTIONAL ) ) SignalSubObj ( 5 "USEAP2" "Display on APPROACH_2" SigSubType ( DECOR ) SignalFlags ( DEFAULT OPTIONAL ) ) SignalSubObj ( 6 "USEAP1" "Display on APPROACH_1" SigSubType ( DECOR ) SignalFlags ( DEFAULT OPTIONAL ) ) SignalSubObj ( 7 "USERES" "Display on RESTRICTING" SigSubType ( DECOR ) SignalFlags ( OPTIONAL ) ) SignalSubObj ( 8 "USESPR" "Display on STOP_AND_PROCEED" SigSubType ( DECOR ) SignalFlags ( OPTIONAL ) ) ) )
The two signaltypes defined in this shape, share the same script with just the display state reversed :
SignalType ( "NF_THEATRE_BANNER_CLEAR" SignalFnType ( INFO ) SignalLightTex ( "tb-banner-clear-ltex" ) ORTSScript ( NF_BANNER_LIGHT ) SignalLights ( 1 SignalLight ( 0 "White Light" Position ( 0 0.405 0.1 ) Radius ( 0.38 ) ) ) SignalDrawStates ( 2 SignalDrawState ( 0 "Blank" ) SignalDrawState ( 1 "Show" Drawlights ( 1 DrawLight ( 0 ) ) ) ) SignalAspects ( 0 ) ) SignalType ( "NF_THEATRE_BANNER_STOP" SignalFnType ( INFO ) SignalLightTex ( "tb-banner-stop-ltex" ) ORTSScript ( NF_BANNER_LIGHT ) SignalLights ( 1 SignalLight ( 0 "White Light" Position ( 0 0.405 0.1 ) Radius ( 0.38 ) ) ) SignalDrawStates ( 2 SignalDrawState ( 0 "Show" Drawlights ( 1 DrawLight ( 0 ) ) ) SignalDrawState ( 1 "Blank" ) ) SignalAspects ( 0 ) )
And this the related script :
SCRIPT NF_BANNER_LIGHT // Banner Repeater Light General Script extern float route_set (); extern float next_sig_lr (); extern float draw_state; float routevalid; float nextstate; // Draw state : // 0 : not shown // 1 : shown // // No signal aspects // // User flags : // // 2 : USECL2 : display on CLEAR_2 // 3 : USECL1 : display on CLEAR_1 // 4 : USEAP3 : display on APPROACH_3 // 5 : USEAP2 : display on APPROACH_2 // 6 : USEAP1 : display on APPROACH_1 // 7 : USERES : display on RESTRICTING // 8 : USESPR : display on STOP_AND_PROCEED // Set default to no display draw_state = 0; nextstate = next_sig_lr(SIGFN_NORMAL); // set on next aspect if (hashead(2) && nextstate ==# SIGASP_CLEAR_2) { draw_state = 1; } if (hashead(3) && nextstate ==# SIGASP_CLEAR_1) { draw_state = 1; } if (hashead(4) && nextstate ==# SIGASP_APPROACH_3) { draw_state = 1; } if (hashead(5) && nextstate ==# SIGASP_APPROACH_2) { draw_state = 1; } if (hashead(6) && nextstate ==# SIGASP_APPROACH_1) { draw_state = 1; } if (hashead(7) && nextstate ==# SIGASP_RESTRICTING) { draw_state = 1; } if (hashead(8) && nextstate ==# SIGASP_STOP_AND_PROCEED) { draw_state = 1; }
Hope this helps,
Rob Roeterdink
#6
Posted 16 May 2019 - 03:29 AM
I'll have to try that method when I get home. The log keeps telling me HEAD6 is an invalid parameter, and not showing what it's supposed to. I probably messed up in how I used it
#7
Posted 16 May 2019 - 04:12 AM
In your example the function HASHEAD( ) has a number instead of the name of the SignalSubObj:
if (hashead(2) && nextstate ==# SIGASP_CLEAR_2)
Is this the number of the SignalSubObj?
can I use in the Function both, number or Name?
Regards
Eugen
#8
Posted 16 May 2019 - 04:21 AM
I have always used it with numbers only.
Regards,
Rob Roeterdink
#9
Posted 16 May 2019 - 05:17 AM
ebnertra000, on 16 May 2019 - 03:29 AM, said:
I'll have to try that method when I get home. The log keeps telling me HEAD6 is an invalid parameter, and not showing what it's supposed to. I probably messed up in how I used it
In the Manual Chapter 10.15.6 the function is defined with Headname:
state = HASHEAD(headname)
In my signalfile it works with a Headname, but the Headname is existimg in the shape.
regards
Eugen
#10
Posted 16 May 2019 - 06:38 AM