Scripts / Could use some help with thunder and lighting script

Author
Message
m2design
GameGuru TGC Backer
14
Years of Service
User Offline
Joined: 25th Mar 2010
Location:
Posted: 11th Jan 2016 22:34 Edited at: 12th Jan 2016 01:47
I have made several attempts to make a script that will simulate thunder and lighting. None of which have worked to my satisfaction.
When the player enters the trigger zone I need the player to freeze, turn on the light marker for say 5 seconds, turn off the light marker then play a thunder sound. When the thunder has dissipated unfreeze the player leaving the light marker off and then continue on his way. I will plan to place several entities around the map that will trigger this script for what will seem random.



Any help would be welcome.
Edit:
my latest attempt works except it needs a timer delay for the lights to stay on for a set time then turn off before the thunder happens.,
The latest attachment shows where I am... lacking the time delay
Can anyone help me with the delay .... I don't think I need to freeze the player any more.
Windows 10,64 bit|AMD FX-6200 Six-core-3.80 Ghz |CPU PASSMARK 6,142 |Memory 10GB |NVIDIA GEFORCE GTX 660 SC |GPU PASSMARK 4,114

Attachments

Login to view attachments
Pirate Myke
Forum Support
14
Years of Service
User Offline
Joined: 31st May 2010
Location: El Dorado, California
Posted: 12th Jan 2016 02:39
Try this. I commented inside the script where I added stuff.

Intel(R) Core(TM)2 Quad CPU Q6600 @ 2.40GHz, 2400 Mhz, 4 Core(s), 4 Logical Processor(s), 8gb RAM, Nvidia gtx660, Windows 7 Pro 64bit

m2design
GameGuru TGC Backer
14
Years of Service
User Offline
Joined: 25th Mar 2010
Location:
Posted: 12th Jan 2016 06:23
@ Pirate Myke
Thanks for the code.
The timer lines do not work. I think the timer function in 1.11 does not function. No matter what I try the timer refuses to start.
I remd out all of the code except that required to run the timer and no matter what it does not start. what you should be legit but...

If you get time maybe you could write a short script you can apply to an entity just to print a prompt after say 10 seconds. I tried to do just that using the code you gave and I can't make it work. When I did a search for timer I found on one of the posts using almost identical code with the same results.

Perhaps you run a test to see if the timer code really works or is it broken (Bug perhaps in beta 1.11)
I also tried a very similar timer code by smallg and it will not start either.
Windows 10,64 bit|AMD FX-6200 Six-core-3.80 Ghz |CPU PASSMARK 6,142 |Memory 10GB |NVIDIA GEFORCE GTX 660 SC |GPU PASSMARK 4,114
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 12th Jan 2016 11:55 Edited at: 12th Jan 2016 11:59
set this script on the lights and then change the setting to point to an entity that holds the thunder sound effect (as we can't add sounds to lights unfortunately)
note; you may want/need to set the sound entity always active

edit, timers work fine.
StartTimer(e) is a function that doesnt return a value but resets GetTimer(e) to 0 every time it is called.
GetTimer(e) is the function that actually returns the value.
you need to make sure StartTimer(e) is only called once otherwise GetTimer(e) will always be 0~1 and you can't use variable = StartTimer(e) but you can use variable = GetTimer(e)
life\'s one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, AMD R9 200 series , directx 11

Attachments

Login to view attachments
m2design
GameGuru TGC Backer
14
Years of Service
User Offline
Joined: 25th Mar 2010
Location:
Posted: 12th Jan 2016 21:25 Edited at: 13th Jan 2016 05:27
@smallg
Let me start by saying thank you for the script. I think I understand most of it. Lua drives me nuts with it's strange sequencing of command placement but I am slowly catching on.
Info: what I have is one light (entity no. 149) named thunder light to turn on and off. I have one trigger entity named burned wood laying on the beach
(entity number 159)
Problem: When the program starts there is an immediate flash (not sure about the flash) followed by a clap of thunder and the trigger entity (159) has vanished from the beach.



I have attached the current copy of your script which I am using noting a few revisions.

Edit : Solved the problem of the trigger vanishing. remarked the lines that hide the trigger (159) entity. Now the first time getting near the now visual trigger the thunder and lighting works just as I had envisioned.
The only thing is, the trigger entity will not function again beyond the first instance. See the video...

New edit @ 21:24 my time:
Believe it or not, I fixed it. Attached is the final script for your approval. Thank you for everything.
Windows 10,64 bit|AMD FX-6200 Six-core-3.80 Ghz |CPU PASSMARK 6,142 |Memory 10GB |NVIDIA GEFORCE GTX 660 SC |GPU PASSMARK 4,114

Attachments

Login to view attachments
Belidos
3D Media Maker
9
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 13th Jan 2016 10:44
looking really good, one suggestion I have for you, make the light source white with a very small amount of blue to get a more realistic flash.
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 13th Jan 2016 16:37 Edited at: 13th Jan 2016 16:38
it's because my script works on the lights, you place the lights as the trigger and then the flash will appear at the point of interest, rather than needing 1 very bright light that will light up the entire level you can set smaller lights at the player's position (there's only 1 extra entity which is used to store the sound file)
but glad you got it working as you wanted
life\'s one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, AMD R9 200 series , directx 11
m2design
GameGuru TGC Backer
14
Years of Service
User Offline
Joined: 25th Mar 2010
Location:
Posted: 13th Jan 2016 17:42
@ smallg
Thanks for the explanation. I understand. With a small modification to your lua script I can place 1 trigger entity where I choose and by changing the light entity number in the trigger script I can flash lighting and thunder anywhere the light happens to be without moving the trigger entity or placing a new one. In other words the light does not need to be where the player happens to be. From the stick of burned wood (the trigger on the beach) I can change the light entity number of a light placed far away and I am able to flash lightning over that location wherever the subject light is located on the map, not just at the players location which would be the burned wood.
Do you think it would be appropriate for me to post this video in a demo thread in the forum "script" section so others will be aware of the possibilities.
Or should it be posted in "work in progress". You sir are a joy to work with and a very patient and understanding one also.



@Belidos
Good suggestion, I added a little blue to the light, thanks
Windows 10,64 bit|AMD FX-6200 Six-core-3.80 Ghz |CPU PASSMARK 6,142 |Memory 10GB |NVIDIA GEFORCE GTX 660 SC |GPU PASSMARK 4,114
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 13th Jan 2016 19:30
no worries, with some adjustments on the trigger_boundary my script would do the same but like i said, it's merely using a slightly different method to get the same result, if it works (and it looks good from the video) than it's all fine
*the only modification i would make is to increase or remove this*
Quote: "if GetPlayerDistance(e) > trigger_boundry then
lightswitch[e] = -1
end"

because if you moved back and forth quickly over the trigger you will see the lightning repeat lots

and my script already repeats using this part
Quote: "elseif lightswitch[e] == 3 then
if repeating == 1 then
if GetPlayerDistance(e) > 2500 then
lightswitch[e] = 0
end
else
Destroy(e)-- not sure what this does
end"

if you wanted the reset range smaller just make the 2500 smaller (but higher than the trigger_boundary, maybe trigger_boudary*2)
life\'s one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, AMD R9 200 series , directx 11
m2design
GameGuru TGC Backer
14
Years of Service
User Offline
Joined: 25th Mar 2010
Location:
Posted: 14th Jan 2016 17:32
@smallg

I have taken your advise and removed my added lines of code and changed your reset range to trigger*2 and everything works just fine.
I have discovered that I can't manipulate any light that is beyond about 3000 units from the trigger entity, not a real problem but interesting.

I have also (Experimenting) realized I can control a cluster of lights by just adding multiple lights to the script. Makes for a little more dynamic flash.
Windows 10,64 bit|AMD FX-6200 Six-core-3.80 Ghz |CPU PASSMARK 6,142 |Memory 10GB |NVIDIA GEFORCE GTX 660 SC |GPU PASSMARK 4,114
Belidos
3D Media Maker
9
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 14th Jan 2016 17:39 Edited at: 15th Jan 2016 08:18
I think there is a limit of 3000 on activating entities, it's much like the lod system, to decrease the resource usage.
m2design
GameGuru TGC Backer
14
Years of Service
User Offline
Joined: 25th Mar 2010
Location:
Posted: 15th Jan 2016 01:57
@Belidos
Thanks for the info, kind of figured it was something like that. I's not a real problem, I can live with it. I was hoping to display a lightning flash out over the water off shore but no big deal for now.

Windows 10,64 bit|AMD FX-6200 Six-core-3.80 Ghz |CPU PASSMARK 6,142 |Memory 10GB |NVIDIA GEFORCE GTX 660 SC |GPU PASSMARK 4,114
R.E.Z.
9
Years of Service
User Offline
Joined: 9th Apr 2015
Location:
Posted: 24th Feb 2016 19:41 Edited at: 25th Feb 2016 18:49
Hello,

@ m2design
the lightning on command looks really great =)
Is it possible, to use the attached m2thunder_b.lua or m2thunder.lua script in my own levels?
Also for commercial use?
If I use it, which credits should I shown?

Regards,
R.E.Z.
PM
m2design
GameGuru TGC Backer
14
Years of Service
User Offline
Joined: 25th Mar 2010
Location:
Posted: 29th Feb 2016 17:50 Edited at: 29th Feb 2016 18:22
@R.E.Z
As you might gather from the full thread, the scripts you wish to use were created with assistance.
The scripts were written with the knowledge by all participants that the scripts were public.
I have no problem with your using the scripts in any manner you wish. I can not speak for others involved, as to credits, I require none and prefer none.
Good luck.
Edit:
m2thunder_b.lua is the final. You will need to revise a couple of variables used in the script to make it work.
You will need to revise the trigger entity number and the light entity number to the numbers of the entities you use.
Windows 10,64 bit|AMD FX-6200 Six-core-3.80 Ghz |CPU PASSMARK 6,142 |Memory 10GB |NVIDIA GEFORCE GTX 660 SC |GPU PASSMARK 4,114

Attachments

Login to view attachments
R.E.Z.
9
Years of Service
User Offline
Joined: 9th Apr 2015
Location:
Posted: 29th Feb 2016 18:18 Edited at: 29th Feb 2016 18:42
@ m2design
Thank You for Your answer

Edit: And Thank You for explaining about the adjustments and changes to make

C.U. R.E.Z.
PM
Pirate Myke
Forum Support
14
Years of Service
User Offline
Joined: 31st May 2010
Location: El Dorado, California
Posted: 29th Feb 2016 19:43
I have no issue with you using the script as you like either. That what these threads are for.
I get to learn and you get to learn.

Win, win.
Intel(R) Core(TM)2 Quad CPU Q6600 @ 2.40GHz, 2400 Mhz, 4 Core(s), 4 Logical Processor(s), 8gb RAM, Nvidia gtx660, Windows 7 Pro 64bit, Screen resolution 1680 x 1050.

R.E.Z.
9
Years of Service
User Offline
Joined: 9th Apr 2015
Location:
Posted: 29th Feb 2016 21:28
Hello,

@ Pirate Myke:
Thank You
Yes, Win, win

C.U. R.E.Z.
PM
m2design
GameGuru TGC Backer
14
Years of Service
User Offline
Joined: 25th Mar 2010
Location:
Posted: 29th Feb 2016 21:56
@R.E.Z.
Be aware you will need to provide a "Wav" file for the actual Thunder. The sound needs to be assigned in the properties list of the trigger entity.
Hope this all works for you.
Windows 10,64 bit|AMD FX-6200 Six-core-3.80 Ghz |CPU PASSMARK 6,142 |Memory 10GB |NVIDIA GEFORCE GTX 660 SC |GPU PASSMARK 4,114

Login to post a reply

Server time is: 2024-12-22 13:10:21
Your offset time is: 2024-12-22 13:10:21