SenpaiArtorias Posted April 29, 2016 Share Posted April 29, 2016 Good Day and Hello all Im Posting the first time in the klei forums and hope im right here. The Topic is i need some help with my custom charackter i currently try to make , i did it like a year ago but now when i try the same thing i cant get it work and i dont know why. What i try is to add to my charackter Lvl Up with food the problem is i cant get it work like i did last time. I already watched other charackter Mods with the same function and tryd to copy them over or using them as an exampel but no matter how i add it even when i just copy paste it i cant get it really working :/. Its the last function i need for my custom charackter and i hope someone can give me an advice or help to get it work. This is the code in my "preflabs/charname.lua" Spoiler local function applyupgrades(inst) local max_upgrades = 30 local upgrades = math.min(inst.level, max_upgrades) local hunger_percent = inst.components.hunger:GetPercent() local health_percent = inst.components.health:GetPercent() local sanity_percent = inst.components.sanity:GetPercent() inst.components.hunger.max = math.ceil (100 + upgrades * 2) --160 inst.components.health.maxhealth = math.ceil (80 + upgrades * 4) --220 inst.components.sanity.max = math.ceil (70 + upgrades * 2) --150 inst.components.talker:Say("Level : ".. (inst.level)) if inst.level >29 then inst.components.talker:Say("Level : Max!") end inst.components.hunger:SetPercent(hunger_percent) inst.components.health:SetPercent(health_percent) inst.components.sanity:SetPercent(sanity_percent) end local function oneat(inst, food) --if food and food.components.edible and food.components.edible.foodtype == "HELLO" then if food and food.components.edible and food.prefab == "dragonfruit" then --give an upgrade! inst.level = inst.level + 1 applyupgrades(inst) inst.SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup") end end local function onpreload(inst, data) if data then if data.level then inst.level = data.level applyupgrades(inst) --re-set these from the save data, because of load-order clipping issues if data.health and data.health.health then inst.components.health.currenthealth = data.health.health end if data.hunger and data.hunger.hunger then inst.components.hunger.current = data.hunger.hunger end if data.sanity and data.sanity.current then inst.components.sanity.current = data.sanity.current end inst.components.health:DoDelta(0) inst.components.hunger:DoDelta(0) inst.components.sanity:DoDelta(0) end end end local function onsave(inst, data) data.level = inst.level data.charge_time = inst.charge_time end Greetings and a Nice Day Link to comment Share on other sites More sharing options...
SenpaiArtorias Posted April 30, 2016 Author Share Posted April 30, 2016 (edited) Okay for everyone wounder how the state is i didnt was able to manage getting it working with my "char.lua" . Instant of using my one i copyd one of the Charackters lua where the Upgrade is working i replaced every file from my folder into the downloaded charackter and only keeped the downloadchar.lua. I edit all functions and stats in the download.lua with my char.lua renamed it and now its magical working dont know why. Fazit somehow my char.lua was bugged and didnt was able to make the Upgrade code working im glad its working now and someone with similar problem can take this experience as a little help. Thanks for everyone that was reading my thread and trying to help. PS : somewhere the function to mark my thread as done ? when not Moderator for the forum can close it =) Greetings Artorias Edited April 30, 2016 by SenpaiArtorias Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now