Need help with scripting...

Discussion of rolling-stock creation & re-painting.

Need help with scripting...

Unread postby MadMike1024 » Thu Dec 15, 2011 3:18 pm

PapaExpress has created a xenon beacon for the GP15. He and I hacked away at it until we actually have them flashing from a timer in the .lua file. The lights look great, but I'd like to include a point_light glow to enhance the appearance. Positioning the lightglow and the color are done, now I need to know if it is possible to activate it from the .lua animation. Can anyone help us out here?
MadMike1024
Global Mod
 
Posts: 1730
Joined: Fri Jul 30, 2010 8:11 pm
Location: Vancouver, WA

Re: Need help with scripting...

Unread postby MadMike1024 » Thu Dec 15, 2011 4:11 pm

MadMike1024 wrote:PapaExpress has created a xenon beacon for the GP15. He and I hacked away at it until we actually have them flashing from a timer in the .lua file. The lights look great, but I'd like to include a point_light glow to enhance the appearance. Positioning the lightglow and the color are done, now I need to know if it is possible to activate it from the .lua animation. Can anyone help us out here?


Ok, it can be done... Call("ChildName:Activate",True/False)

Image

The effect from a distance is striking... I have the snow SP GP38-2 beaconed up as well.... hopefully by Christmas...
MadMike1024
Global Mod
 
Posts: 1730
Joined: Fri Jul 30, 2010 8:11 pm
Location: Vancouver, WA

Re: Need help with scripting...

Unread postby PapaXpress » Thu Dec 15, 2011 4:16 pm

Now you got me wanting to get home, done with dinner, my son's performance at church, and stuff the boys in bed, so I can see what you did. *!greengrin!*
Image
"Just post some random unrelated text. We have members here who can help you with that." ~ Chacal
"When all else fails, read the instructions... if that doesn't work either, try following them." ~ Old Prof
Image
The Grade Crossing - Atlanta North Project - Virtual Rail Creations
User avatar
PapaXpress
 
Posts: 5147
Joined: Sat Oct 23, 2010 10:30 pm
Location: that "other" timezone

Re: Need help with scripting...

Unread postby Kali » Fri Dec 16, 2011 12:58 am

1/0 rather than true/false is the "official" way for calls afaik - I think you got a little lucky there :).
Kali
 
Posts: 1600
Joined: Mon Mar 14, 2011 1:00 am
Location: England-by-Sea

Re: Need help with scripting...

Unread postby MadMike1024 » Fri Dec 16, 2011 1:10 am

Kali wrote:1/0 rather than true/false is the "official" way for calls afaik - I think you got a little lucky there :).


When you set True=1 and False=0 it works fine... actually, the true/false was an example, what is actually there is the timer trigger variable.

the real result: Call("StrobeGlow1:Activate",Timer1).

There is a second strobe, so the is a StrobeGlow2 and a Timer2 as well. The result is nice, because there is a little bit of randomness in the .lua file processing time, keeping it slightly off. Interestingly the active lit element for the flasher lights a weensy bit sooner than the glow, and goes away slightly sooner so it looks proper.
MadMike1024
Global Mod
 
Posts: 1730
Joined: Fri Jul 30, 2010 8:11 pm
Location: Vancouver, WA

Re: Need help with scripting...

Unread postby Kali » Fri Dec 16, 2011 1:23 am

Ok - true/false are reserved words ( that obviously actually mean true or false ); I would stick to using 0 and 1 personally - maybe call them On/Off instead - just to keep things clear but I'm not writing your code :).

The randomness is the length of a frame in the game engine - you can get the frame length if you want as the parameter passed to Update(). Most RSC scripts seem to call it "time", but as that is another reserved word I've always used Interval ( in my variable naming scheme that's p_nInterval ) which is the length of time since the last frame in seconds. As you might expect there, it's a small fraction of a second.
Kali
 
Posts: 1600
Joined: Mon Mar 14, 2011 1:00 am
Location: England-by-Sea

Re: Need help with scripting...

Unread postby MadMike1024 » Sun Dec 18, 2011 3:05 am

Kali wrote:Ok - true/false are reserved words ( that obviously actually mean true or false ); I would stick to using 0 and 1 personally - maybe call them On/Off instead - just to keep things clear but I'm not writing your code :).

The randomness is the length of a frame in the game engine - you can get the frame length if you want as the parameter passed to Update(). Most RSC scripts seem to call it "time", but as that is another reserved word I've always used Interval ( in my variable naming scheme that's p_nInterval ) which is the length of time since the last frame in seconds. As you might expect there, it's a small fraction of a second.


I need a way to check and see if the engine is running. It doesn't make sense for the beacons to be flashing if the engine is down...
MadMike1024
Global Mod
 
Posts: 1730
Joined: Fri Jul 30, 2010 8:11 pm
Location: Vancouver, WA

Re: Need help with scripting...

Unread postby Kali » Sun Dec 18, 2011 3:16 am

Check the RPM control.
Kali
 
Posts: 1600
Joined: Mon Mar 14, 2011 1:00 am
Location: England-by-Sea

Re: Need help with scripting...

Unread postby MadMike1024 » Mon Dec 19, 2011 12:23 am

Kali wrote:Check the RPM control.


Does RPM return a 0 if the engine isn't running?
MadMike1024
Global Mod
 
Posts: 1730
Joined: Fri Jul 30, 2010 8:11 pm
Location: Vancouver, WA

Re: Need help with scripting...

Unread postby Kali » Mon Dec 19, 2011 4:40 am

Yep, it's simply the number in the RPM displays.
Kali
 
Posts: 1600
Joined: Mon Mar 14, 2011 1:00 am
Location: England-by-Sea

Re: Need help with scripting...

Unread postby PapaXpress » Mon Dec 19, 2011 1:38 pm

Mike and I worked it out last night. :D
Image
"Just post some random unrelated text. We have members here who can help you with that." ~ Chacal
"When all else fails, read the instructions... if that doesn't work either, try following them." ~ Old Prof
Image
The Grade Crossing - Atlanta North Project - Virtual Rail Creations
User avatar
PapaXpress
 
Posts: 5147
Joined: Sat Oct 23, 2010 10:30 pm
Location: that "other" timezone


Return to Rolling-Stock Design

Who is online

Users browsing this forum: No registered users and 2 guests