Read updating time and day

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
xyztankman
Posts: 54
Joined: Mon Jun 21, 2021 7:48 pm

Read updating time and day

Post 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");
    }
    
    
    
Attachments
DialogueVariables.JPG
DialogueVariables.JPG (17.32 KiB) Viewed 496 times
User avatar
Tony Li
Posts: 21987
Joined: Thu Jul 18, 2013 1:27 pm

Re: Read updating time and day

Post 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.
xyztankman
Posts: 54
Joined: Mon Jun 21, 2021 7:48 pm

Re: Read updating time and day

Post by xyztankman »

Hey Tony, thanks! I didn't notice the Watches page before. All good!
User avatar
Tony Li
Posts: 21987
Joined: Thu Jul 18, 2013 1:27 pm

Re: Read updating time and day

Post by Tony Li »

Glad to help!
Post Reply