PlacidCobra Posted December 3, 2013 Share Posted December 3, 2013 (edited) I have come up with this code, but it makes my game crash every time i try to play as the character, I will note that i am using the models for seras and wolfe at the moment, while i make my own. local prefabs = {} local function updatestats(inst)local health_percent = inst.components.health:GetPercent() if GetClock():IsDay() theninst.components.health.maxhealth = 150inst.components.hunger.maxhunger = 100inst.components.hunger:SetRate(TUNING.WILSON_HUNGER_RATE * 1.1)inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 0.9)inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1)inst.components.combat.damagemultiplier = 0.8inst.AnimState:SetBuild("seras")elseif GetClock():IsNight() theninst.components.health.maxhealth = 250inst.components.hunger.maxhunger = 150inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1.2)inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1.4)inst.components.combat.damagemultiplier = 1.8inst.components.hunger:SetRate(TUNING.WILSON_HUNGER_RATE * 0.1)inst.AnimState:SetBuild("wolfe")endinst.components.health:SetPersent(health_percent)endlocal fn = function(inst) -- choose which sounds this character will playinst.soundsname = "willow" -- a minimap icon must be specifiedinst.MiniMapEntity:SetIcon( "wilson.png" ) --Stats variesinst:ListenForEvent( "daytime", function() updatestats(inst) end , GetWorld())inst:ListenForEvent( "nighttime", function() updatestats(inst) end , GetWorld())updatestats(inst) -- Night-visioninst.entity:AddLight()inst.Light:Enable(true)inst.Light:SetRadius(4)inst.Light:SetFalloff(0.2)inst.Light:SetIntensity(0.9)inst.Light:SetColour(100/255,100/255,245/255) return inst end any help would be greatly apreciated Edited December 3, 2013 by PlacidCobra Link to comment https://forums.kleientertainment.com/forums/topic/30154-code-help/ Share on other sites More sharing options...
Heavenfall Posted December 3, 2013 Share Posted December 3, 2013 Looking at the log.txt after a crash usually helps, it's in C:\Users\yourusername\Documents\Klei\DoNotStarve this is surely not spelled rightinst.components.health:SetPersent(health_percent) Link to comment https://forums.kleientertainment.com/forums/topic/30154-code-help/#findComment-382516 Share on other sites More sharing options...
Malacath Posted December 3, 2013 Share Posted December 3, 2013 (edited) Not to mention that you used that big chunk of code in the beginning without the variable inst being declared. So wrap them inside a function and call that function at the appropriate time.Edit: Or not, I'm just a big dummy who can't read codes without indents xD sorry Edited December 3, 2013 by Malacath Link to comment https://forums.kleientertainment.com/forums/topic/30154-code-help/#findComment-382541 Share on other sites More sharing options...
PlacidCobra Posted December 3, 2013 Author Share Posted December 3, 2013 Looking at the log.txt after a crash usually helps, it's in C:\Users\yourusername\Documents\Klei\DoNotStarve this is surely not spelled rightinst.components.health:SetPersent(health_percent)Thank you that was the solution Link to comment https://forums.kleientertainment.com/forums/topic/30154-code-help/#findComment-382651 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