Page 1 of 1

Error in Kill quest

Posted: Wed Mar 29, 2017 11:22 am
by OneManOnMars
Hi,

I am trying to set up a normal kill quest.

This is what I did:

I added a variable wolfKills to the Variables tab
Image

I have 3 Enemies that have a an increment on Destroy Script attached to them:
Image

and I have this Quest here setup:
Image

And I have this Diaolgue Entry that asks for this condition:
Image

Quest["SaveMe"].State == "active" and Variables["wolfKills"]>=3

And I get this error message:
Dialogue System: Lua code 'return Quest["SaveMe"].State == "active" and Variables["wolfKills"]>=3' threw exception 'Lookup of field 'wolfKills' in the table element failed because the table element itself isn't in the table.'
UnityEngine.Debug:LogError(Object)
PixelCrushers.DialogueSystem.Lua:RunRaw(String, Boolean, Boolean)
PixelCrushers.DialogueSystem.Lua:Run(String, Boolean, Boolean)
PixelCrushers.DialogueSystem.Lua:IsTrue(String, Boolean, Boolean)

If I remove the part (and Variables["wolfKills"]>=3) it does work. But I need to check if these nasty wolfs are dead or not.

What I am doing wrong. I allready spent half a day on that. In another forum post I have read, that the part with the tables means that the variable is not set. But as you can see I have set it. So....

Your help would be very much appreciated!!

Re: Error in Kill quest

Posted: Wed Mar 29, 2017 11:32 am
by Tony Li
Hi,

Change "Variables" to "Variable". Or use the Lua wizard to write the Lua code for you. I use the Lua wizards a lot, not just because I'm lazy ;) but also because it helps reduce typos.

Example screenshot:
Image

Re: Error in Kill quest

Posted: Wed Mar 29, 2017 11:51 am
by OneManOnMars
Hi Tony,

awesome! :o I just did not know that wizard exists! Face Palm.
So I get closer to the functioning quest. The message error is gone. But somehow the wolfKill gets not incremented when killing a wolf. Is there more to it then just adding the script to the enemy and entering the proper values?

Because it does work if I go to the Variables tab and set the wolfKills to 3.
So it must be the increment on destroy script.

Re: Error in Kill quest

Posted: Wed Mar 29, 2017 12:06 pm
by Tony Li
As a debugging step, inspect the Increment On Destroy component and specify an Alert Message such as:

Code: Select all

Wolves Killed: [var=wolfKills]
This will let you know when the Increment On Destroy component is working.

When the player kills a wolf, does it destroy the wolf GameObject? If it only disables the GameObject, change Increment On to Disable. Many frameworks, such as UFPS and ICE, just disable the GameObject and return it to a pool for recycling.

If killing a wolf doesn't disable or destroy it, you'll need to use a different component than Increment On Destroy. In this case, let me know what happens to the wolf GameObject when it's killed; I'll try to suggest a solution.

Re: Error in Kill quest

Posted: Wed Mar 29, 2017 12:17 pm
by OneManOnMars
Thanks again Tony!

This helped me out! It is embarrassing to say but it was another typo in the script!

But this will not be the last quest so I guess your lessons will help me from now on.

Thank you for your help.

Re: Error in Kill quest

Posted: Wed Mar 29, 2017 12:18 pm
by Tony Li
Glad I could help!