Jump to content

Recommended Posts

Hello !

(this is for don't starve together !)
So I'm creating two characters, one named Vee and one named Mayhem.
I'd like to make it so when Mayhem is a ghost, Vee's sanity reaches zero and can't go back up until Mayhem is back to life  - I have no idea how to code that, could anyone help me out ?

Also, I'd love to learn how to code for don't starve together on my own, does anyone know of a website or something that teaches coding step by step ?

Thanks in advance !

Magpie

This might help with modding generically:

It's a wonderful collection of modding knowledge.

In terms of sanity aura stuff, you can add or remove a sanity aura from a player by doing something like this: player:AddComponent("sanityaura") and then you can change it's properties by doing something like this: player.components.sanityaura.aura = TUNING.SANITYAURA_SMALL

If you meant to immediately make the player's sanity 0, then just do this: player.components.sanity:DoDelta(-300) or whatever number you want.

In some function (maybe AddPlayerPostInit(myFunction)), you can somehow (maybe by listening for events) check if a certain player is dead. First, you must retrieve the other player accurately, not just c_find("mayhem"), if there is more than one, you must find the right partner. Then try checking if their dead with these: otherplayer.components.health:IsDead() or otherplayer:HasTag("playerghost"). Then, you must wait for vee's sanity to reach zero. Without using a forever loop, check if player.components.sanity:GetPercent() == 0 then, this is the main part, do player.components.sanity.ignore = true. This will stop any deltas from being done to the sanity. When you learn that the other player has been revived, in other words, if the top two death conditions are false, then set that ignore variable back to true and then it will work again. If you want to make the sanity the same as when mayhem dies, then just store the percent before all of this like this local oldSanity = player.components.sanity:GetPercent() and when mayhem comes back just set it back like this: player.components.sanity:SetPercent(oldSanity)

I know this probly seems vague, but there are some implementations that I'm not entirely sure how to talk about with full knowledge, such as how to check when the player is dead and therefore either activate or deactivate the sanity lock without checking constantly, and whether or not you should use AddPrefabPostInit("vee", myFunction) or AddPlayerPostInit(myFunction) and check if the player is "vee". In the end however, those earlier points are probably best handled by a good system of events. This is likely what your flow will look like. If you want to learn more, just look around the guides in the forums or in the sanity component in game. Learning lua by itself might not help as much as learning how Klei uses it. Their code is extremely well written.

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...