Can you use a variable to store system expressions?

Get help using Construct 2

Post » Sun Feb 19, 2017 5:17 pm

Sorry if that title is hard to understand, I wasn't sure the best way to word it. Anyway...
What I am wondering is can I store an expression to be used as a variable?

For example:
In my dialog system I am using this text to let my function know which dialog to call from the XML and set it:
xml.StringValue("/Conversations/"&currentChapter&"/hint[@id='"&currentVerse&NumberLines&"']/text()")

Now rather than copying and pasting this into every use, is there a way to set say a constant variable to hold that text and then apply it when needed, so that
rather that having:
Code: Select all
Function On"fc_callDialog": Set text xml.StringValue("/Conversations/"&currentChapter&"/hint[@id='"&currentVerse&NumberLines&"']/text()") "


I will instead be able to do something like
Code: Select all
Function On"fc_callDialog": Set text variableName


(I am sorry if this isn't well explained, it is difficult to word the exact question)

The issue is that it simply calls the variable as a string of text rather than considering any of as an expression? I get the feeling it isn't possible to do this in Construct but I thought I would check if anybody here knows something I don't about doing this.
B
21
S
6
Posts: 17
Reputation: 1,372

Post » Sun Feb 19, 2017 5:29 pm

As far as I know, that isn't possible, since expressions aren't strings.
If you would load the expressions from a variable, C2 would load them as strings and not as expressions.

If you only want to simplify your "fc_callDialog" function, you could do the following:
  1. Add a function, you could call it "getDialog"
  2. Add an action "Function.Set return value"
  3. Insert your expression in the field
  4. Now, in your fc_callDialog function, set the text to "Function.Call("getDialog")"

This won't make the whole process less complicated, but it will keep the mess in the fc_callDialog function to a minimum.
"We can't solve problems by using the same kind of thinking we used when we created them."
- Albert Einstein
B
27
S
11
G
8
Posts: 528
Reputation: 7,091

Post » Sun Feb 19, 2017 9:26 pm

@randomly : Yeah that works grand, I was using params to hold it but the returnvalue is a bit cleaner - Cheers. It's a pity, would be super handy to be able to just throw a bunch of expressions into a var and pull it when needed.
B
21
S
6
Posts: 17
Reputation: 1,372


Return to How do I....?

Who is online

Users browsing this forum: Lancifer and 28 guests