Jump to content

Recommended Posts

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() then
inst.components.health.maxhealth = 150
inst.components.hunger.maxhunger = 100
inst.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.8
inst.AnimState:SetBuild("seras")
elseif GetClock():IsNight() then
inst.components.health.maxhealth = 250
inst.components.hunger.maxhunger = 150
inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1.2)
inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1.4)
inst.components.combat.damagemultiplier = 1.8
inst.components.hunger:SetRate(TUNING.WILSON_HUNGER_RATE * 0.1)
inst.AnimState:SetBuild("wolfe")
end
inst.components.health:SetPersent(health_percent)
end
local fn = function(inst)
 
-- choose which sounds this character will play
inst.soundsname = "willow"
 
-- a minimap icon must be specified
inst.MiniMapEntity:SetIcon( "wilson.png" )
 
--Stats varies
inst:ListenForEvent( "daytime", function() updatestats(inst) end , GetWorld())
inst:ListenForEvent( "nighttime", function() updatestats(inst) end , GetWorld())
updatestats(inst)
 
--  Night-vision
inst.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 by PlacidCobra
Link to comment
https://forums.kleientertainment.com/forums/topic/30154-code-help/
Share on other sites

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 by Malacath

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