Page 1 of 1

Weather Event Not Working

Posted: Tue Jun 23, 2020 8:05 pm
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

RE: Weather Event Not Working

Posted: Wed Jun 24, 2020 12:35 am
by KnightHawk75
temp not temperature.

See attached.

RE: Weather Event Not Working

Posted: Wed Jun 24, 2020 10:08 am
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