Just paste this script over the other, save and run.
Fiddle with lo,hi (in init) to change the frequency/duration. 2000 lo and 5000 hi seemed to give the best "showery day" effect. After the rain event (or non event) the timer is randomised ready for next event. No zones or anything needed.
-- Created by Corno_1
-- random event functionality added by !nullptr
-- modify hi and lo for rain duration/frequency
local addX = 0
local addY = 0
local addZ = 0
local onetimeEvent = 0
local start_time_rain=math.ceil(g_Time*1000)
local rupdate = 0
function rainbox_followplr_init(e)
raining = 1
lo = 2000
hi = 5000
rain_frequency = math.random(lo,hi)
end
function rainbox_followplr_main(e)
local rtrg = rain_timer(rain_frequency)
-- debug line - remove
TextCenterOnX(50,50,1,"RF: "..rain_frequency.." - Timer: "..rupdate.." - Raining: "..raining)
if rtrg == 1 then
if raining==1 then
Hide(e)
raining=0
elseif raining==0 then
Show(e)
raining=1
end
rain_frequency = math.random(lo,hi)
end
if onetimeEvent == 0 then
addX = g_Entity[e]['x'] - g_PlayerPosX
addY = g_Entity[e]['y'] - g_PlayerPosY
addZ = g_Entity[e]['z'] - g_PlayerPosZ
end
SetPosition(e,g_PlayerPosX+addX,g_PlayerPosY+addY,g_PlayerPosZ+addZ)
ResetPosition(e,g_PlayerPosX+addX,g_PlayerPosY+addY,g_PlayerPosZ+addZ)
onetimeEvent = 1
end
-- ***************************************
function rain_timer(finish)
local stop_timex=math.ceil(g_Time*1000)
local r_elapsedx=start_time_rain-stop_timex
if r_elapsedx == 0 then
start_time_rain=stop_timex+1
rupdate=rupdate+1
else
start_time_rain=stop_timex+1
end
if rupdate == finish then
rupdate=0 -- reset for next use
return 1
else
return 0
end
end -- poll timer
AKA SisterMatic (Steam)
Development/ Gaming Rigs
Sys 1: i7-4770 (3.5)/16Gb/128 SSD/3Tb/970gtx/2 x 23, 1 x 27 LCD - Sys 2: i7/8Gb/670gtx/1.5Tb/1 x 23 LCD - Sys 3: Amd Quad/8Gb/645gtx/1Tb/30" LCD