Page 1 of 1

Using Inventory Master: Error when condition checks for item on player while talking to NPC

Posted: Mon Feb 13, 2017 12:49 pm
by EonNomad
Hi, I'm using the Inventory Master asset and am using the Inventory Master Lua script that you emailed me about a week ago.

When I attach the Inventory Master Lua script on the Dialogue Manager in my own scene and set an NPC dialogue node with the following condition: PlayerHasItem("Normerica Lens") == true

I receive this error as the dialogue starts when scene starts:

Code: Select all

Dialogue System: Lua code 'return PlayerHasItem("Normerica Lens") == true' threw exception 'Exception has been thrown by the target of an invocation.'
UnityEngine.Debug:Lo.DialogueSystem.ConversationModel:EvaluateLinksAtPriority(ConditionPriority, DialogueEntry, List`1, List`1, List`1, Boolean)
PixelCrushers.DialogueSystem.ConversationModel:EvaluateLinks(DialogueEntry, List`1, List`1, List`1, Boolean)
PixelCrushers.DialogueSystem.ConversationModel:GetState(DialogueEntry, Boolean, Boolean, Boolean)
PixelCrushers.DialogueSystem.ConversationModel:.ctor(DialogueDatabase, String, Transform, Transform, Boolean, IsDialogueEntryValidDelegate, Int32, Boolean, Boolean)
PixelCrushers.DialogueSystem.DialogueSystemController:StartConversation(String, Transform, Transform, Int32)
PixelCrushers.DialogueSystem.DialogueSystemController:StartConversation(String, Transform, Transform)
PixelCrushers.DialogueSystem.DialogueManager:StartConversation(String, Transform, Transform)
PixelCrushers.DialogueSystem.ConversationStarter:StartConversation(Transform)
PixelCrushers.DialogueSystem.ConversationStarter:TryStartConversation(Transform, Transform)
PixelCrushers.DialogueSystem.ConversationStarter:TryStartConversation(Transform)
PixelCrushers.DialogueSystem.<StartConversationAfterOneFrame>c__Iterator19:MoveNext()
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)gError(Object)
PixelCrushers.DialogueSystem.Lua:RunRaw(String, Boolean, Boolean)
PixelCrushers.DialogueSystem.Lua:Run(String, Boolean, Boolean)
PixelCrushers.DialogueSystem.Lua:IsTrue(String, Boolean, Boolean)
PixelCrushers
The ending of the error changes slightly when I go and talk to the character again :

Code: Select all

PixelCrushers.DialogueSystem.ConversationTrigger:OnUse(Transform)
UnityEngine.GameObject:BroadcastMessage(String, Object, SendMessageOptions)
PixelCrushers.DialogueSystem.ProximitySelector:Update() (at Assets/Dialogue System/Scripts/Supplemental/Utility/ProximitySelector.cs:173)
I've attached an image to show that I put the code in the Condition parameter and it's only on the right most node in the node view window.
If I change my item name which is already set in the item database in Inventory Master, and replace it with one that already exists in the database, I still get the same error.

Just in case this matters, I'm using the Proximity Selector on my character to detect NPC's when facing them. This does not occur at all when I'm in the example scene that you made for the IM asset.

Might I be missing a component or setting a parameter wrong somewhere?

Re: Using Inventory Master: Error when condition checks for item on player while talking to NPC

Posted: Mon Feb 13, 2017 1:15 pm
by Tony Li
Hi,

That error means the C# function I wrote, PlayerHasItem(), encountered a problem. Later today, I'll update the script to include more error messages and better error recovery, and I'll post it here. It's probably a minor configuration issue. With more error messages, you should be able to identify the issue so you can resolve it.

Re: Using Inventory Master: Error when condition checks for item on player while talking to NPC

Posted: Mon Feb 13, 2017 1:25 pm
by EonNomad
Ahh okay, thank you very much!

Re: Using Inventory Master: Error when condition checks for item on player while talking to NPC

Posted: Mon Feb 13, 2017 8:39 pm
by Tony Li
Here's an updated package: InventoryMasterIntegration_2017-02-13.unitypackage

I suspect your Player Inventory component's Character System field was unassigned. The updated package handles that more gracefully, and it will also print a more helpful error message in the console if it runs into an error. If you still get an error message after checking the Character System field, please paste it in here like you pasted the previous message.

Re: Using Inventory Master: Error when condition checks for item on player while talking to NPC

Posted: Tue Feb 14, 2017 4:01 pm
by EonNomad
Yes, my Character System field was empty. I had it empty because I don't equip anything on my character but I just made the prefab, linked it to the field and it is working now.

On the console view, I had the Warnings clicked so that they didn't come up. I don't know if you had warnings come up before the script update but I'm now aware that you use those to communicate that something is missing etc.

Thanks again!

Re: Using Inventory Master: Error when condition checks for item on player while talking to NPC

Posted: Tue Feb 14, 2017 4:07 pm
by Tony Li
Happy to help! Yes, the Dialogue System will often log warnings if things aren't quite right. It's a good idea to review these every once in a while to make sure it's all working correctly.