Here, use these code words: --- only run on server
if isClient() then return end
--check every ten minutes
Events.EveryTenMinutes.Add(function ()
local instance = SCampfireSystem.instance
local isRaining = getClimateManager():isRaining()
---loop all objects
for i = 0, instance.system:getObjectCount() - 1 do
local luaObject = instance.system:getObjectByIndex(i):getModData()
if isRaining and luaObject.exterior then
luaObject:putOut()
end
end
end)
function Utils.getWeather()
local currentWeather = "normal"
local rainIntensity = getClimateManager():getRainIntensity()
local currentWeatherPeriod = getClimateManager():getWeatherPeriod():getCurrentStageID()
--Check weather
if (currentWeatherPeriod == 3) or (currentWeatherPeriod == 8) or (rainIntensity >= 0.75) then --3: Storm | 8: Tropical Storm | 7: Blizzard (not used)
currentWeather = "extreme"
end
local modID = "ReactiveSoundEvents" -- The modID for Reactive Sound Events
local WorldSoundManager = getWorldSoundManager() -- Sound Manager
local Utils = require("ReactiveSoundEvents/Utils") -- Utils call
local function onEveryTenMinutes()
local modData = ModData.getOrCreate(modID)
if (modData.baseEventChance == nil) or (modData.eventChance == nil) or (modData.eventCD == nil) then
--print("Reactive Sound Events: modData still not set")
return
end
local weather = Utils.getWeather()
if weather == "extreme" then
if bWeatherEvents then
local doEvent = Utils.getProbability(10)
if doEvent then
--print("Reactive Sound Events: weather event will play!")
createEvent(false)
end
--Climate Probabilities:
if climate == "extreme" then
local objects = Square:getObjects()
for i=0, objects:size() - 1 do
local name = objects:get(i):getName()
if name and name == "Campfire" then
squareProp:UnSet(IsoFlagType.burning)
end