scefhwil wrote:davveb wrote:There's a new method SendConsistMessage, which works just like the signal messaging calls, but instead of sending messages along the track to the next signal the messages are sent along the train to the next wagon.
Dave,
A check in the Wiki doesn't reveal any info on this new function. Can you post the correct syntax for using it please?
Stuart
Well I don't know about correct

, but the following seems to work:
Call( "SendConsistMessage", msg, argument, direction )
Where msg is a unique index number, argument is a string containing your data, and direction indicates which way the message is to be sent, 1 from the rear of the unit, 0 from the front.
To receive a message in another unit you must define a function:
function OnConsistMessage ( msg, argument, direction )
-- Your code.
end
in the engine lua script file. This will ensure it works for both player and AI trains. If the message needs to be forwarded along the train then include another Call( "SendConsistMessage", msg, argument, direction ) within the above function.
You will also need some way to distiguish the engine being driven by the player from other engines in the consist. I use an engine blueprint control which is set from the simulation lua script. As this script only runs for the player's unit this provides suitable identification.