Train Order Board aspect scripts.

Feedback, questions, updates on current projects, you name it!
Trainboi
Posts: 197
Joined: Fri Jul 05, 2013 9:16 am

Train Order Board aspect scripts.

Postby Trainboi » Fri May 19, 2017 10:40 pm

Been messing about with this script a while now and I can't quite figure it out. Considering I've no idea what I'm doing, suggest whatever, but I'm specifically looking at or above the bold line. For the sake of keeping this short, I'm only posting from the start of the script to the end of my new section.

include "World.gs" //included this for world functions

include "Browser.gs" //included this for making browser elements


class trainorder isclass Industry
{
//standard scenery piece so im making this class MapObject

Soup mySoup;

int i;
//browser name

Browser info;

//operable animation values

float[] anim = new float[0];

//animation frame counts

float[] animFrame = new float[0];

//names of anims

int[] frame = GetMeshAnimationFrame();

Numbers[0] = 0;
Numbers[1] = 1;
Numbers[15] = 15;
Numbers[30] = 30;

string[] animName = new string[0];



bool AspectGreen = false;
bool AspectYellow = false;
bool AspectRed = true;

Asset m_coronaGreen, m_coronaYellow, m_coronaRed;

define int ASPECT_RED = 1;
define int ASPECT_YELLOW = 2;
define int ASPECT_GREEN = 3;
int m_signalAspects;


void ConfigureSignalAspects() {
switch (m_signalAspects) {
case ASPECT_GREEN:

AspectYellow = false;
AspectGreen = true;
AspectRed = false;

break;


case ASPECT_YELLOW:

AspectYellow = true;
AspectGreen = false;
AspectRed = false;

break;


case ASPECT_RED:
default:

AspectYellow = false;
AspectGreen = false;
AspectRed = true;

}
}

// ============================================================================
// Name: SigController
// Desc: Controls signal aspect
// ============================================================================


thread void SigController(void) {

if(frame = 1) {
SetFXCoronaTexture("light1", m_coronaRed);
SetFXCoronaTexture("light2", m_coronaRed);
}
else if(frame = 15) {
SetFXCoronaTexture("light1", m_coronaYellow);
SetFXCoronaTexture("light2", m_coronaYellow);
}
else if(frame = 30) {
SetFXCoronaTexture("light1", m_coronaGreen);
SetFXCoronaTexture("light2", m_coronaGreen);
}
else {
SetFXCoronaTexture("light1", null);
SetFXCoronaTexture("light2", null);
}

}

I know SigController can/does run because when I originally set it up it was arranged differently, and it did select all the correct coronas. That part seems to be fine. The problem is I need to get them to change - the signal is up(red) at frame 1, halfway(yellow) at frame 15, and down(green) at frame 30. Accordingly I've tried to set up so the script will pick up the animation frame and select the appropriate coronas, being null at all points in between. Unfortunately I'm currently getting a parse error reported on the bold line. Any suggestions, either for what is causing the parse error or whether or not this script will achieve what I want it to?

Pencil
Site Admin
Posts: 1224
Joined: Sat Oct 08, 2005 10:28 am
Location: Portland, Oregon

Re: Train Order Board aspect scripts.

Postby Pencil » Sat May 20, 2017 10:45 pm

GetMeshAnimationFrame takes a parameter (the name of the mesh with the animation), right?

What are you trying to do with the script?

Trainboi
Posts: 197
Joined: Fri Jul 05, 2013 9:16 am

Re: Train Order Board aspect scripts.

Postby Trainboi » Sun May 21, 2017 8:26 am

The object of the script is that at frame 1 (signal up) the signal is red, at frame 15 (signal midway) the light displays yellow, and at frame 30 (signal down) the light displays green.
I don't think I gave a specific mesh for the script to check...that's probably it. Will mess about with it and see how it goes.

*edit*

Okay, here we go. I am now getting a parse error at (bold) line 85. Once again, no idea why...

include "World.gs" //included this for world functions

include "Browser.gs" //included this for making browser elements


class trainorder isclass Industry
{
//standard scenery piece so im making this class MapObject

Soup mySoup;

int i;
//browser name

Browser info;

//operable animation values

float[] anim = new float[0];

//animation frame counts

float[] animFrame = new float[0];

//names of anims

int[] down = GetMeshAnimationFrame("anim1");

int[] up = GetMeshAnimationFrame("anim2");

string[] animName = new string[0];



bool AspectGreen = false;
bool AspectYellow = false;
bool AspectRed = true;

Asset m_coronaGreen, m_coronaYellow, m_coronaRed;

define int ASPECT_RED = 1;
define int ASPECT_YELLOW = 2;
define int ASPECT_GREEN = 3;
int m_signalAspects;


void ConfigureSignalAspects() {
switch (m_signalAspects) {
case ASPECT_GREEN:

AspectYellow = false;
AspectGreen = true;
AspectRed = false;

break;


case ASPECT_YELLOW:

AspectYellow = true;
AspectGreen = false;
AspectRed = false;

break;


case ASPECT_RED:
default:

AspectYellow = false;
AspectGreen = false;
AspectRed = true;

}
}

// ============================================================================
// Name: SigController
// Desc: Controls signal aspect
// ============================================================================


thread void SigController(void) {

if(down = 1) and (up = 1) {
SetFXCoronaTexture("light1", m_coronaRed);
SetFXCoronaTexture("light2", m_coronaRed);
}
else if(down = 1) and (up = 15) {
SetFXCoronaTexture("light1", m_coronaRed);
SetFXCoronaTexture("light2", m_coronaYellow);
}
else if(down = 1) and (up = 30) {
SetFXCoronaTexture("light1", m_coronaRed);
SetFXCoronaTexture("light2", m_coronaGreen);
}
else if(down = 15) and (up = 15) {
SetFXCoronaTexture("light1", m_coronaYellow);
SetFXCoronaTexture("light2", m_coronaYellow);
}
else if(down = 15) and (up = 1) {
SetFXCoronaTexture("light1", m_coronaYellow);
SetFXCoronaTexture("light2", m_coronaGreen);
}
else if(down = 15) and (up = 30) {
SetFXCoronaTexture("light1", m_coronaYellow);
SetFXCoronaTexture("light2", m_coronaGreen);
}
else if(down = 30) and (up = 30) {
SetFXCoronaTexture("light1", m_coronaGreen);
SetFXCoronaTexture("light2", m_coronaGreen);
}
else if(down = 30) and (up = 1) {
SetFXCoronaTexture("light1", m_coronaGreen);
SetFXCoronaTexture("light2", m_coronaRed);
}
else if(down = 30) and (up = 15) {
SetFXCoronaTexture("light1", m_coronaGreen);
SetFXCoronaTexture("light2", m_coronaYellow);
}
else {
SetFXCoronaTexture("light1", null);
SetFXCoronaTexture("light2", null);
}

}

Pencil
Site Admin
Posts: 1224
Joined: Sat Oct 08, 2005 10:28 am
Location: Portland, Oregon

Re: Train Order Board aspect scripts.

Postby Pencil » Mon May 22, 2017 7:37 pm

It almost seems like you might want to use an event file and listen for those messages ( http://online.ts2009.com/mediaWiki/inde ... nt_Message )?

Trainboi
Posts: 197
Joined: Fri Jul 05, 2013 9:16 am

Re: Train Order Board aspect scripts.

Postby Trainboi » Tue May 23, 2017 3:05 pm

I actually figured out an alternate solution, one which does not use coronas at all.
With a lighted texture behind it, the transparent signal aspect actually functions perfectly:
Image
Image
Image
Image
I like the look of them, although the aspect doesn't have the same nice high-visibility offered by most coronas. Still, most train order boards in Trainz don't have lighting at all, and this at least looks good with night mode...

NormHart
Posts: 251
Joined: Tue Nov 01, 2011 9:22 am
Location: Calistoga, California

Re: Train Order Board aspect scripts.

Postby NormHart » Tue May 23, 2017 7:40 pm

That looks great trainboi1!

Pencil
Site Admin
Posts: 1224
Joined: Sat Oct 08, 2005 10:28 am
Location: Portland, Oregon

Re: Train Order Board aspect scripts.

Postby Pencil » Tue May 23, 2017 7:42 pm

Yes, it does - nice job!

You could always try lod'ing the light, using a larger light mesh as you get farther away.....

Trainboi
Posts: 197
Joined: Fri Jul 05, 2013 9:16 am

Re: Train Order Board aspect scripts.

Postby Trainboi » Tue May 23, 2017 9:29 pm

Yes, it does - nice job!

You could always try lod'ing the light, using a larger light mesh as you get farther away.....
There's an idea...good one!

PacificCoastBorax99
Posts: 15
Joined: Sun Mar 01, 2015 3:03 pm

Re: Train Order Board aspect scripts.

Postby PacificCoastBorax99 » Tue Jun 13, 2017 12:36 pm

Nice depot you got there Trainboi! Is that a Southern Pacific Standard type? Reminds me of the depot at Lone Pine...

Trainboi
Posts: 197
Joined: Fri Jul 05, 2013 9:16 am

Re: Train Order Board aspect scripts.

Postby Trainboi » Tue Jun 13, 2017 5:52 pm

It's a standard type CS-22. Lone Pine was one of the type, with hipped roofs, an extended first-floor waiting room, and an extended freight depot.


Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 3 guests

cron