Building and scripting signals

Discussion about RailWorks route design.

Building and scripting signals

Unread postby SAR704 » Mon May 20, 2019 8:13 am

Has anybody from here ever made their own custom signals and scripted them? It looks as complex as C programming to me. But the main annoyance is not knowing how to set the signals up in 3D Crafter 8.

An example of what I mean is that with lofts, you have to have the axis at one end of it. With the signals, and levers (the ones I want in the game are Semaphore signals), it doesn't mention where to position the axis, what shaders are needed. It essentially seems like training a pilot to fly a 747 under the impression that they have flown a plane before, when actually they haven't.

There is an explanation of the scripts on the web at railsimdev.com, but this is assuming that you have prior knowledge of how to set them up. I have never done an animated object for TS before, so it makes it more mystifying. I only need about 6 or so different signals for my route, but it feels like there are days/weeks of trial and error before I even get close to getting one to work.

Given the age of TS, it seems to devalue the worthiness of figuring out the whole process. I an not sure how many folks here actually still tackle these highly advanced projects in TS, but I am curious as to whether or not somebody here has successfully built their own signals from the ground up or not.

Thanks in advance.
Geforce GTX 1060
16GB RAM
Intel Core i5-3350 3.10ghz
Win te(n) Home
SAR704
 
Posts: 716
Joined: Tue Jun 21, 2011 9:48 am
Location: Adelaide, South Australia

Re: Building and scripting signals

Unread postby buzz456 » Mon May 20, 2019 8:54 am

The question is why do you want to do this?
Buzz
39 and holding.
"Some people find fault like there's a reward for it."- Zig Ziglar
"If you can dream it you can do it."- Walt Disney
Image
User avatar
buzz456
Site Admin
 
Posts: 20938
Joined: Sun Mar 21, 2010 8:30 am
Location: SW Florida

Re: Building and scripting signals

Unread postby SAR704 » Mon May 20, 2019 10:27 am

Because I want to use prototypical signals for my own route, and it will give me an understanding of how to set them up, for future reference. I have an SAR 3 arm signal built, but where to go from here is still a mystery.
Geforce GTX 1060
16GB RAM
Intel Core i5-3350 3.10ghz
Win te(n) Home
SAR704
 
Posts: 716
Joined: Tue Jun 21, 2011 9:48 am
Location: Adelaide, South Australia

Re: Building and scripting signals

Unread postby Sacredd » Mon Jul 13, 2020 2:11 am

SAR704 wrote:Has anybody from here ever made their own custom signals and scripted them? It looks as complex as C programming to me. But the main annoyance is not knowing how to set the signals up in 3D Crafter 8.

An example of what I mean is that with lofts, you have to have the axis at one end of it. With the signals, and levers (the ones I want in the game are Semaphore signals), it doesn't mention where to position the axis, what shaders are needed. It essentially seems like training a pilot to fly a 747 under the impression that they have flown a plane before, when actually they haven't.

There is an explanation of the scripts on the web at railsimdev.com, but this is assuming that you have prior knowledge of how to set them up. I have never done an animated object for TS before, so it makes it more mystifying. I only need about 6 or so different signals for my route, but it feels like there are days/weeks of trial and error before I even get close to getting one to work.

Given the age of TS, it seems to devalue the worthiness of figuring out the whole process. I an not sure how many folks here actually still tackle these highly advanced projects in TS, but I am curious as to whether or not somebody here has successfully built their own signals from the ground up or not.

Thanks in advance.



Hi Sir.Even i want to make custom signals for a route.Did not find proper sources for it.Did you get the sources now on how to make those signals
Sacredd
 

Re: Building and scripting signals

Unread postby savv_nz » Sat Oct 10, 2020 12:00 am

With 3dC make your signal as you would any other object, pivot locations (except the root object being at 0,0,0 so it isn’t in the ground when you place it) isn’t Important. Export each of your semaphores arms animations independently (ie, you select the root object, rodding, arm for one semaphore, then export that animation. Then repeat for the next one etc). You then export the signal object itself as one object. For a three arm semaphore you should have 1x IGS and 3x IA files exported.

You can then call the individual animations in the script after adding them to the animation portion of the signal blueprint. Ie, animation name: arm1 then the path of the ia file in the other field (name escapes me right now) repeat for all 3 arms. You would need to set the blueprint to have 3 links.(one for each arm)

Then it’s scripting time....
Cheers,

Stefan van Vliet

TSNZ Webmaster http://www.tsnz.co.nz
NZTS Workshops Co-Founder
TSNZ Discord https://discord.gg/RD6MsgM
savv_nz
 
Posts: 64
Joined: Sun Feb 22, 2009 7:52 am

Re: Building and scripting signals

Unread postby SAR704 » Sun Oct 11, 2020 4:02 am

The scripting is complex to me. It's like I want to build a cargo ship engine. But that initiates the questions of what I need to start with, what I'm aiming for etc. I am not sure which values will have xxx effect on another.

It's like a randomised assortment to me that I need to neatly arrange with no idea of what goes up front.

I wish that there was a highly comprehensive scripting guide that could make sense of every command, where to put it, the hierarchy, the result of entering values that can't be read. With a 3d model, you know where to continue. With scripting, it's like walking through a maze with a blindfold.

Just my thoughts re the whole concept, and the lack of detail about such that is not by any means your fault savv_nz.
Geforce GTX 1060
16GB RAM
Intel Core i5-3350 3.10ghz
Win te(n) Home
SAR704
 
Posts: 716
Joined: Tue Jun 21, 2011 9:48 am
Location: Adelaide, South Australia

Re: Building and scripting signals

Unread postby savv_nz » Mon Oct 12, 2020 6:45 pm

I have just completed a project that has two unique signalling systems within it, both of which had to be scripted from scratch in lua. I will get my signalling man to drop into this thread... as for a clear guide, there isn’t one, most of it is a complete mystery and has to be figured out as you go along if our experience is anything to go by.

A semaphore system, should be much less complex that the two colour light systems required by our project however, so there is possibly some hope.
Cheers,

Stefan van Vliet

TSNZ Webmaster http://www.tsnz.co.nz
NZTS Workshops Co-Founder
TSNZ Discord https://discord.gg/RD6MsgM
savv_nz
 
Posts: 64
Joined: Sun Feb 22, 2009 7:52 am

Re: Building and scripting signals

Unread postby GibbseyNZ » Tue Oct 13, 2020 3:36 am

This way be dragons. Its a lot of work, but is worth it in the end.
I have recently finished the scripting for 2 different colour light systems. The route I have been working on has 2 different systems and being the stickler for realism, both are scripted to operate as close to the real ones as possible.
The signal scripting has a lot of powerful stuff you can do with it once you get your head around it though, but it took me a long time to get the signals for our route done.
There are certain functions that the script needs to have, and then after that you can add whatever you want inside those functions or functions called from within those core functions.
And yes, the "days/weeks of trial and error" to get them right quickly turns into months, especially in our case.
I have never created 3d objects for export to the game, but I have done all the signal scripting and blueprints. Most of the signals I did were 3 aspect color light signals but there was 1 animated signal which was a points indicator so have a little experiance with that as well.
I initially tried adapting the UK 3 colour light signal scripts but found that so much of it was written for different use cases and modularity that it made adapting it for my needs hard. Plus, like you, I had no idea what was needed and how the system worked as a whole. So I ended up starting from scratch and building it up, but by bit, testing as I went and eventually got the 2 working systems I have now.

These were the 2 most useful references I have found. That and looking at the scripts for the Kuju UK colour light signals.
https://sites.google.com/a/railsimdev.c ... -reference
https://sites.google.com/a/railsimdev.c ... signalling

I have been meaning to try and write a signals reference document with all the info I have learnt from the scripting and some examples of different useful tasks, like the basic steps required for an animated object on a signal or how to detect trains. Possibly the largest part of some of my scripts and the most complex is the function that reacts to recieving a signal message from another signal to know what state the next signal is in or when a train has entered the block the signal protects.
GibbseyNZ
 

Re: Building and scripting signals

Unread postby SAR704 » Wed Oct 14, 2020 12:38 am

@GibbseyNZ

That sounds good. Despite TS's age, it would be great to see a tutorial on signal creation. If you don't mind me asking, how complex would it be to create a signal like this, but with 3 arms? Being semaphore types, I suspect that they're not as complex. I use 3d Crafter to export, and TSM to build the base model.

I have no idea of what values I need to export them with, and this is before the scripting fun.

img116.jpg
You do not have the required permissions to view the files attached to this post.
Geforce GTX 1060
16GB RAM
Intel Core i5-3350 3.10ghz
Win te(n) Home
SAR704
 
Posts: 716
Joined: Tue Jun 21, 2011 9:48 am
Location: Adelaide, South Australia

Re: Building and scripting signals

Unread postby savv_nz » Wed Oct 14, 2020 5:55 am

SAR704 wrote:
I have no idea of what values I need to export them with, and this is before the scripting fun.



See my description above, I made the models and GibbseyNZ did the scripting. There is nothing special about naming or anything, as long as you know what you called the various bits (like light glows, red1, red2, red3 for example) you can reference them in the script and, of course, that you export the animation for each arm seperately.

GibbseyNZ Will confirm, but I suspect it needs to then be exported with 3 links referenced in the blueprint, one for each arm, and then it’s time to script.
Cheers,

Stefan van Vliet

TSNZ Webmaster http://www.tsnz.co.nz
NZTS Workshops Co-Founder
TSNZ Discord https://discord.gg/RD6MsgM
savv_nz
 
Posts: 64
Joined: Sun Feb 22, 2009 7:52 am

Re: Building and scripting signals

Unread postby SAR704 » Wed Oct 14, 2020 8:42 am

I would be very interested to know how GibbseyNZ actually scripted the signals. i think that once I start to understand the basics, I might be able to get the hang of it, and not have to rely on UK signals. If he is willing to outline how it's done, it would be greatly appreciated.

But what about semaphore signals? I gather that the arms have to have the axis at the pivot point (where it rotates). But it's positioning relative to the signal structure itself is irrelevant I assume. IE, it can rotate in thin air right?
Geforce GTX 1060
16GB RAM
Intel Core i5-3350 3.10ghz
Win te(n) Home
SAR704
 
Posts: 716
Joined: Tue Jun 21, 2011 9:48 am
Location: Adelaide, South Australia

Re: Building and scripting signals

Unread postby savv_nz » Wed Oct 14, 2020 7:50 pm

SAR704 wrote:But what about semaphore signals? I gather that the arms have to have the axis at the pivot point (where it rotates). But it's positioning relative to the signal structure itself is irrelevant I assume. IE, it can rotate in thin air right?


Yep, where you place your pivot points is of no concern to the sim, excepting that of the root object (which needs to be at the base of the object so its sits on the ground).
Cheers,

Stefan van Vliet

TSNZ Webmaster http://www.tsnz.co.nz
NZTS Workshops Co-Founder
TSNZ Discord https://discord.gg/RD6MsgM
savv_nz
 
Posts: 64
Joined: Sun Feb 22, 2009 7:52 am

Re: Building and scripting signals

Unread postby GibbseyNZ » Thu Oct 15, 2020 4:07 am

Definately willing to offer as much help as I can. I am a bit busy with work at the moment so might be able to start writting something up in about a week.
As Savv says, when you export the model you need to know the light glow names to turn them on or off from teh script, and also need to know the arm animation names and their animation times, as in the script you run an update function and it moves the animation based on how long the update has taken since the last update, so if it takes 0.05sec between updates, it updates the animation to the position it should be.
The main things are (names not exact but give an idea of whats needed) :
Global Variables - at start of script to define variables used and things like the numbers associated with each signal message, signal states and animation times
Initialise function - initialisations the signal on route load, or when it recieves a signal reset message
Update function - runs after initialisation, or when an animation is running
Junction State change - called when signal recieves a message to say the junction ahead has changed
getSignalState - returns the current state of the signal, this is called when it recieves a message from another signal asking what the signals state is (such as a distant signal checking the state of the home signal ahead)
reacttosignalMessage - called when signal recieves a message. this message could be reset to initialise it, a state message from teh next signal along the line, from a junction, or from a loco
determinesignalstate - called when certain messages are recieved and determines what the state of the signal should be. semaphores are fairly easy. Distants are either green or yellow (clear or warning) and each home signal head is either green or red (clear or blocked). Also calls the update function if the signal state is changed to animate the signal arms
setlights - sets the light glows that are on or off based on the signal state

I think thats most of the main functions. Inside that is a lot of if/else statements to check various states of variables.
It is quite powerful, and you can do lots of fancy things if you code them in. For example I have coded it so that the light colour doesnt change straight away. when a train passes a signal is changes to blank with all lights off for a short period of time before the red comes up. This is to make it look more like the prototype which can have a short delay between the light colour changing (like 1 second). It also helps to make it look more like the fade out and fade in that older incandecent bulbs had.
But you can do lots of things, like check how far from teh signal a train is,and what speed its doing. This is used by some of the signals I scripted as a stop and proceed signal, where if its red you have to stop within 50m of the signal for 10 seconds, then you are allowed to proceed past the signal at a slow speed and I was able to achieve that in the game by checking the distance of the train to the signal and the speed its going. If distance < 50 and speed < 1 then start timer, sort of thing.
GibbseyNZ
 

Reply

Unread postby RailRoadEngineer » Thu Oct 15, 2020 6:14 am

In the Developer Documentation > Signaling Function Reference, the following signaling functions are not included.
They are very useful in signal scripts!!

Call( "GetLinkApproachControl", LinkNumber ) - state of checkbox "approach control", 0 or 1

Call( "GetLinkLimitedToYellow", LinkNumber ) - state of checkbox "limited aspect", 0 or 1

Call( "GetLinkFeatherChar", LinkNumber ) - Contents of "Name of Route" field, integer (ASCII code, 1st char only)

Call( "GetLinkSpeedLimit", LinkNumber ) - Contents of "Speed of Route" field, integer

Call ( "GetId" ) - Contents of the ID field, string​
RailRoadEngineer
 
Posts: 49
Joined: Sun Sep 13, 2020 5:14 pm

Re: Building and scripting signals

Unread postby SAR704 » Thu Oct 15, 2020 6:41 am

Thanks for the information. But if GibbseyNZ could post a comprehensibe guide to the process, it would be almost revolutionary.

Basically, if I start with one entry, and get the hierachy incorrect followed by an hour or so of trying to script it, then it's a waste of time. Scripting sounds like getting every move correct in a game of chess against an expert. If you make one blunder, it's down the drain. Is there any margin for error with these scripts?

I know that it is common with some video games for scripts to be relied upon. I have no idea how loco set up and scripts work in the game. But if I could get a comprehensive understanding of this as well, I might even be able to get one working in game.
Geforce GTX 1060
16GB RAM
Intel Core i5-3350 3.10ghz
Win te(n) Home
SAR704
 
Posts: 716
Joined: Tue Jun 21, 2011 9:48 am
Location: Adelaide, South Australia

Next

Return to Route Design

Who is online

Users browsing this forum: No registered users and 3 guests