Problem with number values
Dasdingomon
Member Posts: 2
Good evening everyone.
The game I am trying to create is simple. There will be 18 actors, all of them wil get a random number between 1 and 18. In order to finish the game you will start from 1 and continue to 18 in numerical order. I am not very experienced with GameSalad and I have been stuck with a problem for two days now.
The part where I am stuck with is that i have created 18 actors. All of these actors are supposed to get a number between 1 and 18, with none of the numbers are allowed to be used twice.
In order to number my actors, I have created a table with 1 row and 18 columns, it is called Table 1. All columns are set to integer. I have numbered like column 1 = 1, column 2 = 2 , column 18 = 18 etc.
The numbers are linked with the actors by a 'Display Text' behavior. This is the way i assigned the numbers with the actors:
tableCellValue( game.Table 1, 1, random(1, 18))
(game.Table 1 is the table with 1 row and 18 columns as mentioned above.
The situation now is that my actors get a random number between 1 and 18, but the problem is some numbers are getting picked twice.
What I want to achieve is that my actors get numbered between 1 and 18 with none of the numbers getting used twice, so the players are able to start with 1 and destroy the actors by pressing them in numerical order.
Also a side question is: I have looked up the most of the GameSalad Cookbook guides on youtube and havent been able to find a video which explains how you are able to put prioritys on actors. As you probably have figured out my game idea, this will be needed to tell the system which actor has to be pressed in what order.
I hope that I have pointed out my problem clearly. If there is still a point which is unclear, I am willing to give more detailed information.
/Mustafa 'Dasdingomon' Seker
The game I am trying to create is simple. There will be 18 actors, all of them wil get a random number between 1 and 18. In order to finish the game you will start from 1 and continue to 18 in numerical order. I am not very experienced with GameSalad and I have been stuck with a problem for two days now.
The part where I am stuck with is that i have created 18 actors. All of these actors are supposed to get a number between 1 and 18, with none of the numbers are allowed to be used twice.
In order to number my actors, I have created a table with 1 row and 18 columns, it is called Table 1. All columns are set to integer. I have numbered like column 1 = 1, column 2 = 2 , column 18 = 18 etc.
The numbers are linked with the actors by a 'Display Text' behavior. This is the way i assigned the numbers with the actors:
tableCellValue( game.Table 1, 1, random(1, 18))
(game.Table 1 is the table with 1 row and 18 columns as mentioned above.
The situation now is that my actors get a random number between 1 and 18, but the problem is some numbers are getting picked twice.
What I want to achieve is that my actors get numbered between 1 and 18 with none of the numbers getting used twice, so the players are able to start with 1 and destroy the actors by pressing them in numerical order.
Also a side question is: I have looked up the most of the GameSalad Cookbook guides on youtube and havent been able to find a video which explains how you are able to put prioritys on actors. As you probably have figured out my game idea, this will be needed to tell the system which actor has to be pressed in what order.
I hope that I have pointed out my problem clearly. If there is still a point which is unclear, I am willing to give more detailed information.
/Mustafa 'Dasdingomon' Seker
Comments
Change Attribute self.(or game.)randomRow to random(1,tableRowCount(game.Table))
Add/Remove Table Row: remove [at index] row [self.randomRow]
[optional:] Save table(game.Table)
That way, each time you choose a random row, you delete that row so that it cannot be used again. The random expression chooses a row from the remaining rows (e.g. after the first number is chosen, there will be 17 rows in the table).
I usually add another behavior above those two: Change Attribute self.remainingRows to tableRowCount(game.Table) and put self.remainingRows inside of the random expression instead so that I can use that for rule conditions (e.g When self.remainingRows=0 --> game over).
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
First of all I would like to thank you for trying to help me with my problem. I tryed the things you said, but in the end it didn't work for me.
I have solved my problem by this way:
Created a new tabel with 2 columns and 18 rows. The table contains the x and y positions i want to have. Chosing the rows trough a random function. This worked out pretty nice for me.
Again thanks alot for trying to help me out.
/Mustafa 'Dasdingomon' Seker