Error in Corgi Inventory Example

Announcements, support questions, and discussion for the Dialogue System.
lostmushroom
Posts: 194
Joined: Mon Jul 01, 2019 1:21 pm

Error in Corgi Inventory Example

Post by lostmushroom »

I'm getting a few issues with the Corgi Inventory Example. When Dude1 gives you a teddy bear, the console shows the following errors.

- The referenced script (Unknown) on this Behaviour is missing
- The referenced script on this Behaviour (Game object 'Dialogue Manager') is missing
- Dialogue System: Lua code 'mmAddItem("MainInventory", "Teddy", 1)' threw exception 'Tried to invoke a function call on a non-function value. If you're calling a function, is it registered with Lua?'
UnityEngine.Debug:LogError(Object)

And the teddy bear does not show up in Inventory.

Is this just a simple missing script or is there something else going on here?

Thanks for your help :)
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: Error in Corgi Inventory Example

Post by Tony Li »

Hi,

That example also uses Inventory Engine, which is an inventory system included with Corgi. Did you import the Dialogue System's Inventory Engine Support package?
lostmushroom
Posts: 194
Joined: Mon Jul 01, 2019 1:21 pm

Re: Error in Corgi Inventory Example

Post by lostmushroom »

Oops, no I didn't! I'll do that and see if it works.
lostmushroom
Posts: 194
Joined: Mon Jul 01, 2019 1:21 pm

Re: Error in Corgi Inventory Example

Post by lostmushroom »

Imported the support package, the scene works now.

I have another question. How can I add conditions relating to the inventory to dialogue options? Let's say I want to have a dialogue option show up only if the player has 5 coins in their inventory. What's the best way to go about this?
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: Error in Corgi Inventory Example

Post by Tony Li »

Hi,

Use the Inventory Engine Lua Functions documented on the Inventory Engine Support page.

For example:
  • Dialogue Text: "Hey, moneybags! Can you spare some of those coins?"
  • Conditions: mmGetQuantity("MainInventory", "Coin") >= 5
lostmushroom
Posts: 194
Joined: Mon Jul 01, 2019 1:21 pm

Re: Error in Corgi Inventory Example

Post by lostmushroom »

Ah nice, I almost had it. I was missing the >=5 which seems very obvious now... :D

Thanks!
lostmushroom
Posts: 194
Joined: Mon Jul 01, 2019 1:21 pm

Re: Error in Corgi Inventory Example

Post by lostmushroom »

Just tried it, getting an error unfortunately.

Dialogue System: Lua code 'return mmGetQuantity(MainInventory, Coin) >=1;' threw exception 'Exception has been thrown by the target of an invocation.'
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: Error in Corgi Inventory Example

Post by Tony Li »

Use quotes, like this:

Code: Select all

mmGetQuantity("MainInventory", "Coin") >= 5
Also, the inventory name (e.g., "MainInventory") must exactly match the name of your inventory GameObject. In the Dialogue System's Corgi Inventory Example scene, this GameObject is named "MainInventory".

The second parameter, "Coin", must be the name of an Inventory Engine item.
lostmushroom
Posts: 194
Joined: Mon Jul 01, 2019 1:21 pm

Re: Error in Corgi Inventory Example

Post by lostmushroom »

The code is working, but the quest isn't playing as I intended. Maybe I've missed something.

I have two dialogue options: "I have a coin" and "I don't have a coin".

The condition for "I have a coin" is: mmGetQuantity("MainInventory", "Coin") >=1;
The condition for "I don't have a coin" is: mmGetQuantity("MainInventory", "Coin") <=0;

However, even if you have 1 coin, the option "I have a coin" doesn't show up. The only way I can get it to show it to change the condition from >=1 to .=0, but then both options show up. Have I made a mistake somewhere?

Thanks for all your help btw, it's appreciated.
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: Error in Corgi Inventory Example

Post by Tony Li »

Try removing the ";" at the end.

You only need a semicolon to separate statements. Since your condition only has one statement, you don't need it.

For debugging, you can also type:

Code: Select all

return mmGetQuantity("MainInventory", "Coin")
into the "Run" bar at the bottom of the Dialogue Editor's Watches section, or in a Lua Console at runtime. You can also enter the full conditions, such as:

Code: Select all

return mmGetQuantity("MainInventory", "Coin") >=1
and:

Code: Select all

return mmGetQuantity("MainInventory", "Coin") <=0
to see what results they return.
Post Reply