Jump to content

Recommended Posts

Hi I'm new to modding and I've tried a few tutorials but it always gives an error message. I'm trying to give my character a sanity boost when he holds the pan flute. I can't seem to figure out what code to use or exactly where. I've tried a few options but can't figure it out. 

 

Here is the code I've been trying to use. 

AddPrefabPostInit(“panflute”, function(inst)

        if GetPlayer().prefab == “character” then

            inst:AddComponent("sanityaura")

            inst.components.sanityaura.aura = TUNING.SANITYAURA_LARGE

        end

    end)

Edited by SecondQuill

Well with DST it's a lot simpler, since Klei did a similar thing with Wurt and carrying a fish in the inventory:

    inst:AddComponent("itemaffinity")
    inst.components.itemaffinity:AddAffinity("hutch_fishbowl", nil, TUNING.DAPPERNESS_MED, 1)
    inst.components.itemaffinity:AddAffinity(nil, "fish", TUNING.DAPPERNESS_MED, 1)
    inst.components.itemaffinity:AddAffinity(nil, "fishmeat", -TUNING.DAPPERNESS_MED_LARGE, 2)
    inst.components.itemaffinity:AddAffinity(nil, "spoiled_fish", -TUNING.DAPPERNESS_MED_LARGE, 2)

So tune as desired and repurpose for the flute prefab name.

Tried adding to the code. It keeps crashing. Tried in the character file and modmain.lua and haven't had any luck. I'm a super noob. Sorry xP This is the code I used. 

 inst:AddComponent("itemaffinity")

    inst.components.itemaffinity:AddAffinity(“panflute”, nil, TUNING.DAPPERNESS_MED, 1)

 

UPDATE: 

I got it to not crash but the effect doesn't work. Fiddled around and got it to do the opposite of what I wanted but reversing it doesn't make a positive reaction. 

Edited by SecondQuill

This code is used to tune dapperness, yes?  I tried looking up that stat, but found nothing.  What does dapperness do, and how does this code affect it?

inst.components.itemaffinity:AddAffinity(“panflute”, nil, TUNING.DAPPERNESS_MED, 1)

Dapperness is like a personal sanity aura, just for yourself. Maxwell is very "dapper", so he has a very large, passive, sanity gain. Dapperness (I think) is defined in player_common.lua, and look at Maxwell's character file and you can see that Klei set this dapperness very high.

OHHHHHHHH!!!!!  So that's what dapperness is!  I tried googling it, and I read the code, but I couldn't make heads or tails of it.  I think I saw it factoring into the heat code, and that's when I just gave up trying to understand it at all.  Ok, so it's your personal sanity aura, ok.

My guess is that dapperness tuning is like favorite food tuning, where it multiples an existing value.  I'll try using similar code to affect my player's favorite item stat.

This is Maxwell's dapperness code:  inst.components.sanity.dapperness = TUNING.DAPPERNESS_LARGE

On 2/26/2020 at 1:58 PM, SecondQuill said:

I got it to not crash but the effect doesn't work. Fiddled around and got it to do the opposite of what I wanted but reversing it doesn't make a positive reaction. 

How did you get the opposite reaction?

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