Jump to content

Recommended Posts

Heya, I making a character using transformation to alter their stats, however I noticed it also replenishes their stats - it is not supposed to do that. How do I solve this?
Here's the code for the transformation
- It's also worth mentioning that their stat is based on their beard

local function DefStats(inst)        inst.components.health:SetMaxHealth(TUNING.WILSON_HEALTH)    inst.components.hunger:SetMax(TUNING.WILSON_HUNGER)    inst.components.sanity:SetMax(TUNING.WILSON_SANITY)
    inst.components.locomotor.walkspeed = 4.25     inst.components.locomotor.runspeed = 6.25    inst.components.hunger:SetRate(0.8) end local function Stage1_Stats(inst)     inst.components.beard.bits = BEARD_BITS[1]     inst.components.health:SetMaxHealth(TUNING.WILSON_HEALTH*1.5)     inst.components.hunger:SetMax(TUNING.WILSON_HUNGER*1.5)     inst.components.sanity:SetMax(TUNING.WILSON_SANITY/1.5)     inst.components.locomotor.walkspeed = 4.1     inst.components.locomotor.runspeed = 6.1     inst.components.hunger:SetRate(1) end
local function master_postinit(inst)    inst:AddComponent("beard")    inst.components.beard.onreset = DefaultStats    inst.components.beard.prize = "beardhair"    inst.components.beard:AddCallback(BEARD_DAYS[1], Stage1_Stats)    inst.components.beard:AddCallback(BEARD_DAYS[2], Stage2_Stats)    inst.components.beard:AddCallback(BEARD_DAYS[3], Stage3_Stats)	-- Stats    inst.components.health:SetMaxHealth(TUNING.WILSON_HEALTH)    inst.components.hunger:SetMax(TUNING.WILSON_HUNGER)    inst.components.sanity:SetMax(TUNING.WILSON_SANITY)    inst.components.locomotor.walkspeed = 4.25     inst.components.locomotor.runspeed = 6.25    inst.components.hunger:SetRate(0.8)end

You can see in the stats components that it's doing this:

function Hunger:SetMax(amount)    self.max = amount    self.current = amountend

So instead of using that function, just change the max stat directly like this:

inst.components.health.maxhealth = TUNING.WILSON_HEALTH*1.5inst.components.hunger.max = TUNING.WILSON_HUNGER*1.5inst.components.sanity.max = TUNING.WILSON_SANITY/1.5

(Note that it's "maxhealth", not "max" like the other two)

Edited by almightyjanitor

You can see in the stats components that it's doing this:

function Hunger:SetMax(amount)    self.max = amount    self.current = amountend

So instead of using that function, just change the max stat directly like this:

inst.components.health.maxhealth = TUNING.WILSON_HEALTH*1.5inst.components.hunger.max = TUNING.WILSON_HUNGER*1.5inst.components.sanity.max = TUNING.WILSON_SANITY/1.5

(Note that it's "maxhealth", not "max" like the other two)

 

It throws an error

post-729509-0-95092400-1449504520_thumb.

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