TABLES: trying to extract a random number from a range of numbers defined by a difficulty attribute
So, I'm discovering the joy of tables, but got stuck along the way.
I have set up a quiz game, that extracts it's info from a table. It picks a random row every time following a change attribute:
random(1,tableRowCount( game.Table 1 )) - so a random row between line 1 and however many lines there are in the table.
So far so good. BUT, to take everything a step further...
...I added a column to my table where I set a difficulty of 1 to 4 for every question.
The idea is when the game starts I want to select only random questions with difficulty level 1.
Later on only questions with difficulty 2 and so on, you get the pont.
How do I make "random(1,tableRowCount( game.Table 1 ))" extract info only from those rows with the difficulty I want.
I know the fastest workaround would be simply to organize my questions by level of difficulty, and the just extract a random number from that range, but my CSV is constant work in progress, and is organized by category and alphabetical order, so it would turn into a real mess if I changed this.
Any ideas for doing it mathematically-ish? :-)
I have set up a quiz game, that extracts it's info from a table. It picks a random row every time following a change attribute:
random(1,tableRowCount( game.Table 1 )) - so a random row between line 1 and however many lines there are in the table.
So far so good. BUT, to take everything a step further...
...I added a column to my table where I set a difficulty of 1 to 4 for every question.
The idea is when the game starts I want to select only random questions with difficulty level 1.
Later on only questions with difficulty 2 and so on, you get the pont.
How do I make "random(1,tableRowCount( game.Table 1 ))" extract info only from those rows with the difficulty I want.
I know the fastest workaround would be simply to organize my questions by level of difficulty, and the just extract a random number from that range, but my CSV is constant work in progress, and is organized by category and alphabetical order, so it would turn into a real mess if I changed this.
Any ideas for doing it mathematically-ish? :-)
Comments
QX: How do you reference your difficultyLevel in your .csv ???
then again, you might duplicate the .csv and edit the duplicate so it only contains easy qxs
then duplicate your original csv and edit it so it only contains medium qxs
save each and import of those newCSV into a separate tables
know you end-up with 3-4 tables
but think that would make it easier for you to reference.
Rule: When
Attribute: game.level = 1
--behavior … random(1,tableRowCount( game.1 ))
Rule: When
Attribute: game.level = 2
--behavior … random(1,tableRowCount( game.2 ))
@};- MH
I didn't think of making several tables. I'll go that way, as it is easier than managing all my questions in ranges. On top of it ranges change over time when adding or removing data, so separate tables is the way to go.
Many thanks!