Simple Train Demostration Scene

About Truespace Archives

These pages are a copy of the official truespace forums prior to their removal somewhere around 2011.

They are retained here for archive purposes only.

Simple Train Demostration Scene // Scriptorium

1  |  

Post by Shell1850 // Nov 23, 2008, 4:38pm

Shell1850
Total Posts: 13
I create s simple model train control program using jScript Function Set and jScript arrays.


To make it work, click on a track and then click on the Timer Event.


There are 2 Types of track layout in this demonstration. "Load 8 Seg Track" and "Load 4 Seg Track".


Of course there is no track but the 4 boxes move as if there is one.

Post by frootee // Nov 23, 2008, 4:54pm

frootee
Total Posts: 2667
pic
Now That's Cool Shell!


Perfect timing too! You know it's Christmas Time and Model Trains play a big

part in the Holidays! :)


Well Done!


Froo

Post by Shell1850 // Nov 24, 2008, 6:34am

Shell1850
Total Posts: 13
I fixed a several problems with this scene. I added a speed control a "Load from File" brick. The speed control has a dead spot in the center position. Move it to the right to go forward and move it to the left for reverse.


The "Load From File" uses the Test1.txt file. Set the Directory to the location of the text file.

Post by frootee // Nov 24, 2008, 7:03am

frootee
Total Posts: 2667
pic
Are you planning on adding a town, complete with trees and buildings? That would look really cool!

Post by Norm // Nov 24, 2008, 7:33am

Norm
Total Posts: 862
pic
Oh wow! Is this ever neat. :jumpy:

We have new toy for Tuesday Nite Scriptor meet!!!

Post by frootee // Nov 24, 2008, 8:03am

frootee
Total Posts: 2667
pic
Hey you could add a Proximity Sensor where a road would cross the tracks... and have some of those railroad guards to keep cars from crossing...


the guards are normally up, but when the train gets close to the crossing (when the train reaches the proximity radius of the sensor), the guards are scripted to rotate and come down; i.e. they rotate 90 degrees.


A second sensor would be required, on the other side of the crossing, to raise the guards. Cool.

Post by frootee // Nov 24, 2008, 8:26am

frootee
Total Posts: 2667
pic
I was looking at the StreetLampAuto example in the Activities - My Activities library. This uses a proximity sensor, but also uses a timer. Timers are still troublesome in shared space, so I figure, it may be worth while to use a Watchdog Event in lieu of the timer. Since the train is always moving, it's position is always changing. which means the proximity sensor would be continuously triggered without the use of a timer. Unless the watchdog event itself uses a timer internally.


In which case, the timer could be replaced with a Paused Activity Loop, which seems to be more efficient in shared space.


Just some thoughts.

Post by trueBlue // Nov 24, 2008, 8:30am

trueBlue
Total Posts: 1761
pic
Very outstanding bunch of scripting there Shell1850.
I noticed in your Track Desc you wrote System.ThisOwner and you are missing the () at the end of the command. IE should be System.ThisOwner()
I modified your Load From File script and added a Open File Control just to show how it could be done. HTH

Post by Norm // Nov 24, 2008, 8:56am

Norm
Total Posts: 862
pic
I would suggest the watchdog not needed:

Create an array of location values
Real railroads embed proximity sensor in tracks.
one element of array is preprogrammed with the location train must be in for the gates to begin their protection sequence.
final car in train passes by the end of detection area and the gates go back up.
Each crossing would have a pair of these numbers in the array.
as the track becomes more complex, the array is updated with new location values for next crossing lights.
I was looking at the StreetLampAuto example in the Activities - My Activities library. This uses a proximity sensor, but also uses a timer. Timers are still troublesome in shared space, so I figure, it may be worth while to use a Watchdog Event in lieu of the timer. Since the train is always moving, it's position is always changing. which means the proximity sensor would be continuously triggered without the use of a timer. Unless the watchdog event itself uses a timer internally.

In which case, the timer could be replaced with a Paused Activity Loop, which seems to be more efficient in shared space.

Just some thoughts.

Post by frootee // Nov 24, 2008, 9:50am

frootee
Total Posts: 2667
pic
Hm I was thinking the example referenced uses a Proximity sensor but it does not. That's why I referenced the timer and watchdog.


So, does a proximity sensor run continuously?

Post by Shell1850 // Nov 24, 2008, 9:54am

Shell1850
Total Posts: 13
Thanks trueBlue for the inproved LoadFromFile object. I will have to study it.


I plan to add buildings, a bridge and maybe some railroad guards. Now I have something working, I can add to it.


I was looking at removing SegmentStart of the TrackDescription. I Just have to Add the SegmentLength to get the SegmentLength.


I am going to visit my mom tomorrow. I will get back to it next week.

Post by Norm // Nov 25, 2008, 5:05am

Norm
Total Posts: 862
pic
I was figuring the movement of train into the circuit would trigger the gates. You could do with proximity sensor but then using timer and such adds to cpu activity.

Hm I was thinking the example referenced uses a Proximity sensor but it does not. That's why I referenced the timer and watchdog.

So, does a proximity sensor run continuously?

Post by Shell1850 // Dec 13, 2008, 10:50am

Shell1850
Total Posts: 13
I have updated my basic train layout. I have included switch track and added a crossing guard.


Click on the Reset several times. Set on POWER ON. Use the Reverse control or Forward control to the speed of the train.


I hope you enjoy it.
Awportals.com is a privately held community resource website dedicated to Active Worlds.
Copyright (c) Mark Randall 2006 - 2024. All Rights Reserved.
Awportals.com   ·   ProLibraries Live   ·   Twitter   ·   LinkedIn