How do I convert text to a comparable expression?

0 favourites
  • 5 posts
From the Asset Store
Change delay, create new lines, "backspace" the text
  • This is going to sound kind of weird, but my dialogue system has the dialogue stored in text files which is then read through ajax and gets used in game. The dialogue currently supports branching paths, neat dialogue effects, etc.

    This is what it looks like at the moment.

    What if I want to check variables to see if dialogue is available? Let's say certain dialogue should only play if a quest is completed. This is easy to do from within Construct itself, but as all the dialogue is stored in these texts, I was hoping I could write the check within the file itself.

    Within the dialogue file it would have something like testingvar=1 or testingvar=true. My testing file uses the example testvar=1 While the screenshot shows the check testvar=1 as part of the branch name, in my game it is properly separated after being read. However, after isolating this expression from the rest of the text from within Construct, it is still represented as a string. It isn't an expression that Construct can actually check.

    Is there a way to convert a string to a readable expression? If so, how do I do it?

    Any help is appreciated :)

    (I apologize if this is hard to understand or read, it's kinda difficult to explain what I'm doing here.)

  • You’ll have to parse the text manually. Here are a few ways but you can do simpler things too. I mean it sounds like you are already doing parsing, you just need to handle math expressions too.

    construct.net/en/forum/construct-3/how-do-i-8/perform-maths-expression-162865

    construct.net/en/forum/construct-3/general-discussion-7/visual-branching-passage-163824

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I really wanted to avoid having to manually check each variable, but I guess I have no choice.

    Still though, I saw a response on of the posts you linked that mentioned using js and the eval function, but unfortunately that didn't work when I used variables instead of regular numbers.

    Is using javascript not a possibility to solve my issue, or will I HAVE to do what you did in your parser example and check if a string is a variable name for each variable I might use?

  • Nevermind, turns out this was redundant and I could have just used the dictionary object, which honestly works better for my needs anyways. Thanks for the help and have a nice Christmas!

  • I didn’t touch js because it’s not portable between c2 and c3. That and I just like straight events over using events.

    Anyways, I don’t use c3. look at the manual though. I think that js has a way to access event sheet variables. Perhaps that would be helpful.

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