Page 1 of 1

Use c# registered functions in quest descriptions

Posted: Tue Aug 09, 2022 7:24 pm
by kimosabe
Hi,

I used the following to be able to use a C# function in the conditions and scripts part of the dialogue system

Code: Select all

    void OnEnable()
    {
        Lua.RegisterFunction("ItemInInventory", this, SymbolExtensions.GetMethodInfo(() => ItemInInventory(string.Empty)));

    }

    void OnDisable()
    {
        Lua.UnregisterFunction("ItemInInventory");
    }

    public double ItemInInventory(string itemName)
    {
        return (double)inventoryController.GetAmountOfItem(itemName);
    }
Which works perfectly fine, now I was wondering if and how I can use that function to display the value in my quest descriptions?

Like:
Items collected:
Cheese (ItemInInventory("Cheese") / 1)

I could've sworn that I read somewhere that this is possible but I can't find it anymore or get it to work.
Any help would be appreciated!

- Kimosabe

Re: Use c# registered functions in quest descriptions

Posted: Tue Aug 09, 2022 9:50 pm
by Tony Li
Hi,

Use the [lua(code)] markup tag.

Code: Select all

Items collected:
Cheese ([lua(ItemInInventory("Cheese"))] / 1)

Re: Use c# registered functions in quest descriptions

Posted: Wed Aug 10, 2022 6:54 am
by kimosabe
See below

Re: Use c# registered functions in quest descriptions

Posted: Wed Aug 10, 2022 6:55 am
by kimosabe
Tony Li wrote: Tue Aug 09, 2022 9:50 pm Hi,

Use the [lua(code)] markup tag.

Code: Select all

Items collected:
Cheese ([lua(ItemInInventory("Cheese"))] / 1)
This doesn't seem to be working for me?

Image

Re: Use c# registered functions in quest descriptions

Posted: Wed Aug 10, 2022 8:26 am
by Tony Li
Please use a lowercase "l" (L) in [lua(code)]

Re: Use c# registered functions in quest descriptions

Posted: Wed Aug 10, 2022 10:02 am
by kimosabe
Tony Li wrote: Wed Aug 10, 2022 8:26 am Please use a lowercase "l" (L) in [lua(code)]
I'm an idiot, thank you very much!

Re: Use c# registered functions in quest descriptions

Posted: Wed Aug 10, 2022 10:11 am
by Tony Li
No worries; happy to help!

Re: Use c# registered functions in quest descriptions

Posted: Wed Aug 10, 2022 10:20 am
by kimosabe
Tony Li wrote: Wed Aug 10, 2022 10:11 am No worries; happy to help!
Can you make sure that the method is being called right before displaying the information? Or is there a way to force update?

Re: Use c# registered functions in quest descriptions

Posted: Wed Aug 10, 2022 10:39 am
by Tony Li
Yes, it's called right before displaying the text. To manually update, call DialogueManager.SendUpdateTracker(). This will update the quest tracker HUD and the quest log window if the quest log window is open.