(S) How can I read certain lines of text from the C2 textbox

0 favourites
  • 7 posts
From the Asset Store
Forget about default textbox restrictions, you can create sprites atop of the textbox
  • (Solved)

    Hey there!

    I'm trying to make a coding/hacking game in the stile of TIS-100, but I don't know how to "read" certain lines that the player would type and how to make C2 recognize certain words (like "move" or "rotate") in order to assign them functions.

    (Photo from TIS-100)

    In each square you can write a couple of commands, and the game executes them from top to bottom, but doesn't go to the next command until the current one has finished.

    Any idea on how to do this?

    Thanks!

  • bump...

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • To get a certain line from some text you can use the tokenat() expression:

    tokenat(TextBox.text, 0, newline)

    The 0 means get the first line, 1 the second, and so on.

    Beyond that you could use tokenat again to get individual words if you seperate everything with spaces or something. What that's called is a parser and there are also lots of other ways to do it. You could do a forum search for parser to see various examples to maybe get some ideas.

  • To get a certain line from some text you can use the tokenat() expression:

    tokenat(TextBox.text, 0, newline)

    The 0 means get the first line, 1 the second, and so on.

    Beyond that you could use tokenat again to get individual words if you seperate everything with spaces or something. What that's called is a parser and there are also lots of other ways to do it. You could do a forum search for parser to see various examples to maybe get some ideas.

    Awesome, thank you!

  • ...Beyond that you could use tokenat again to get individual words if you seperate everything with spaces or something. What that's called is a parser and there are also lots of other ways to do it. You could do a forum search for parser to see various examples to maybe get some ideas.

    Hey, I have searched for parser on the forum, but I haven't found anything about them...

    Could you show me how to use tokenat for individual words?

  • Here are the posts I was thinking of:

    Those ways give more control than tokenat, but the way to get indavidual words seperated by spaces is the same as the one to get lines except " " is used instead of newline.

    I also know regex could possibly be used somehow.

  • Here are the posts I was thinking of:

    Those ways give more control than tokenat, but the way to get indavidual words seperated by spaces is the same as the one to get lines except " " is used instead of newline.

    I also know regex could possibly be used somehow.

    Great, thank you very much!

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