Jump to content

Need Help to Add Perks


Recommended Posts

Hi, I'm new on this of modding and I would really appreciate it if you could give me a little hand about the codes in .LUA file For DST.

1-All science machine recipes unlock (Like Wickerbottom)

2- Drained / Loss of sanity when chopping or burning trees, plants, etc.

3-Gain sanity when planting pinecone, bushes, Sapling, etc.

Also if you could tell me exactly where the codes should be, I would be really grateful.

Thank you for your attention  :D
 

 

Link to comment
Share on other sites

Is this for a character mod, or do you want these effects to work for all players on the server. Since you're saying "perks", I'm guessing it's a character mod.

There's no shortcut to this kind of thing. The recipe unlock is pretty straight forward, and you can probably figure out how to do it, by looking at a character (vanilla or mod) that does this already, like Wickerbottom.

Points 2 and 3 depend on whether there are events for those actions you can listen to. Again, try searching for characters (vanilla or mods) that do sort of the same thing. That's really the best way to go about this. Otherwise, it's just about searching through the appropriate stategraphs, prefabs and components, to see where the events you want to react to are pushed. Point 3 is very likely to have useful events, but chopping trees doesn't call events on the character, so I think you'll have a hard time with that one.

I hope others can be of more help. These questions are a bit too broad for me to answer in detail.

If you're a novice to coding LUA, check out this crash course, and other tutorials on how to code LUA. There's really no way around it.

Edited by Ultroman
Link to comment
Share on other sites

Thanks for the tip, I researched a little more and looking for other mods as you said, and I was able to find exactly what I needed (Even point 2 and yes, it was very difficult to find it).

And maybe you could help me more in this, I would like to decrease the drainage of sanity because it is very high.

 

-- Sanity penalty for chop trees
local function sanityfn(inst)
    if inst.sg:HasStateTag("chopping") then
        return TUNING.BEAVER_SANITY_PENALTY
    end
    return 0
end

 

Do you know how to adjust the loss of sanity?

Link to comment
Share on other sites

This line :


        return TUNING.BEAVER_SANITY_PENALTY

You can find values in the tuning.lua file (in the script folder).

        BEAVER_SANITY_PENALTY = -1.5,

Now you have three choices :

- you find another existing value in the tuning file that you want to use instead.

- you create your own tuning value (great if you use it in multiple files or have multiples custom values that you want to modify quickly). Something like this in your modmain :

GLOBAL.TUNING.MYCHARACTER_SANITY_PENALTY = -0.8

- you put directly the value you want to use. In this case, this could look like this :

         return -1

 

Edited by Lumina
Link to comment
Share on other sites

Sorry for not answering before.
I tried changing the return to -1, but that drained sanity for no reason. And unfortunately I don't know how to do the first and the second option.

I decided to keep it, anyway it's fine, more challenge for players.

Thank you very much for your help :D

Link to comment
Share on other sites

13 minutes ago, Yoyo_Dodo said:

I tried changing the return to -1, but that drained sanity for no reason. And unfortunately I don't know how to do the first and the second option.

Just in case, what return did you changed ?

This one :

         return TUNING.BEAVER_SANITY_PENALTY

or this one ?

     return 0

I can see how changing the second can cause the effect your mentioning, i don't see how changing the first will cause this (but i could miss something).

Link to comment
Share on other sites

Then it's why, change the first one. The first one define the gain or loss of sanity when you do the "chopping" action.

The second is a general sanity function, the default one, that you don't need to change. It explain the constant sanity drain for no reason.

Link to comment
Share on other sites

I put this and this error appears

-- Sanity penalty for chop trees
local function sanityfn(inst)
    if inst.sg:HasStateTag("chopping") then
        return -1 TUNING.BEAVER_SANITY_PENALTY
    end
    return 0
endThe second

 

 

error.jpg

Link to comment
Share on other sites

You need to replace the value, not adding it. Something like this :



-- Sanity penalty for chop trees
local function sanityfn(inst)
    if inst.sg:HasStateTag("chopping") then
        return -1
    end
    return 0
end

Let me know if it doesn't work.

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