Jump to content

[Solved] Can't pick up certain item?


Recommended Posts

For all of the other items in my mod, I can spawn them in using the both console commands, but with this item specifically trying to get them with the client side console commands, or through the normal means doesn't work. It just leaves me with the item on the floor, I can't inspect it or pick it up?

Where am I going wrong here?

20190824014156_1.thumb.jpg.0fb794a3307b869e53e8a19b2f7faa69.jpg

Item's prefab file

local assets =
{
    Asset("ANIM", "anim/wakes_eggs.zip"),
	
	Asset("ATLAS", "images/inventoryimages/wakes_eggs.xml"),
    Asset("IMAGE", "images/inventoryimages/wakes_eggs.tex"),
}

local prefabs =
		{
			"wakes_eggs",
				
		} 
	
local function fn(Sim)
    local inst = CreateEntity()

    inst.entity:AddTransform()
    inst.entity:AddAnimState()
    inst.entity:AddNetwork()

    MakeInventoryPhysics(inst)
	MakeSmallBurnable(inst)
	MakeSmallPropagator(inst)

    inst.AnimState:SetBank("wakes_eggs")
    inst.AnimState:SetBuild("wakes_eggs")
    inst.AnimState:PlayAnimation("idle", true)
	
	inst.entity:AddLight()
		inst.Light:Enable(true)
		inst.Light:SetFalloff(.7)
		inst.Light:SetIntensity(0.15)
		inst.Light:SetColour(172 / 255, 247 / 255, 246 / 255)
	
	MakeInventoryFloatable(inst, "small", 0.15, 0.6)

    inst.entity:SetPristine()

    if not TheWorld.ismastersim then
        return inst
    end

    inst:AddComponent("stackable")
    inst.components.stackable.maxsize = TUNING.STACK_SIZE_SMALLITEM

    inst:AddComponent("inspectable")

    inst:AddComponent("inventoryitem")
    inst.components.inventoryitem.imagename = "wakes_eggs"
    inst.components.inventoryitem.atlasname = "images/inventoryimages/wakes_eggs.xml"
	
	inst:AddTag("preparedfood")
	
    inst:AddComponent("edible")
	inst.components.edible.healthvalue = -25
	inst.components.edible.hungervalue = 50
	inst.components.edible.sanityvalue = -75
	inst.components.edible.foodtype = "MEAT"
	
	inst:AddComponent("perishable")
	inst.components.perishable:SetPerishTime(TUNING.PERISH_PRESERVED*2)
	inst.components.perishable:StartPerishing()
	inst.components.perishable.onperishreplacement = "rottenegg"
	
	inst:AddComponent("tradable")
	inst.components.tradable.goldvalue = 1

    MakeHauntableLaunch(inst)

    return inst
end
STRINGS.NAMES.WAKES_EGGS = "Chaurus Eggs"
STRINGS.RECIPE_DESC.WAKES_EGGS = "Eggs for an Egg-Sister."

return Prefab("common/inventory/wakes_eggs", fn, assets, prefabs)
	

Modmain part where the item's mentioned:

local FOODTYPE = GLOBAL.FOODTYPE
local FOODGROUP = GLOBAL.FOODGROUP
RECIPETABS = GLOBAL.RECIPETABS
Recipe = GLOBAL.Recipe
Ingredient = GLOBAL.Ingredient
local AllRecipes = GLOBAL.AllRecipes
local Ingredient = GLOBAL.Ingredient
local TECH = GLOBAL.TECH

local wakes_eggs = {
	name = "wakes_eggs",
	test = function(cooker, names, tags) return (names.tallbirdegg or names.tallbirdegg_cooked) and (names.wormlight or names.wormlight_lesser ==2)  and not tags.meat end,
	priority = 10,
	weight = 1,
	foodtype="MEAT",
	perishtime = TUNING.PERISH_PRESERVED*2,
	cooktime = 1,
}
AddIngredientValues({"tallbirdegg"}, {blue_egg=1})
AddIngredientValues({"tallbirdegg_cooked"}, {blue_egg=1})
AddIngredientValues({"spidereggsack"}, {blue_egg=1})
AddIngredientValues({"wormlight"}, {blue_glow=1})
AddIngredientValues({"wormlight_lesser"}, {blue_glow=1})
AddCookerRecipe("cookpot", wakes_eggs)

AddIngredientValues({"spidereggsack"}, {egg=4})


AddPrefabPostInit("wakes_eggs", function(inst)  
if GLOBAL.ThePlayer.prefab == "wakes" then
inst:AddComponent("edible")    
inst.components.edible.foodtype = "MEAT"
inst.components.edible.healthvalue = 50
inst.components.edible.sanityvalue = 50  
inst.components.edible.hungervalue = 75
end
end)

Any help would be appreciated, I've been stuck on this for hours. 

Edited by Scrumch
Link to comment
Share on other sites

Probably you are trying to spawn an item only on client (if you use dedicated server or world with caves). Before pressing Enter check if console has "Remote" mark. You may toggle it by pressing Ctrl key.

NKRpEiM.png

It's easy to check if an item is on client side only:

  • If you hover the mouse over it, there is no item name
  • If you restart server, an item disappears.
  • Like 1
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...