Trying to get random to go through numbers 1-9 and not repeat any of them.

33miles33miles Member, BASIC Posts: 71

Hi guys! I am building a word game but am having troubles with random. In my game I have a button that you can tap to get a clue up to 9 times but I never want any of the clues to be repeated unless you restart the level. These clues give 1 of 9 blank tile actors a new letter image one per tap. This is where my problems begin. I have tried to use a table method that tshirtbooth made a video of a few years ago but my game is fairly different. He only uses one actor I use 9, also he uses a self actor and I am using a global. Plus I made my table integer based unlike his text one but I'm not sure if that would cause it not to work. So I followed his video guide as best I could but I'm not very good with tables because I have managed without them for over a year, although I know at some point I will need them to finish my set of games I'm developing. But back on topic, my table has 9 rows each descending down with a number in column 1. The numbers go in order 1 through 9 down the table. Here's a pic of my table:

And here's one of the rule I made for it:

My global attribute that I'm using is an index attribute. So after making this effort I tried it out and they still repeat themselves and only 5 or 6 out of the nine clues even show up. I would be very greatful if someone could point out what I'm doing wrong or tell me if there is another maybe non table way to do this. Please help me if you can and thanks so much for your time. :)

Comments

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

    Your rule is deleting a row and then choosing the row to use. Switch those two behaviors so that the Change Attribute is first and the Add/Remove Row is second.

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

  • SocksSocks London, UK.Member Posts: 12,822

    @tatiang said:
    Your rule is deleting a row and then choosing the row to use. Switch those two behaviors so that the Change Attribute is first and the Add/Remove Row is second.

    tatiang, the table detective™

  • 33miles33miles Member, BASIC Posts: 71

    Hey @tatiang :) Thanks for the quick reply. My code now looks like this:

    Is that what you meant? Because unfortunately it's still doing the same thing. 5 or 6 of the clues activate and then it just stops. Should my game.RandomClues attribute be an index one like it is or an integer? Thanks for the help and I look forward to hearing from you. :)

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

    It doesn't matter if it's an index or integer attribute. Either type will support values between 1 and the number of rows in your table. I generally don't use index values because they aren't supported in Windows Creator but that's up to you.

    You may need to use Log Debugging Statements to monitor the value of game.RandomClues and also display the table rows (if there aren't too many...) on-screen to be able to monitor those.

    If you prefer, upload your project file (.zip it first) to a file-sharing site and then post a download link here and I'll take a look.

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

  • 33miles33miles Member, BASIC Posts: 71

    Hi @tatiang thanks for offering to look at my file. I made a demo of the problem in my game and am posting a link here: https://www.dropbox.com/s/py01t9f18tlswn7/Random Test 0.1.zip?dl=0
    Please take a look and let me know if there's some way we can fix this. Thanks again! :smile:

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

    I see the problem. You're choosing a random value and then checking to see if that random value equals the placeholder value (e.g. the fourth square is number four). Instead, you need to check the tableCellValue at that row.

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

  • 33miles33miles Member, BASIC Posts: 71

    Hey again @tatiang, thanks for checking my demo out. For some reason I'm still not getting it to work. I added that string to each tile and now the tap button does nothing. :'( Did you change anything else that you could show me? Or if you wouldn't mind could you upload the modified file so I can study it and learn from it? Thanks so much tatiang, I really appreciate your help. :smile:

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

    Here's a version that uses only two prototype actors and no instances.

    Note: made with Mac Creator Release Candidate 0.13.8

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

  • 33miles33miles Member, BASIC Posts: 71

    Thanks @tatiang, you made my night!!! It works awesome! And using only 2 actors with no instances was cool and will definitely save a lot of time. It's getting late here so I thank you so much again and I will study your demo more intensely tomorrow but I'm just glad to see that it works. Have a great night and I appreciate your knowledge! :smile:

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

    You're welcome!

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

Sign In or Register to comment.