Randomize a TABLE
sebmacfly
Member Posts: 1,018
Hi,
I need to fill a Table with ramdom numbers from 1 to 11 and from -1 to -10.
The table size is 8 rows x 8 columns.
The special thing is that i need to have 3 times every number in the table (3x1, 3x-5, 3x-10, 3x11, etc...)
And one of the case have to be empty.
See the picture joined to this thread.
Is there a way to randomly fill this table using those numbers 3 times ?
Thanks a lot
Comments
Here is one you'll need to click each time to add an entry
Universal Binary Template - Universal Binary Template Instructions Rev 4 (Short) - Custom Score Display Template
Hi mate,
Thanks for help...
The template is not working, starts to third row, and the random function is giving me more then 3 times some numbers...
I absolutely need to have only 3 times every numbers, not - not +
from -10 to +11
Can you take a look please ?
Thank you very much
ah... and the empty case position have to be random too.
Place each possible value in its own table row (column 1). If you need three copies of each number, then place three values:
1 1 1 2 2 2 3 3 3 etc.
Use the Loop over Table behavior in the Release Candidate to loop over the rows of the table. For each iteration of the loop:
change attribute self.randomRow to random(1,tableRowCount(tableName)). change attribute game.NumberToPlace to tableCellValue(tableName,self.randomRow,1) Add/Remove Table Row [remove] [at index: self.randomRow]
This will pick a random row, select its value as game.NumberToPlace (you can do what you wish with that number), and then delete the row so it doesn't get picked again. If you need a blank space, add a zero to your table data and have a rule in the loop that checks for game.NumberToPlace=0 and then decide what to do to display the blank.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
It's working for me I just tried it again. It starts in the 2nd row 1st column leaving the 1st row first column blank as you requested.
Try this one (I changed the name so it would let me upload it) and see of it works I have it set to random(-10,11)*3. Make sure you are opening it with the latest nightly build. The random function works just change the it to suit yourself.
Universal Binary Template - Universal Binary Template Instructions Rev 4 (Short) - Custom Score Display Template
ah... and the empty case position have to be random too.> @colander said:
Hi @colander
I was out for 2 months, thanks for your answer...
The empty case have to be random too, can you look at that ?
Thanks very much !
Under Attributes row is set to 2 change it to 1.
Universal Binary Template - Universal Binary Template Instructions Rev 4 (Short) - Custom Score Display Template