Jump to content

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.

Edited by Icrangirl

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	

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
×
  • Create New...