Page 1 of 1

Getting bool from other script

Posted: Tue Feb 05, 2019 7:07 am
by Dragonception
If I want to set as a condition the bool from a script outside the Dialogue System, how should I proceed?

I have a public bool IsItemInInventory(string searchedObject) in Inventory.cs, which uses the RPG.Core namespace.

Now I want to only display conversation option 2 if this bool returns true for IsItemInInventory("FireEssence"), i.e. I need the true value of this bool to be a condition.

Re: Getting bool from other script

Posted: Tue Feb 05, 2019 10:15 am
by Tony Li
1. Register IsItemInInventory with Lua.
Example

Code: Select all

using PixelCrushers.DialogueSystem;
...
void OnEnable() {
    Lua.RegisterFunction("IsItemInInventory", this, SymbolExtensions.GetMethodInfo(() => IsItemInInventory(string.Empty)));
}

void OnDisable() {
    Lua.UnregisterFunction("IsItemInInventory");
}
2. Set conversation option 2's Conditions field to:

Code: Select all

IsItemInInventory("FireEssence") == true

Re: Getting bool from other script

Posted: Wed Feb 06, 2019 12:12 pm
by Dragonception
Fantastic! That works.