ImperetorMaximus Posted March 8, 2014 Share Posted March 8, 2014 Hello: I just need some help with the Unikitty mod i am co-authoring with Hollow Shell.I have an if-else loop based upon the characters sanity that, though having the correct syntax, wont apply to the characers stats. If anyone would be willing to look into the code below and help me correct my error, i will give full credit to you. I would post this as an attachment, but i wont let me. local MakePlayerCharacter = require "prefabs/player_common" local assets = { Asset( "ANIM", "anim/player_basic.zip" ), Asset( "ANIM", "anim/player_idles_shiver.zip" ), Asset( "ANIM", "anim/player_actions.zip" ), Asset( "ANIM", "anim/player_actions_axe.zip" ), Asset( "ANIM", "anim/player_actions_pickaxe.zip" ), Asset( "ANIM", "anim/player_actions_shovel.zip" ), Asset( "ANIM", "anim/player_actions_blowdart.zip" ), Asset( "ANIM", "anim/player_actions_eat.zip" ), Asset( "ANIM", "anim/player_actions_item.zip" ), Asset( "ANIM", "anim/player_actions_uniqueitem.zip" ), Asset( "ANIM", "anim/player_actions_bugnet.zip" ), Asset( "ANIM", "anim/player_actions_fishing.zip" ), Asset( "ANIM", "anim/player_actions_boomerang.zip" ), Asset( "ANIM", "anim/player_bush_hat.zip" ), Asset( "ANIM", "anim/player_attacks.zip" ), Asset( "ANIM", "anim/player_idles.zip" ), Asset( "ANIM", "anim/player_rebirth.zip" ), Asset( "ANIM", "anim/player_jump.zip" ), Asset( "ANIM", "anim/player_amulet_resurrect.zip" ), Asset( "ANIM", "anim/player_teleport.zip" ), Asset( "ANIM", "anim/wilson_fx.zip" ), Asset( "ANIM", "anim/player_one_man_band.zip" ), Asset( "ANIM", "anim/shadow_hands.zip" ), Asset( "SOUND", "sound/sfx.fsb" ), Asset( "SOUND", "sound/wilson.fsb" ), Asset( "ANIM", "anim/beard.zip" ), -- Don't forget to include your character's custom assets! Asset( "ANIM", "anim/unik.zip" ),}local prefabs = {} local fn = function(inst) -- choose which sounds this character will playinst.soundsname = "willow" -- a minimap icon must be specifiedinst.MiniMapEntity:SetIcon( "willow.png" ) -- todo: Add an example special power here.inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1.3)inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1.4)inst.components.health:SetMaxHealth(100)inst.components.hunger:SetMax(100)inst.components.sanity:SetMax(200)inst.components.combat.damagemultiplier = .75 local function updatestats(inst)if inst.components.sanity.current <= 40 then--powers when insaneinst.components.combat.damagemultiplier = 2inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 2)inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 2.5)inst.components.combat.attackrange = 4inst.components.combat.hitrange = 4inst.components.health:StartRegen(-1, 2) inst.components.talker:Say("Say positive... oh forget it...") endend return MakePlayerCharacter("unik", prefabs, assets, fn) Link to comment https://forums.kleientertainment.com/forums/topic/32494-help-character-script-help/ Share on other sites More sharing options...
squeek Posted March 8, 2014 Share Posted March 8, 2014 You're not doing anything with the updatestats function, so it's never getting called.Presumably the goal is to have different stats when insane and sane, so you should do something like this:local assets = { Asset( "ANIM", "anim/player_basic.zip" ), Asset( "ANIM", "anim/player_idles_shiver.zip" ), Asset( "ANIM", "anim/player_actions.zip" ), Asset( "ANIM", "anim/player_actions_axe.zip" ), Asset( "ANIM", "anim/player_actions_pickaxe.zip" ), Asset( "ANIM", "anim/player_actions_shovel.zip" ), Asset( "ANIM", "anim/player_actions_blowdart.zip" ), Asset( "ANIM", "anim/player_actions_eat.zip" ), Asset( "ANIM", "anim/player_actions_item.zip" ), Asset( "ANIM", "anim/player_actions_uniqueitem.zip" ), Asset( "ANIM", "anim/player_actions_bugnet.zip" ), Asset( "ANIM", "anim/player_actions_fishing.zip" ), Asset( "ANIM", "anim/player_actions_boomerang.zip" ), Asset( "ANIM", "anim/player_bush_hat.zip" ), Asset( "ANIM", "anim/player_attacks.zip" ), Asset( "ANIM", "anim/player_idles.zip" ), Asset( "ANIM", "anim/player_rebirth.zip" ), Asset( "ANIM", "anim/player_jump.zip" ), Asset( "ANIM", "anim/player_amulet_resurrect.zip" ), Asset( "ANIM", "anim/player_teleport.zip" ), Asset( "ANIM", "anim/wilson_fx.zip" ), Asset( "ANIM", "anim/player_one_man_band.zip" ), Asset( "ANIM", "anim/shadow_hands.zip" ), Asset( "SOUND", "sound/sfx.fsb" ), Asset( "SOUND", "sound/wilson.fsb" ), Asset( "ANIM", "anim/beard.zip" ), -- Don't forget to include your character's custom assets! Asset( "ANIM", "anim/unik.zip" ),}local prefabs = {}local function OnSane(inst, data) inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1.3) inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1.4) inst.components.health:SetMaxHealth(100) inst.components.hunger:SetMax(100) inst.components.sanity:SetMax(200) inst.components.combat.damagemultiplier = .75endlocal function OnInsane(inst, data) inst.components.combat.damagemultiplier = 2 inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 2) inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 2.5) inst.components.combat.attackrange = 4 inst.components.combat.hitrange = 4 inst.components.health:StartRegen(-1, 2) inst.components.talker:Say("Stay positive... oh forget it...")end local fn = function(inst) -- choose which sounds this character will play inst.soundsname = "willow" -- a minimap icon must be specified inst.MiniMapEntity:SetIcon( "willow.png" ) -- set the default stats to sane; the goinsane event will be called when save data is loaded if you are insane OnSane(inst) -- listen for insane/sane changes inst:ListenForEvent("gosane", OnSane) inst:ListenForEvent("goinsane", OnInsane)endreturn MakePlayerCharacter("unik", prefabs, assets, fn) Link to comment https://forums.kleientertainment.com/forums/topic/32494-help-character-script-help/#findComment-426938 Share on other sites More sharing options...
ImperetorMaximus Posted March 9, 2014 Author Share Posted March 9, 2014 Thank you so much, ill let you know if it works. Link to comment https://forums.kleientertainment.com/forums/topic/32494-help-character-script-help/#findComment-427780 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