Scripts / Lights flashing red and blue? (Siren)

Author
Message
Johno 15
GameGuru TGC Backer
10
Years of Service
User Offline
Joined: 25th Aug 2014
Location: Cork, Ireland
Posted: 1st Dec 2015 21:41
Name says it all I suppose.I've got a police car and was wondering if it were possible for it to have flashing blue/Red lights, I have no idea about LUA ultimately and have no idea how to do something like this, would i use two lights alternating with a script or one light changing colour every second or so? I'm not even sure if it can be done in lua but then again Like i said, No idea
'Judge a man not by his answers. But by his questions.'
Belidos
3D Media Maker
9
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 2nd Dec 2015 09:44 Edited at: 3rd Dec 2015 22:57
This in theory (can't test it as i'm at work) should do what you need. You need a red and a blue light source and the following two scripts.


Drop a red light source and apply the light_flash.lua script. It will flash on and off when you test it (you may want to adjust the time in line 7 but make sure both scripts have the same delay so they flash evenly)

light_flash.lua


Drop a red light source and apply the light_flash2.lua script. It will flash on and off when you test it (you may want to adjust the time in line 7, but make sure both scripts have the same delay so they flash evenly)

light_flash2.lua


Note: I may have added one too many end commands at the bottom of the script, so if it says there's an unexpected end command when you run it just delete the last end in each script.

I'm still learning LUA at the moment so I may be wrong, apologies in advance if it doesn't work, also there may be a way to do it in a single script and single light source by alternating colours instead of turning it on and off, but i'm not sure how to do that.
Johno 15
GameGuru TGC Backer
10
Years of Service
User Offline
Joined: 25th Aug 2014
Location: Cork, Ireland
Posted: 2nd Dec 2015 16:57
Thanks Belidos, Will give it a go now and let you know how i get on
'Judge a man not by his answers. But by his questions.'
Belidos
3D Media Maker
9
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 3rd Dec 2015 22:53 Edited at: 3rd Dec 2015 22:55
Not sure how you got on, but I had a chance to test this tonight and yeah I made a couple of mistakes in the second script, here's the fixed scripts:

light_flash.lua


light_flash2.lua


Here's a video of it working, it might not show yet it's still processing.

Attachments

Login to view attachments
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 3rd Dec 2015 23:01
why not give them the same script?
life\'s one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, AMD R9 200 series , directx 11
Belidos
3D Media Maker
9
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 3rd Dec 2015 23:20
Because they need to alternate, one scrip starts in the on state and one starts in the off state.

If that can be done with one script i'd love it if you could show me how, i'm still learning and I hunger for knowledge
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 4th Dec 2015 11:20
ah i didnt actually notice that but it's still fairly simple as you're already using arrays there's 2 quick ways, 1 is to set the entity number specifically in the init(e) part when setting 'on' state
i.e.
on[1] = 0
on[3] = 1
on[4] = 0
etc

or a more automated way is like this


now every time you place a light with that script it will have the opposite 'on' state to the previous light... much easier to place many lights now
life\'s one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, AMD R9 200 series , directx 11
Belidos
3D Media Maker
9
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 4th Dec 2015 12:32
That's great thanks Smallg, that would certainly be an easier way to do it.

I'm new to LUA so things like arrays and such are just vague background noise to me, i'm still getting to grips with the basics. At the moment i'm just learning about each command in a logical step by step way, and with luck i'll eventually be able to link those commands in more complicated ways to make scripts do more.

Login to post a reply

Server time is: 2025-01-01 05:43:27
Your offset time is: 2025-01-01 05:43:27