As some ones of you know, I am working in sway motion for vehicles. I need to trigger some movements in the precise moment when train is passing a junction.
Does anybody have any idea to get this data inside of the simulation or engine script?
I have tried with:
1.-JunctionCount Control, It is used to trigger joint sounds -- It doesn't work.
2.- Call( "GetConnectedLink", distance of searching, 1, 0 ) setting the first parameter at 5 meters and waiting for 1 or -1 --- It doesn't work.
I hope anybody can help me.
Thanks in advance.
Regards.
The man who doesn't follow his vocation betrays himself and condemns himself to unhappiness.
I would explore the JunctionCount Control. Not that I have any idea about it. But when you say "It is used to trigger joint sounds", then I think "just modify the animation instead of activating a sound". But I don't know anything about controls in general, it is just my guess.
The Call( "GetConnectedLink", distance of searching, 1, 0 ) is for signal scripts. "distance of searching" is a dummy parameter which is no more used. You can use "5", to be compatible with the default scripts. Note that it must be a string. Anyway, it does not help you.
What you could do, if the JunctionCount Control does not help you, is this (complex) idea: You create a signal object, which is does nothing regarding signalling (just passing on all the messages), but when the train passes it, it sends a message to the train. That way, the route builder must place such objects wherever he wants the train to say "junction-like".
Sending the message is done by this (in the signal script of the sender object):
Call ( "SendConsistMessage", SIGMSG_CUSTOM, "argument" )
This must be contained in function OnConsistPass, the sending is done from the "current" link, thus not supplied as an argument.
"argument" will be "", unless you want to communicate different cases of swaying (e.g., switch to the left, switch to the right).
The engine script must contain a function OnCustomSignalMessage where it does whatever needs to be done on receiving such a message.
However, I would first spend a lot of energy on this JunctionCount control, to be honest. But I never tried engine scripting myself.
I still don't know why I can not get any value from JunctionCount control inside the engine script.
If I use the ControlExist function then I get a value = true, but if I use GetControlValue then value always is NIL.
The same issue happen with AbsoluteSpeed control, to set or trigger sounds and its curves of volume or pitch, this control works perfectly, but it doesn't give any value in engine script so I need use other resources like SpeedoMeter or GetSpeed to get values for speed parameters.
Your idea about to put one kind of signal sending "consist messages" in each junction is a very good idea but a bit unpractical. To feel the effect, you would need to have these signals in each route where you want to use the vehicule.
I would not discard that idea so fast, but obviously that will be the last resource to use.
I will follow searching.
Thanks again.
Regards.
The man who doesn't follow his vocation betrays himself and condemns himself to unhappiness.
I know nothing of track and signals, all my work has been with engine lua's so this may not be relevant at all.
When checking boiler pressure for example, it not just a one time call as the value is always altering, like wise I would suggest that the engine with respect to the track is also constantly altering so a single call will only return a value for that period in time and won't alter until another call is made.
Have you tried putting your call to check for a junction within a function such as..
function (time)
make your call here
Jump to your sway routine here
end
Obviously this is vastly simplified to the code you need but the point is that it will return a value dependant on the engine/track status.