Page 1 of 1

Variables

Posted: Sun Dec 30, 2018 2:53 pm
by pegassy
So far I have been using the variables system for kill counts quests and also for setting up conversation conditions without using quest conditions. I am trying to step up my use of variables, but I have realized that I do not really know where they are stored and how to access them properly, and whether or not they may be used in conjunction with UCC attributes.

So to chunk it out, I have a few questions:

1) Is there a way to call out a variable and show it in a text window or assign it to a slider? (quest tracker and alerts do use [var=x] to show a variable, but I could not make that work in a text window. Could you point to where I should look at in the documentation for this.

2) Is there a possibility of integrating those with the Attribute values of UCC? For example, if you have an intelligence of 5 (DSU variable) then the attribute value "Mana" for UCC can be set up to be 5x intelligence.

Thank you for bearing with the noob questions.

Re: Variables

Posted: Sun Dec 30, 2018 4:58 pm
by Tony Li
pegassy wrote: Sun Dec 30, 2018 2:53 pmSo far I have been using the variables system for kill counts quests and also for setting up conversation conditions without using quest conditions. I am trying to step up my use of variables, but I have realized that I do not really know where they are stored and how to access them properly, and whether or not they may be used in conjunction with UCC attributes.
At runtime, the Dialogue System runs a Lua scripting environment. When it loads a dialogue database, it puts the database's variable values, quest states, etc., into Lua. You can put Lua code in your dialogue entry nodes' Conditions and Script fields. Typically you'll do it through the "..." dropdown menus, but you can also type in the Lua code manually. When the Dialogue System saves a game, it essentially just dumps the contents of the Lua environment into the saved game. You can read more about Lua here: Logic & Lua.
pegassy wrote: Sun Dec 30, 2018 2:53 pm1) Is there a way to call out a variable and show it in a text window or assign it to a slider? (quest tracker and alerts do use [var=x] to show a variable, but I could not make that work in a text window. Could you point to where I should look at in the documentation for this.
You may need to do a tiny bit of scripting or use an equivalent visual scripting action. In a C# script, use the DialogueLua.GetXXX() and SetXXX() functions as described in How To Use Lua In Your C# Scripts. For example:

Code: Select all

using PixelCrushers.DialogueSystem; // Put this line at the top of your script.
...
int x = DialogueLua.GetVariable("x").asInt;
MySlider.value = x;
If you want to process [var=x] and [lua(code)] markup tags in a string, use FormattedText.ParseCode():

Code: Select all

MyUIText.text = FormattedText.ParseCode("The value of x is [var=x].");
This is what the quest tracker and alert panel do.
pegassy wrote: Sun Dec 30, 2018 2:53 pm2) Is there a possibility of integrating those with the Attribute values of UCC? For example, if you have an intelligence of 5 (DSU variable) then the attribute value "Mana" for UCC can be set up to be 5x intelligence.
The UCC integration adds special Lua functions to get and set attributes and items. For example, let's say you have a DSU variable named "intelligence". In Lua, this would be:

Code: Select all

Variable["intelligence"]
To set the UCC attribute "Mana":

Code: Select all

uccSetAttribute("", "Mana", 5 * Variable["intelligence"])
(If the first parameter is blank, it applies to the player.)

It's possible to tie activity dynamically to variable changes, such as automatically increasing Mana whenever Variable["intelligence"] changes. But this is usually pretty case-specific and involves a bit more work.

Re: Variables

Posted: Sun Dec 30, 2018 5:16 pm
by pegassy
As always, thank you so much for the detailed explanation Tony. I appreciate it.

Re: Variables

Posted: Mon Dec 31, 2018 8:31 am
by Tony Li
Always glad to help!