Page 1 of 1
Random Weather
Posted: Tue Jul 12, 2016 6:48 pm
by Gunner98
Curious if anyone has built any Lua script for random Wx events? Either start of scenario of mid game. If so, would you be willing to share?
Thanks
B
RE: Random Weather
Posted: Tue Jul 12, 2016 7:01 pm
by wqc12345
Here is my script for one of my scenarios.
--Random weather
local temp= math.random(22,28)
local rain= math.random(0,5)
local cloud= math.random(0,5)/10.0
local sea= math.random(1,4)
ScenEdit_SetWeather(temp,rain, cloud, sea)
ScenEdit_SpecialMessage('South Asian Allied Forces (SAAF)', '<P><FONT size=2 face="Courier New">COMMANDER,</P><P>NEW WX REPORT,</P> TEMPERATURE: ' .. temp .. ' DEGREES CELSIUS, RAIN STATE: ' .. rain .. ' CLOUD LEVEL: ' .. cloud .. ' AND SEA STATE: ' .. sea)
RE: Random Weather
Posted: Thu Jul 14, 2016 8:09 am
by Gunner98
Thank you sir.
RE: Random Weather
Posted: Thu Jul 14, 2016 1:51 pm
by USSInchon
Does this make the weather change throughout the mission or does it need a trigger to change?
RE: Random Weather
Posted: Thu Jul 14, 2016 2:00 pm
by wqc12345
This code will change the weather (within the defined parameters) and display a message with those new parameters. But, you need to set the trigger. So, no, it won't change it unless you give it some trigger.
RE: Random Weather
Posted: Thu Jul 14, 2016 9:56 pm
by magi
still very cool...
RE: Random Weather
Posted: Thu Jun 01, 2017 10:00 am
by butch4343
ORIGINAL: wqc12345
Here is my script for one of my scenarios.
--Random weather
local temp= math.random(22,28)
local rain= math.random(0,5)
local cloud= math.random(0,5)/10.0
local sea= math.random(1,4)
ScenEdit_SetWeather(temp,rain, cloud, sea)
ScenEdit_SpecialMessage('South Asian Allied Forces (SAAF)', '<P><FONT size=2 face="Courier New">COMMANDER,</P><P>NEW WX REPORT,</P> TEMPERATURE: ' .. temp .. ' DEGREES CELSIUS, RAIN STATE: ' .. rain .. ' CLOUD LEVEL: ' .. cloud .. ' AND SEA STATE: ' .. sea)
Guys,
I am a LAU dunce, I was wondering if anyone could possible explain the above code, I find LAU easier to grasp if someone can explain the script.
local temp= math.random(22,28)
Is this basically saying select a temprature between 22 and 28 centigrade and the math.random bit is the bit that randomises it?
local rain= math.random(0,5)
local cloud= math.random(0,5)/10.0
Is the /10.00 part equivelant to 100% cloud? If so what does the bracket (0,5) represent? is that between 0 and 50% cloud cover?
local sea= math.random(1,4)
If I wanted a sea state of zero would it read local sea= math.random(0,0)?
The next bit that confuses me is
ScenEdit_SetWeather(temp,rain, cloud, sea)
Am I right to think that my LAU script look like the following
ScenEdit_SetWeather(local temp= math.random(22,28),local rain= math.random(0,5),local cloud= math.random(0,5)/10.0,local sea= math.random(1,4)) ?
Would I need to use the Special Action message section of the script if I dont want the player to recieve weather reports?
Last question I promise, if I want to simplify things and just set the weather would my script look something like
ScenEdit_SetWeather(local temp=(28),local rain=(5),local cloud=(2)/10.0,local sea=(4)) ?
The reason I ask is that am building a flight of the intruder scenario and have never used the set weather LAU.
Thanks in advance for you paitience folks [:D]
Butch
RE: Random Weather
Posted: Thu Jun 01, 2017 10:29 am
by Gunner98
Butch
I am one step up from Lua Dunce, and have graduated to Lua Numpty [:D]- but here goes:
In the first bit you are setting 4 'local' variables and I think you have a good understanding of them.
The line: ScenEdit_SetWeather(temp,rain, cloud, sea) - assigns the local variables to the actual game that is running
So you need both parts of the script: the first part to define the variables and the second to assign them (Guessing here)
You don't need a special action -set up a trigger: Time or Regular time etc and the action is your Lua code
There is a tag on the event page now where you can make the event happen without showing in the log so you keep it from the player.
Your simplified scrip should look like: (Not at the game so cannot test it)
ScenEdit_SetWeather(temp=28,rain=5,cloud=2,sea=4)
I have run the script as quoted by wqc12345 and it works great - and the last line returns a message to the player when the weather changes.
Hope this makes sense, and I would invite any of the Lua Wizards out there to correct me if this is wrong.
RE: Random Weather
Posted: Thu Jun 01, 2017 12:35 pm
by butch4343
Gunner,
Thanks, Ill give it a wee try tonight to test it out
Much obliged mate.
RE: Random Weather
Posted: Thu Jun 01, 2017 1:13 pm
by StuartG
Is there any way to localise different weather into a regional area? For example, ive set the weather for a particular period accurately, and it varies over time. But im wondering if you can make a particular area an exception to the global settings and with different weather, just to give recce aircraft or satellites a chance of penetrating an overcast.
RE: Random Weather
Posted: Mon Jun 05, 2017 6:39 pm
by butch4343
Gunner,
Im sorry to be a a#pain in the arse mate
Ive tried the simplified LAU you suggested:
ScenEdit_SetWeather(temp=28,rain=0,cloud=0,sea=0)
I keep getting the following error:
- Lua script execution error: [string "Weather 1 Cloudy Clear "]:1: ')' expected near '='
21:40:00 - 21:40:00 - Event: 'Weather 1 Cloudy Clear ' has been fired.
As my scenario is only air ops the temp, rain and sea state are of no importance, its really the cloud cover am trying to get to work,
Any ideas of where I have gone wrong?
Kind Regards
Butch
RE: Random Weather
Posted: Tue Jun 06, 2017 12:59 am
by CCIP-subsim
Get rid of the text bits - those are not needed. Just use this if you want to set weather with Lua (the numbers are in the same order):
ScenEdit_SetWeather (28,0,0,0)
RE: Random Weather
Posted: Tue Jun 06, 2017 9:26 am
by butch4343
CCIPsubsim,
Thanks mate, that sorted that out and the script is working a treat.
Thanks one and all for your help.
[:)]