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

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
EonNomad
Posts: 3
Joined: Sat Feb 11, 2017 4:33 pm

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

Post 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?
Attachments
Screenshot (20).png
Screenshot (20).png (198 KiB) Viewed 662 times
User avatar
Tony Li
Posts: 22062
Joined: Thu Jul 18, 2013 1:27 pm

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

Post 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.
EonNomad
Posts: 3
Joined: Sat Feb 11, 2017 4:33 pm

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

Post by EonNomad »

Ahh okay, thank you very much!
User avatar
Tony Li
Posts: 22062
Joined: Thu Jul 18, 2013 1:27 pm

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

Post 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.
EonNomad
Posts: 3
Joined: Sat Feb 11, 2017 4:33 pm

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

Post 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!
User avatar
Tony Li
Posts: 22062
Joined: Thu Jul 18, 2013 1:27 pm

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

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