Jump to content

Would this code work for modding?


Recommended Posts

Quote

local _G = GLOBAL
local TUNING = _G.TUNING
local APPI = AddPrefabPostInit

APPI("world", function(world)
    world:ListenForEvent("fullmoon", function()
        print("full moon, setting leif chances to 1/5")
        
        local LEIF_MIN_DAY = TUNING.LEIF_MIN_DAY
        local LEIF_PERCENT_CHANCE = TUNING.LEIF_PERCENT_CHANCE
        TUNING.LEIF_MIN_DAY = 0
        TUNING.LEIF_PERCENT_CHANCE = 1/5
        
        local function clocktick()
            local clock = _G.GetClock()
            if clock:IsNight() and clock:GetMoonPhase() == "full" then return end 
            print("exiting full moon, setting leif chances back")
            
            TUNING.LEIF_MIN_DAY = LEIF_MIN_DAY
            TUNING.LEIF_PERCENT_CHANCE = LEIF_PERCENT_CHANCE
            world:RemoveEventCallback("clocktick", clocktick)
        end
        
        world:ListenForEvent("clocktick", clocktick)
    end)
end)

Why does the game says it's out of date?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...