Jump to content

Health is nil value


Recommended Posts

I was going to test out my character on DST and everything was fine till i selected to play as my character which gave me a error mentioning that health was a nil value

 

Here is the log:

[00:00:44]: [string "../mods/The Nightmare/scripts/prefabs/night..."]:44: attempt to index field 'health' (a nil value)
LUA ERROR stack traceback:
../mods/The Nightmare/scripts/prefabs/nightmareplayer.lua:44 in (upvalue) common_postinit (Lua) <41-64>
inst = 110573 - (valid:true)
scripts/prefabs/player_common.lua:1324 in (field) fn (Lua) <1243-1534>
inst = 110573 - (valid:true)
scripts/mainfunctions.lua:148 in () ? (Lua) <137-168>
name = nightmareplayer
prefab = Prefab nightmareplayer -
=[C]:-1 in (method) SendSpawnRequestToServer © <-1--1>
scripts/mainfunctions.lua:1169 in (local) cb (Lua) <1167-1170>
scripts/frontend.lua:453 in (method) DoFadingUpdate (Lua) <417-457>

 

This is also what my prefab looks like:


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" ),


}
local prefabs = {}
local start_inv = {
-- Custom starting items
}

local common_postinit = function(inst)

--stats
inst.components.health:SetMaxHealth(120)
inst.components.hunger:SetMax(100)
inst.components.sanity:SetMax(300)


-- Damage multiplier (optional)
inst.components.combat.damagemultiplier = 1

-- Hunger rate (optional)
inst.components.hunger.hungerrate = 1 * TUNING.WILSON_HUNGER_RATE

-- Movement speed (optional)
inst.components.locomotor.walkspeed = 5
inst.components.locomotor.runspeed = 7


inst.soundsname = "willow"


inst.MiniMapEntity:SetIcon( "nightmareplayer.tex" )
end

local function master_postinit(inst)


inst:AddTag("monster")

end

return MakePlayerCharacter("nightmareplayer", prefabs, assets, common_postinit, master_postinit, start_inv)

 

No matter what i try i can't seem to fix it

 

Anyone know how to fix it? :(

Link to comment
Share on other sites

@codelyoko373,

u have to move all the stuff in the common_postinit that starts with inst.components to the master_postinit.

inst.components stuff hast to be done on the server.

and u probably should move inst:AddTag("monster") to the common_postinit.(just look into other characterprefabs how they handle stuff in those 2 functions)

Link to comment
Share on other sites

@codelyoko373,

u have to move all the stuff in the common_postinit that starts with inst.components to the master_postinit.

inst.components stuff hast to be done on the server.

and u probably should move inst:AddTag("monster") to the common_postinit.(just look into other characterprefabs how they handle stuff in those 2 functions)

Thanks ^-^

 

(I bet your getting tired of all my posts XD)

Link to comment
Share on other sites

(I bet your getting tired of all my posts XD)

not more tired, than of all the other pple, who dont care to read the tutorials :razz:

but at least u try, many pple neither read the tutorials, nor try to find a solution on their own :-)

Edited by Seiai
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...