Scripts / Flickering Light script?

Author
Message
3dMan
15
Years of Service
User Offline
Joined: 2nd Aug 2009
Location:
Posted: 1st Mar 2015 06:46
In FPSC classic we has 2 light script files called Light1 and Light2. Light2 was a flickering light effect. There is not one in GameGuru? How can that be accomplished with Lua? I need it for creepy effects.
PM
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 1st Mar 2015 12:45
you have 2 commands
ShowLight(e)
and
HideLight(e)

so use a timer and swap them at an interval like so (this will work with multiple lights - at a constant rate but you can uncomment the line at the bottom to make it more random)

Quote: "
local delay = {}
local init_delay = {}
local on = {}

function light_flicker_init(e)
--change time here to adjust flicker timing
delay[e] = 250
init_delay[e] = delay[e]
on[e] = 0

end

function light_flicker_main(e)

if GetTimer(e) > delay[e] then
if on[e] == 0 then
on[e] = 1
ShowLight(e)
else
on[e] = 0
HideLight(e)
end
delay[e] = GetTimer(e) + init_delay[e]
--to make more random use this line
--delay[e] = GetTimer(e) + math.random(100,1500)
end

end"
life\'s one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11
HarryWever
3D Media Maker
14
Years of Service
User Offline
Joined: 14th Jan 2010
Location: below Sea level
Posted: 1st Mar 2015 15:24
I tried this, but i get a error no function light_flicker_main(e).


Thanks

Harry
PM
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 1st Mar 2015 20:22
you have to make a script file called light_flicker.lua inside the scriptbank folder to copy that code into and then attach it to the lights you want to flicker
life\'s one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11
3dMan
15
Years of Service
User Offline
Joined: 2nd Aug 2009
Location:
Posted: 1st Mar 2015 20:37
Thanks. works great.

Harry, Your getting the error because you don't have the right name before the "init" and "main". They must be the same name as your filename. Example: if your file name is light2.lua, then change these within the file... light2_init(e) and light2_main(e).

PM
HarryWever
3D Media Maker
14
Years of Service
User Offline
Joined: 14th Jan 2010
Location: below Sea level
Posted: 1st Mar 2015 20:39
Ahhhhh thank you 3dman.. i Always have these problems, but now i know why..it must be the same name as the function.

Thanks now it works perfectly.

Cheers

Harry
PM

Login to post a reply

Server time is: 2024-12-21 14:52:21
Your offset time is: 2024-12-21 14:52:21