Adding/Selecting Random Numbers from Tables for In-Game Boosts?

ShineHouseGamesShineHouseGames Member, PRO Posts: 100
edited July 2012 in Working with GS (Mac)
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)?

Answers

  • HC_DKHC_DK Member Posts: 92
    Have a table where all purchased items is listed/saved.
    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
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited July 2012
    The problem is that you are confusing power up numbers with table row numbers. You could just as easily have a table column called "PowerUpNumber" or something to that effect and then just add your power ups in order row by row as they are purchased. So if the player buys power up #1, then #2, and then #6, your table would look like this:

    .......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

  • ShineHouseGamesShineHouseGames Member, PRO Posts: 100
    edited July 2012
    How do I add powerups to the table by order of purchase? Or rather, how do I even add numbers to a table mid-game?
  • ShineHouseGamesShineHouseGames Member, PRO Posts: 100
    You could just as easily have a table column called "PowerUpNumber" or something to that effect and then just add your power ups in order row by row as they are purchased.
    How do I do this?
  • HC_DKHC_DK Member Posts: 92
    Have you looked at: http://cookbook.gamesalad.com/tutorials/2/parts/25 or http://cookbook.gamesalad.com/tutorials/2/parts/36 to understand how tables work or ?

    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
Sign In or Register to comment.