Hello,
I'm currently implementing a mechanic where the player can choose a card from their collection during a conversation. This temporarily switches to a separate conversation, which immediately branches based on if the card played was right for the active dialogue node at the time. This is done by comparing two strings; the chosen card's name and a custom CardRequired field in the node. If the strings match, variable CorrectCardChosen should become true, which enables one dialogue link and disables another. If the strings don't match, the variable stays false and directs to another dialogue node.
My problem is that I'm unable to change the variable which does the branching at runtime. I attempted to change this via the code attached below, and can confirm via Variable Viewer that not changing the bool is where the process stops.
What might I be doing wrong?
How to change boolean variable at runtime through script?
-
- Posts: 5
- Joined: Tue Mar 18, 2025 10:02 am
How to change boolean variable at runtime through script?
- Attachments
-
- Näyttökuva 2025-04-22 184721.png (17.74 KiB) Viewed 503 times
Re: How to change boolean variable at runtime through script?
Hi,
Consider the dialogue database to be static (read-only) at runtime.
The runtime variable values are in the Lua environment. Use the DialogueLua class to set the runtime value:
Consider the dialogue database to be static (read-only) at runtime.
The runtime variable values are in the Lua environment. Use the DialogueLua class to set the runtime value:
Code: Select all
DialogueLua.SetVariable("CorrectCardChosen", true);
-
- Posts: 5
- Joined: Tue Mar 18, 2025 10:02 am
Re: How to change boolean variable at runtime through script?
Hello Tony,
Thank you for the swift and clear response. This did just what I needed to. I've only been using the System for about a month now and haven't looked much into Lua yet. Clearly that's something I should do some reading on one of these days
Thank you for the swift and clear response. This did just what I needed to. I've only been using the System for about a month now and haven't looked much into Lua yet. Clearly that's something I should do some reading on one of these days

Re: How to change boolean variable at runtime through script?
Glad to help! In general you don't need to look too deeply into Lua. You can use the C# methods such as DialogueLua.SetVariable(), and for dialogue entries' Conditions and Script fields you can use the "..." dropdown menus.