Page 1 of 1

Calling script to set a variable

Posted: Sat Mar 17, 2018 5:06 pm
by timbecile
Hey Tony! on to another problem...

I'm trying to use a script to set a value called "HealingCost", but it doesn't seem to be working.

The LUA Script code:

Code: Select all

Variable["HealingCost"] = GetHealingCost()
and the script code:

Code: Select all

    private void OnEnable()
    {

        Lua.RegisterFunction("GetHealingCost", this, GetType().GetMethod("GetHealingCost"));

    }

    private void OnDisable()
    {
        Lua.UnregisterFunction("GetHealingCost");
    }

   double GetHealingCost()
    {
        Debug.Log("geting healing cost");
        double healingCost = 101;
        return healingCost;
    }
It appears to be doing something because it's setting the HealingCost var to 'nil' when I reach the dialog

Re: Calling script to set a variable

Posted: Sat Mar 17, 2018 5:59 pm
by timbecile
duh. Nevermind.

My problem was that the function wasn't public.