Can you use a variable to store system expressions?

0 favourites
  • 3 posts
From the Asset Store
290 static tiles (32x32 in size) + 2 animations for use in your project!
  • 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:


    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:

    Function On"fc_callDialog": Set text xml.StringValue("/Conversations/"&currentChapter&"/hint[@id='"&currentVerse&NumberLines&"']/text()") "[/code:3peseoio]
    I will instead be able to do something like  
    [code:3peseoio]Function On"fc_callDialog": Set text variableName[/code:3peseoio]
    (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.
  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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:

    • Add a function, you could call it "getDialog"
    • Add an action "Function.Set return value"
    • Insert your expression in the field
    • 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.

  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)