Jump to content

Help needed - custom item, bug when used in backpack


Recommended Posts

I recently uploaded my custom items mod The Scientist Starting Kit to the steam workshop and encountered a small bug that I missed while coding. The custom item writing utensils are useableitems that when activated will check if the custom item Wilson's journal is in your inventory. If it is, he'll use the writing utensil to make an entry. It all works normally when everything is in the regular inventory slots or if the journal is in a backpack slot. However if the writing utensil being used is in a backpack slot, it throws the following error:

 

aedcfa1ed10012fc39f3b19b090c099c.jpg

 

Here's the part code for the writing utensils that's causing the crash:

local function MakeEntry(inst)    local owner = inst.components.inventoryitem and inst.components.inventoryitem.owner    if owner then		--Check if Wilson has his journal		if not owner.components.inventory:Has("wilson_journal", 1) then			if owner.components.talker then				owner.components.talker:Say(GetString(owner.prefab, "ANNOUNCE_NO_JOURNAL"))				return false			end		end

The MakeEntry function is what's called when the useableitem is used. I'm sure there's a quick fix to this and having it check a container owner or something to that accord but I'm not sure exactly how to. A little help would be very much appreciated.

Link to comment
Share on other sites

Fixed. I changed the following to check merely for the player rather than the item's "owner". Feel a little dumb now.

local function MakeEntry(inst)    local owner = GetPlayer()    if owner then		--Check if Wilson has his journal		if not owner.components.inventory:Has("wilson_journal", 1) then			if owner.components.talker then				owner.components.talker:Say(GetString(owner.prefab, "ANNOUNCE_NO_JOURNAL"))				return false			end		end	
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...