Page 1 of 1

Read updating time and day

Posted: Mon Jun 28, 2021 12:08 pm
by xyztankman
Hey, I've tried a couple different methods trying to have the time and date update along with my C# script. I tried both below methods and there is no variable change when observed at runtime.

Code: Select all

public static double minute, hour, day, second, month, year;

    public void SendToDialogueSystem()
    {
        DialogueLua.SetVariable("Second", second);
        DialogueLua.SetVariable("Minute", minute);
        DialogueLua.SetVariable("Hour", hour);
        DialogueLua.SetVariable("Day", day);
        DialogueLua.SetVariable("Month", month);
        DialogueLua.SetVariable("Year", year);
    }

    public void HourTracker(double hourUpdate)
    {
        hour = (double)hourUpdate;
    }

    public void DayTracker(double dayUpdate)
    {
        day = (double)dayUpdate;
    }
    
    ...
    
    void Update()
    {
        CalculateTime();
        CalculateSeason();
        SendToDialogueSystem();
    }
    
    ...
    
    void OnEnable()
    {
        // Make the functions available to Lua: (Replace these lines with your own.)
        Lua.RegisterFunction("HourTracker", this, SymbolExtensions.GetMethodInfo(() => HourTracker(hour)));
        Lua.RegisterFunction("DayTracker", this, SymbolExtensions.GetMethodInfo(() => DayTracker(day)));
    }

    void OnDisable()
    {
            Lua.UnregisterFunction("HourTracker");
            Lua.UnregisterFunction("DayTracker");
    }
    
    
    

Re: Read updating time and day

Posted: Mon Jun 28, 2021 1:09 pm
by Tony Li
Hi,

If you're watching the Dialogue Editor's Variables page, notice that the value column is titled "Initial Value". This is the initial starting value. To see the current runtime value of a variable, use the Watches page or the separate Variable Viewer window.

Re: Read updating time and day

Posted: Thu Jul 01, 2021 10:08 am
by xyztankman
Hey Tony, thanks! I didn't notice the Watches page before. All good!

Re: Read updating time and day

Posted: Thu Jul 01, 2021 10:46 am
by Tony Li
Glad to help!