Jump to content

Recommended Posts

So, I'm trying to make a character who can read books for sanity. Ideally, this would be sanity over time, rather than instant. The problem I'm having is that the code, even when copied directly from Wurt, doesn't seem to work?

Here's my code:

Spoiler

local function peruse_brimstone(inst)

    inst.components.sanity:DoDelta(TUNING.SANITY_HUGE)

end

local function peruse_birds(inst)

    inst.components.sanity:DoDelta(-TUNING.SANITY_LARGE)

end

local function peruse_tentacles(inst)

    inst.components.sanity:DoDelta(TUNING.SANITY_HUGE)

end

local function peruse_sleep(inst)

    inst.components.sanity:DoDelta(TUNING.SANITY_LARGE)

end

local function peruse_gardening(inst)

    inst.components.sanity:DoDelta(TUNING.SANITY_LARGE)

end

local function peruse_horticulture(inst)

    inst.components.sanity:DoDelta(-TUNING.SANITY_LARGE)

end

local function peruse_silviculture(inst)

    inst.components.sanity:DoDelta(-TUNING.SANITY_LARGE)

end

Compared to Wurt's:

Spoiler

local function peruse_brimstone(inst)

    inst.components.sanity:DoDelta(-TUNING.SANITY_LARGE)

end

local function peruse_birds(inst)

    inst.components.sanity:DoDelta(TUNING.SANITY_HUGE)

end

local function peruse_tentacles(inst)

    inst.components.sanity:DoDelta(TUNING.SANITY_HUGE)

end

local function peruse_sleep(inst)

    inst.components.sanity:DoDelta(TUNING.SANITY_LARGE)

end

local function peruse_gardening(inst)

    inst.components.sanity:DoDelta(-TUNING.SANITY_LARGE)

end

local function peruse_horticulture(inst)

    inst.components.sanity:DoDelta(-TUNING.SANITY_LARGE)

end

local function peruse_silviculture(inst)

    inst.components.sanity:DoDelta(-TUNING.SANITY_LARGE)

end

And I also added this code, but it didn't fix the issue:

Spoiler

local master_postinit = function(inst)

--[Removed irrelevant code]

    inst.peruse_brimstone = peruse_brimstone

    inst.peruse_birds = peruse_birds

    inst.peruse_tentacles = peruse_tentacles

    inst.peruse_sleep = peruse_sleep

    inst.peruse_gardening = peruse_gardening

    inst.peruse_horticulture = peruse_horticulture

    inst.peruse_silviculture = peruse_silviculture

Wurt's copy of the code:

Spoiler

local function master_postinit(inst)

--[Removed irrelevant code]

    inst.peruse_brimstone = peruse_brimstone

    inst.peruse_birds = peruse_birds

    inst.peruse_tentacles = peruse_tentacles

    inst.peruse_sleep = peruse_sleep

    inst.peruse_gardening = peruse_gardening

    inst.peruse_horticulture = peruse_horticulture

    inst.peruse_silviculture = peruse_silviculture

Does anyone know how to fix this issue?

17 minutes ago, thomas4846 said:

--inst:AddComponent("reader")?

or 

    inst:AddTag("aspiring_bookworm")

That did it, thank you! I guess when I wrote this code I didn't take an in depth enough look at Wurt's prefab.

For future readers, if there are any: The first line enables the character to read books like Wickerbottom, putting both together enables reading like Wurt.

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