Weather Event Not Working

All discussions & material related to Command's Lua interface

Moderators: RoryAndersonCDT, michaelm75au, angster, MOD_Command

Post Reply
User avatar
vettim89
Posts: 3744
Joined: Fri Jul 13, 2007 11:38 pm
Location: Toledo, Ohio

Weather Event Not Working

Post by vettim89 »

I am trying to use the following code to modify the weather. Basic operation is that there is an equal chance the weather will worsen, improve or stay the same. This code is hanging up on the temperature value as every time it returns a value of 'nil' for temperature even if I use the "tonumber" operator. Any ideas on why this doesn't work?

math.randomseed(os.time())
math.random();
math.random(); math.random()
local w=ScenEdit_GetWeather()
local c=math.random(1,3)
if c==1 then
local newtemp=tonumber(w.temperature) - math.random(3,8)
local newrain=tonumber(w.rainfall) + math.random(10,30)
if newrain>>50 then
newrain= 50
end
local newcloud=tonumber(w.undercloud) + math.random(1,3)
if newcloud>>1 then
newcloud=1
end
local newstate=tonumber(w.seastate)+math.random(1,3)
if newstate>>9 then
newstate=9
end
ScenEdit_SetWeather(newtemp, newrain, newcloud, newstate)
elseif c==2 then
local newtemp=tonumber(w.temperature) + math.random(3,8)
local newrain=tonumber(w.rainfall) - math.random(10,30)
if newrain<<0 then
newrain= 0
end
local newcloud=tonumber(w.undercloud) - math.random(1,3)
if newcloud<<0 then
newcloud=0
end
local newstate=tonumber(w.seastate)-math.random(1,3)
if newstate<<0 then
newstate=0
end
ScenEdit_SetWeather(newtemp, newrain, newcloud, newstate)
else
return
end
"We have met the enemy and they are ours" - Commodore O.H. Perry
KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

RE: Weather Event Not Working

Post by KnightHawk75 »

temp not temperature.

See attached.
Attachments
DoRandomWeather.txt
(1.21 KiB) Downloaded 19 times
User avatar
vettim89
Posts: 3744
Joined: Fri Jul 13, 2007 11:38 pm
Location: Toledo, Ohio

RE: Weather Event Not Working

Post by vettim89 »

ORIGINAL: KnightHawk75

temp not temperature.

See attached.

This needs to be changed on CK_infinite's site then because that is what I used for formatting. Oddly, I was wondering if that was the case
"We have met the enemy and they are ours" - Commodore O.H. Perry
Post Reply

Return to “Lua Legion”