Lua and temperature

Post bug reports and ask for game support here.

Moderator: MOD_Command

Post Reply
Nikel
Posts: 2228
Joined: Tue Mar 24, 2009 10:51 am

Lua and temperature

Post by Nikel »

I do not know lua, so sorry if I write something stupid!

This code was posted by Gunner98, created by another member of the forum.

Code: Select all

local temp= math.random(18,24)
local rain= math.random(0,3)
local cloud= math.random(0,3)/10.0
local sea= math.random(1,4)

ScenEdit_SetWeather(temp,rain, cloud, sea)

ScenEdit_SpecialMessage('Russia', '<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)
ScenEdit_SpecialMessage('US', '<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)

Tested it and apparently is adding 10°C to the value randomly generated for most of the map, in some areas minus 10 and the less frecuent is the random value.

Is it a bug? The value should be the same for all the map? The other variables seem to be stable along the map and according to the random value.

TT.png
TT.png (13.22 KiB) Viewed 125 times
Attachments
Temp Test.zip
(3.39 KiB) Downloaded 1 time
Uzabit
Posts: 137
Joined: Fri Jul 13, 2018 6:03 pm

Re: Lua and temperature

Post by Uzabit »

Temp is the current baseline temperature (in deg C). Varies by latitude.

So that means the current temperature will also vary by the current time.

One would have to adjust the actual value for the message considering those factors.
Nikel
Posts: 2228
Joined: Tue Mar 24, 2009 10:51 am

Re: Lua and temperature

Post by Nikel »

But the code is to modify the weather.

Without running any code, I see 20 C in the North Pole and 30 in the South Pole, today.
Uzabit
Posts: 137
Joined: Fri Jul 13, 2018 6:03 pm

Re: Lua and temperature

Post by Uzabit »

Yes, the code does exactly that – but it overlooks the fact that "temp" represents the average temperature, not the current temperature in the specific area where the scenario takes place. A modifier would have to be added to the script that can be manually adjusted to the particular scenario's configuration.
Post Reply

Return to “Tech Support”