Result of math problem in string

  • Hoping someone can help me out on what seems to be a simple problem.

    I'm making a simple math game for kids and want to have a problem display and the answer in a random location. I figured it would be as easy as doing

    question text string:

    int(random(0,20))&"+"&int(random(0,20))

    then a correct answer text string

    int(question.TEXT)

    Question displays fine but the answer only shows the first integer. How can I convert the entire string so that it gives the result?

    I thought about making two sets of variables which could be put together in the question and then added together for the answer but this seems like it would become overly complicated as I start adding levels with other operands, carrying and the like.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I had made this example a long time ago.

    At the time functions weren't yet implemented in C2, but this example should still work.

  • Great!

    Seems like there should be a simpler way but it certainly helps to look though what you've done.

    My seven year old son will be thrilled as well. The whole design of this game was his idea. I'll post it later. :)

    Thanks.

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