Random Text in text box

I'm making a game where once you hit play it gives you some text like a math problem then if you tab that text it will show you the answer and if you top again it brings you to the next question how could I do something like that?

Comments

  • bob loblawbob loblaw Member, PRO Posts: 793

    try this as a starting point. click on the equation or hit tab to display the answer.

  • GrimmGhostsGrimmGhosts Member, PRO Posts: 33

    It works really well thank you for the help I will port over the stuff I already had again thank you!

  • GrimmGhostsGrimmGhosts Member, PRO Posts: 33

    Sometimes I want there to be a word problem like there Is button if you click it it will bring you to a scene with only word problems that get pulled from a table I would make could I do something like that and the same thing where if you tap the answer box it gives you the answer

  • JB makin' a gameJB makin' a game Member, BASIC Posts: 39
    edited November 2018

    First of all, using tables for your math and word problems sounds like a good idea indeed. The quick project Bob made for you is meant to point you in a possible direction and give inspiration. However, and I'm sure Bob agrees, if you create a whole bunch of math problems and put them in a table (in separate cells), the set up for your game will be different from what his project is showing you. Again, he's just giving you food for thought.

    I'll add some of that food, while I'm at it...
    It sounds like the math problems show up pretty much the same as the word problems in your game, the difference being that math problems are the default setting and for word problems to show up, a button needs be clicked. If I'm correct in this assumption, you don't want to create a separate scene for word problems, because you're only gonna change a minor thing in the scene you're already in (displaying word problems instead of math problems).

    You'll have to create logic that changes the displayed problem and the respective answers. If you have the math and word problems in separate tables (I don't know how the rest of your project looks like), you'll need a rule in the actor that display the problem that says something like:
    if (boolean) attribute: mathProblem = true,
    display: Table Math, row: whatever, column: 1 (and whatever logic you have for displaying your problem)
    if answerIsClicked, display Table Math, row: whatever, column: 2 (the answer is in column 2)
    if (boolean) attribute: wordProblem = true,
    display: Table Word row: whatever, column: 1
    if answerIsClicked, display Table Word, row: whatever, column: 2

    If both the math and word problems are in different columns of the same table, it'll be easier to put into logic, but you'll have to see for yourself if that works for you... You create attributes that represent your column numbers for math and word problems, let's call them currentProbColumn and currentAnswColumn.
    display: tableCellValue(TableProblems, row: whatever, column: currentProbColumn)
    if answerIsClicked, display tableCellValue(TableProblems, row: whatever, column: currentAnswColumn)

    if mathProblem = true, set currentProbColumn to 1 and currentAnswColumn to 2
    if wordProblem = true, set currentProbColumn to 3 and currentAnswColumn to 4

    I typ quicker than I zip files, so you'll have to do with the above. Mind you, this is far from perfect. It's just another hint in a possible direction. There are many different ways to do what you want. Keep puzzling, you'll get there!

  • GrimmGhostsGrimmGhosts Member, PRO Posts: 33

    if I have an integer how could I make it pull the row that equals the value of the integer like the value of the integer is 8 how could I make it display the text from row 8?

  • JB makin' a gameJB makin' a game Member, BASIC Posts: 39
    edited November 2018

    That is actually quite straightforward, using tableCellValue. I have no particular problem answering questions like these, but it wouldn't hurt to watch some tutorials about tables.
    I'm relatively new to GameSalad as well and watching just a few videos about tables (just typ "tables in gamesalad" or something more or less specific in YouTube) has helped me enormously, to the point that I've just finished setting up a table that starts with 5 columns of three different types and 1 row with empty cells and ends up with about 5000 rows during runtime, each column filled with different data and unique and randomized data throughout the rows, that corresponds with the boolean column, which checks whether it's relevant or not in the given scenario. A bit of a puzzle, but all created with just a handful of functions, attributes and rules, that make a different game every time you play it. It'd be a nightmare to fill up this table manually and even if I did so, it would use the same set of data every time.

    I write this to give a tiny peek into the possibilities of writing to tables. Mastering it (an achievement that I haven't reached by any means) will make your programming days a lot more comfortable.
    To get you started, here's one of the videos that has helped me understand tables. I haven't used anything of what he does in the video specificly, but playing with the functions gives you an insight in tables that's hard to figure out on your own.

  • GrimmGhostsGrimmGhosts Member, PRO Posts: 33

    Thank you so much I figured out my problem thanks JB and Bob

  • GrimmGhostsGrimmGhosts Member, PRO Posts: 33

    and how do I close this conversation? sorry this is my first discussion here on gamesalad

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    @GrimmGhosts You aren't able to close a thread. Only forums moderators (aka Sous Chefs) can do that. We typically don't close threads unless there's a unique reason to do so. Inactive threads tend to disappear quickly as new threads are created so not to worry.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

Sign In or Register to comment.