Adding/Selecting Random Numbers from Tables for In-Game Boosts?
In my game, I have a system for people to spend an earned "currency" on characters, backgrounds, and POWERUPS.
My power ups work through a timer system, where every 15 seconds, a random number (1-4) is selected for an attribute. Every 30 seconds, depending on the number, a different boost will appear from the one actor (1 = big, 2 = fire, 3 = small, etc.).
--- I'd like to make it so that when a person purchases a new POWERUP, it will be added to the total number of options.---
For example, a power up is purchased that makes the main character invulnerable (and has the number 7 behind it, which would then be included in the randomized appearing power ups). The problem is however, if I use the "random" term for this system, it chooses a random number BETWEEN 1-7 (not 1, 2, 3, 4, 7 -- which is what I'd like it to be).
Anyone know how I could do this (probably with a table)?
My power ups work through a timer system, where every 15 seconds, a random number (1-4) is selected for an attribute. Every 30 seconds, depending on the number, a different boost will appear from the one actor (1 = big, 2 = fire, 3 = small, etc.).
--- I'd like to make it so that when a person purchases a new POWERUP, it will be added to the total number of options.---
For example, a power up is purchased that makes the main character invulnerable (and has the number 7 behind it, which would then be included in the randomized appearing power ups). The problem is however, if I use the "random" term for this system, it chooses a random number BETWEEN 1-7 (not 1, 2, 3, 4, 7 -- which is what I'd like it to be).
Anyone know how I could do this (probably with a table)?
Answers
Add an attribute called eg: RandomNr
Then make a CHANGE ATTRIBUTE: RandomNr to random(1,tableRowCount(TableName))
The number will then be from 1 to 5 (1,2,3,4,7)
Then CHANGE ATTRIBUTE: POWERUP to tableCellValue(TableName,RandomNr,1)
Now the PowerUp attribute will contain the right number for the powerup.
HC
.......PowerUpNumber....PowerUpName
1...............1.........................big
2...............2.........................fire
3...............6.........................small
When you pick a random number, have it pick a table row using random(1,tableRowCount).
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Learn how to use tables or at least try to understand how tables work.
If you still are having problems add @ before my name in your next reply and I will be notified.
HC