Page 1 of 1

Lua and temperature

Posted: Wed Oct 08, 2025 10:46 am
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 218 times

Re: Lua and temperature

Posted: Wed Oct 08, 2025 10:58 am
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.

Re: Lua and temperature

Posted: Wed Oct 08, 2025 11:12 am
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.

Re: Lua and temperature

Posted: Wed Oct 08, 2025 11:21 am
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.