Jump to content

No name/text when hovering over custom item in inventory but the name shows up properly when it's on the ground


Recommended Posts

I've come across a really odd problem to do with string names for custom items. To make things easier to explain let's just say I've made around 20 fruit items. I've grouped them together in a single prefab file similar to amulets or staffs and swap out the animations depending on the specific prefab. I define the recipes and string names/descriptions in mod main. 

The problem is, 4 of the 20 fruit prefabs do not display the name or any sort of text when you hover over them in the inventory. I've searched to see if anyone has encountered this before, but the common problem seems to be when people get "MISSING NAME" instead of their name, but I don't get any text at all (not even the examine action). 

Here's what has me baffled. The name and examine text DOES show up when those 4 items are resting on the ground. And everything else works perfectly with those 4 items. I can even examine them while in the inventory and the examine text shows up. The other 16 of the 20 fruit prefabs work perfectly in every way. It's just the hover name of the 4 problem items specifically when they are in the inventory. 

Here's what the code looks like. Apple works fine but orange doesn't display any text while in the inventory. What could possibly cause this if they're the same code and everything else works fine?

In mod main I define the strings and recipes:

local STRINGS = GLOBAL.STRINGS

 STRINGS.NAMES.STUFF_APPLE = "apple"
 STRINGS.RECIPE_DESC.STUFF_APPLE = "an apple."
 
 STRINGS.NAMES.STUFF_ORANGE = "orange"
 STRINGS.RECIPE_DESC.STUFF_ORANGE = "an orange."

AddRecipe("stuff_apple", {Ingredient("cutgrass",1)}, CUSTOM_RECIPETABS["Stuff"], TECH.STUFF_ONE, nil, nil, true, nil, nil, "images/inventoryimages/stuff.xml", "apple.tex")

AddRecipe("stuff_orange", {Ingredient("cutgrass",1)}, CUSTOM_RECIPETABS["Stuff"], TECH.STUFF_ONE, nil, nil, true, nil, nil, "images/inventoryimages/stuff.xml", "orange.tex")

The prefab file:

local function commonfn(anim)
    local inst = CreateEntity()

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

    MakeInventoryPhysics(inst)

    inst.AnimState:SetBank("fruit")
    inst.AnimState:SetBuild("fruit")
    inst.AnimState:PlayAnimation(anim)

    inst.entity:SetPristine()
	
	inst:AddTag("nopunch")

    if not TheWorld.ismastersim then
        return inst
    end

    inst:AddComponent("inspectable")

    inst:AddComponent("inventoryitem")
    inst.components.inventoryitem.atlasname = "images/inventoryimages/stuff.xml"
    inst.components.inventoryitem.imagename = anim
	print("anim: " .. anim)

    inst:AddComponent("equippable")

    inst.components.equippable:SetOnUnequip(function(inst, owner)
		owner.AnimState:Hide("ARM_carry")
		owner.AnimState:Show("ARM_normal")
    end)
    
	inst.components.equippable:SetOnEquip(function(inst, owner)
        owner.AnimState:OverrideSymbol("swap_object", "swap_fruit", "swap_"..anim)
        owner.AnimState:Show("ARM_carry")
        owner.AnimState:Hide("ARM_normal")
    end)
	
	inst:AddComponent("spellcaster")     
	inst.components.spellcaster:SetSpellFn(onsummon)
	inst.components.spellcaster.canuseontargets = false
	inst.components.spellcaster.canusefrominventory = true
	
    inst:AddComponent("fuel")
    inst.components.fuel.fuelvalue = TUNING.SMALL_FUEL

    MakeSmallBurnable(inst, TUNING.SMALL_BURNTIME)
    MakeSmallPropagator(inst)

    MakeHauntableLaunch(inst)

    return inst
end

local function apple()
    local inst = commonfn("apple")

	STRINGS.CHARACTERS.GENERIC.DESCRIBE.STUFF_APPLE = "This is an apple."
	
	if not TheWorld.ismastersim then
        return inst
    end

    return inst	
end

local function orange()
    local inst = commonfn("orange")

	STRINGS.CHARACTERS.GENERIC.DESCRIBE.STUFF_ORANGE = "This is an orange."
	
	if not TheWorld.ismastersim then
        return inst
    end

    return inst	
end

return
	Prefab("stuff_apple", apple, assets), 
	Prefab("stuff_orange", orange, assets)

 

The xml file that mod main and the prefab file are referencing:

<Atlas>
<Texture filename="stuff.tex" />
<Elements>
<Element name="apple.tex" u1="0.2421875" u2="0.4765625" v1="0.203125" v2="0.39453125" />
<Element name="orange.tex" u1="0.01171875" u2="0.24609375" v1="0.40625" v2="0.59765625" />
</Elements>
</Atlas>

 

Link to comment
Share on other sites

Adding a bunch of custom prefabs can also make others invisible for the duration of the client session even if switching servers, so I'd guess it would have something to do with memory if not a fault in the game's code.

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