Jump to content

ListenForEvent not working i think


Recommended Posts

This is giving me a lot of trouble The Chars Sanity dapperness changes as the clock does Day to dust to night  or supposed to the only thing is Its not changing in game i have to log out and back in for it to change  Can someone Help me find out what I am Doing Wrong / Missing THANKS 

 

Still need to do a lot of work but ill post the whole char well it wont let me up load the zip so i just put the prefab .... oh well  

 

and here just just the code 

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" ),        ------------	    Asset( "ANIM", "anim/wou.zip" ),		Asset( "ANIM", "anim/were_wou.zip" ),		-- DST		        Asset( "ANIM", "anim/ghost_wou_build.zip" ),}       local prefabs = {"pighat","wouhat",}    	-- Custom starting itemslocal start_inv = {"pighat",--"monstermeat",--"monstermeat",}local function updatestats(inst)   if TheWorld.state.isday then   inst.AnimState:SetBuild("wou")   inst.components.sanity.maxsanity = 100   inst.components.sanity.dapperness = .1     elseif TheWorld.state.isdusk then   inst.AnimState:SetBuild("wou")   inst.components.talker:Say ("I can feel it pulling at me")   inst.components.sanity.dapperness = -.16     elseif TheWorld.state.isnight then   inst.AnimState:SetBuild("wou")   inst.components.talker:Say ("ahhh. No full moon in sight")   inst.components.sanity.dapperness = .25     elseif TheWorld.state.isfullmoon then   inst.components.talker:Say ("Ooh NOO.. It feels like it's looking at me")   inst.components.sanity.maxsanity = 50   inst.components.sanity.dapperness = -.05   inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1.1)   inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1.1)   inst.AnimState:SetBuild("were_wou")   --inst.components.health.maxhealth = 200       end end    local function common_postinit(inst) 	-- choose which sounds this character will play	inst.soundsname = "maxwell"	-- Minimap icon	inst.MiniMapEntity:SetIcon( "wou.tex" )end		local function master_postinit(inst)   --inst.components.inventory:GuaranteeItems(prefabs)		inst:ListenForEvent( "dusktime", function() updatestats(inst) end , TheWorld)     inst:ListenForEvent( "daytime", function() updatestats(inst) end , TheWorld)    inst:ListenForEvent( "nighttime", function() updatestats(inst) end , TheWorld)    updatestats(inst)			-- Stats		--inst.components.eater:SetCarnivore(true)	inst.components.health:SetMaxHealth(100)	inst.components.hunger:SetMax(200)	inst.components.sanity:SetMax(100)	inst.components.hunger:SetRate(TUNING.WILSON_HUNGER_RATE*1.2)	--inst.components.sanity.night_drain_mult = 1.1	inst.components.sanity.neg_aura_mult = 1.5		return instend return MakePlayerCharacter("wou", prefabs, assets, common_postinit, master_postinit, start_inv)

wou.lua

Link to comment
Share on other sites

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
 Share

×
  • Create New...