Random Weather

Post new mods and scenarios here.

Moderator: MOD_Command

Post Reply
User avatar
Gunner98
Posts: 5973
Joined: Fri Apr 29, 2005 12:49 am
Location: The Great White North!
Contact:

Random Weather

Post 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
Check out our novel, Northern Fury: H-Hour!: http://northernfury.us/
And our blog: http://northernfury.us/blog/post2/
Twitter: @NorthernFury94 or Facebook https://www.facebook.com/northernfury/
User avatar
wqc12345
Posts: 176
Joined: Mon Dec 07, 2015 2:56 pm
Location: San Francisco, CA

RE: Random Weather

Post 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)
User avatar
Gunner98
Posts: 5973
Joined: Fri Apr 29, 2005 12:49 am
Location: The Great White North!
Contact:

RE: Random Weather

Post by Gunner98 »

Thank you sir.
Check out our novel, Northern Fury: H-Hour!: http://northernfury.us/
And our blog: http://northernfury.us/blog/post2/
Twitter: @NorthernFury94 or Facebook https://www.facebook.com/northernfury/
USSInchon
Posts: 40
Joined: Mon Feb 17, 2014 2:43 pm

RE: Random Weather

Post by USSInchon »

Does this make the weather change throughout the mission or does it need a trigger to change?
User avatar
wqc12345
Posts: 176
Joined: Mon Dec 07, 2015 2:56 pm
Location: San Francisco, CA

RE: Random Weather

Post 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.
magi
Posts: 1533
Joined: Sat Feb 01, 2014 1:06 am

RE: Random Weather

Post by magi »

still very cool...
butch4343
Posts: 327
Joined: Thu Mar 26, 2015 2:09 pm

RE: Random Weather

Post 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
User avatar
Gunner98
Posts: 5973
Joined: Fri Apr 29, 2005 12:49 am
Location: The Great White North!
Contact:

RE: Random Weather

Post 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.
Check out our novel, Northern Fury: H-Hour!: http://northernfury.us/
And our blog: http://northernfury.us/blog/post2/
Twitter: @NorthernFury94 or Facebook https://www.facebook.com/northernfury/
butch4343
Posts: 327
Joined: Thu Mar 26, 2015 2:09 pm

RE: Random Weather

Post by butch4343 »

Gunner,

Thanks, Ill give it a wee try tonight to test it out

Much obliged mate.
StuartG
Posts: 80
Joined: Sun Feb 12, 2017 6:16 am

RE: Random Weather

Post 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.
butch4343
Posts: 327
Joined: Thu Mar 26, 2015 2:09 pm

RE: Random Weather

Post 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

User avatar
CCIP-subsim
Posts: 467
Joined: Tue Nov 10, 2015 6:59 pm

RE: Random Weather

Post 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)
butch4343
Posts: 327
Joined: Thu Mar 26, 2015 2:09 pm

RE: Random Weather

Post by butch4343 »

CCIPsubsim,

Thanks mate, that sorted that out and the script is working a treat.

Thanks one and all for your help.

[:)]
Post Reply

Return to “Mods and Scenarios”