Jump to content

Recommended Posts

I'd like for my character to change along with the seasons (except for autumn), but the code I have currently doesn't do anything. It's placed right above common_postinit

Also I'm not sure if the "groggy" tag would work either. I plan on making an equipable item that would allow him to move normally during summer as well.

2025-10-12105519.png.53bb95b53899bf303a83e78740942367.png

1 hour ago, Baguettes said:

WatchWorldState season and tying that function into it should work, methinks.
Alternatively I would prefer being on Discord to talk about modding so replies are more instantaneous lol

oo ok! And if you want to add me on Discord, my user's .kyupita (including the period at the start)

I figured it out and it was actually pretty easy, what I did was:

In your character's prefab file above common_postinit

local function seasonChange(inst)
	if TheWorld.state.season == "autumn" then
	-- Code here
    elseif TheWorld.state.season == "winter" then
    	-- Code here
    elseif TheWorld.state.season == "spring" then
    	-- Code here
    elseif TheWorld.state.season == "autumn" then
    	-- Code here
    end
end

And then in master_postinit

inst:WatchWorldState("season", seasonChange)

NOTE: Make sure to restore your character's default values after the season ends, if you don't the values will carry over to the next season

 

Here's an example of how my code looks:

Spoiler
-- Above common_postinit

local function seasonstatchange(inst)
	if TheWorld.state.season == "winter" then
		inst:RemoveTag("groggy") -- Removes groggy tag from summer
		inst.components.health:SetMaxHealth(TUNING.TOUJI_HEALTH_WINTER) -- Increase health during winter
		inst.components.sanity:SetMax(TUNING.TOUJI_SANITY_WINTER) -- Increase sanity during winter
		inst.components.hunger.hungerrate = 1 -- Setting hungerrate to default
		inst.components.locomotor:SetExternalSpeedMultiplier(inst, "touji_speed_mod", 1.2) -- Increase speed during winter
	elseif TheWorld.state.season == "spring" then
		inst.components.health:SetMaxHealth(TUNING.TOUJI_HEALTH) -- Setting maxhealth to default
		inst.components.sanity:SetMax(TUNING.TOUJI_SANITY) -- Setting maxsanity to default
		inst:RemoveTag("groggy") -- Removes groggy tag from summer
		inst.components.hunger.hungerrate = 1.4 -- Increase hungerrate
		inst.components.locomotor:SetExternalSpeedMultiplier(inst, "touji_speed_mod", 1) -- Increase speed during spring
	elseif TheWorld.state.season == "summer" then
		inst.components.health:SetMaxHealth(TUNING.TOUJI_HEALTH) -- Setting maxhealth to default
		inst.components.sanity:SetMax(TUNING.TOUJI_SANITY) -- Setting maxsanity to default
		inst:AddTag("groggy") -- Make character groggy during summer
		inst.components.hunger.hungerrate = 1 -- Setting hungerrate to default
		inst.components.locomotor:SetExternalSpeedMultiplier(inst, "touji_speed_mod", 0.8) -- Setting speed to default
	elseif TheWorld.state.season == "autumn" then
		inst:RemoveTag("groggy") -- Removes groggy tag from summer
		inst.components.health:SetMaxHealth(TUNING.TOUJI_HEALTH) -- Setting maxhealth to default
		inst.components.sanity:SetMax(TUNING.TOUJI_SANITY) -- Setting maxsanity to default
		inst.components.hunger.hungerrate = 1 -- Setting hungerrate to default
		inst.components.locomotor:SetExternalSpeedMultiplier(inst, "touji_speed_mod", 0.8) -- Setting speed to default
	end
end
-- Inside master_postinit
inst:WatchWorldState("season", seasonstatchange)

 

 

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
×
  • Create New...