Jump to content

I NEED HELP MODDING MOD


Recommended Posts

Please i need someone who can help me. I'm making a mod, but i don't know how to code that you lose 20 sanity everytime you use someting.

How can i code that?

Can someone tell me the code lines i have to use for it? The thing is that every time one player uses this object, he have to lose 20 of sanity

Please if someone know how to, leave it in the comments <3

Link to comment
Share on other sites

Hello @AntooGG, welcome to the forums. I have moved your post from the Suggestion Subforum into the correct Mods and Tools subforum that particularly deals with your concerns. Unfortunately, I never had the time to start modding so hopefully the lovely people here may be able to help you. Just sit tight and wait for a response from people with better know how than I do about modding.

Generally, afaik (from previous attempts to look into how to mod) the best way to learn to mod is to look at existing code that most likely does what you want to do. In this case I think you should be looking into the grave mounds. Specifically it's called the mound.lua in Don't Starve Together Beta\data\scripts\prefabs. If you look for code line that has "sanity" in it, you'll find the following line.

worker.components.sanity:DoDelta(-TUNING.SANITY_SMALL)

But instead of "-TUNING.SANITY_SMALL", use "-20". Cause we know when you dig up graves, you lose sanity which is what you want to do with your object/item to do to your player, correct? So I guess, within your custom mod's code that completes the "use object" task, include the code above inside it. So that upon "object use", sanity is removed.

Now, I don't know if this would even work cause I'm no modder. So try out the code and see if it works, if not the (again) hopefully the lovely people here in the Mods and Tools Subforum may be able to help you. Just sit tight and wait for a response from people with better know how than I do about modding.

Good luck, cheers.

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