icantevenname Posted April 27, 2020 Share Posted April 27, 2020 I want a character to gain a tiny bit of sanity from caves. I've looked through other characters that do something similar for reference, but they all seem to rely on changing sanity rates for all the other times of the day, and I just want to change the sanity rate in caves only. Link to comment https://forums.kleientertainment.com/forums/topic/117748-sanity-from-caves/ Share on other sites More sharing options...
krylincy Posted April 27, 2020 Share Posted April 27, 2020 you cold check for TheWorld:HasTag("cave") 1 Link to comment https://forums.kleientertainment.com/forums/topic/117748-sanity-from-caves/#findComment-1328899 Share on other sites More sharing options...
rawii22 Posted May 7, 2020 Share Posted May 7, 2020 I looked around for some events that occur when travelling between worlds and I found something in components/worldmigrator.lua. This is run whenever you travel: TheWorld:PushEvent("ms_playerdespawnandmigrate", { player = doer, portalid = self.id, worldid = self.linkedWorld }) In components/playerspawner.lua, the event ms_newplayercharacterspawned is pushed to TheWorld after the function SpawnAtLocation is run which I assume is run when the player is actually move from one world to another In modmain, you could add TheWorld:ListenForEvent("ms_newplayercharacterspawned", function() --[[your function here]] end) For that function, you can make a check using what @krylincy said and then potentially add a sanity aura to the player. If the check returns false you can remove the aura. As for auras, you just add and remove the component as needed. The code might look something like this: local function AddSanityAuraInCaves(player) GLOBAL.TheWorld:ListenForEvent("ms_newplayercharacterspawned", function() if TheWorld:HasTag("cave") then if inst.components.sanityaura == nil then player:AddComponent("sanityaura") end player.components.sanityaura.aura = TUNING.SANITYAURA_SMALL elseif inst.components.sanityaura ~= nil then player:RemoveComponent("sanityaura") end end) end AddPlayerPostInit(AddSanityAuraInCaves) I took some of this straight from the update_sanityaura function in sisturn.lua in prefabs. Only here, the subject in question is the player Link to comment https://forums.kleientertainment.com/forums/topic/117748-sanity-from-caves/#findComment-1331786 Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now