Need help with tables and some actions!

Hi. everyone

Im making a game a bit like subway surf.. but here things come from the right and moves to the left..
i have build 5 actors "5 Lanes" that my player can move in..

made 5 game attributes with the names lane1,lane2, lane3, lane4,lane5

my idea is that the table will have 5 rows, one for each lane
and a collum is "one" spawn sek..

so in the table the will be numbers, each number stands for either a positive spawn, negative spawn, or a "empty" spawn.

this is my table ex:
("-" is a new collum) Collum
lane1 1 - 2 - 1 - 3 - 1
lane2 5 - 5 - 5 - 4 - 1
lane3 1 - 1 - 2 - 2 - 2
lane4 2 - 3 - 3 - 3 - 2
lane5 4 - 1 - 1 - 1 - 4
lets say the #1 is a cannonball, or #number 2 is a powerpickup, or that #5 is nothing.

now what i wont is to tell directly to the lane actor or the game attribute for the lane, to spawns what is equal to that collum # that sek.. and then the sek after spawn the thing in the next collum...

the Actor spawner will have the, spawn set to.. if game attribute "lane1" number is equal to 1 spawn this item..

hope you guys can understand what im trying to write here :S


Best Answers

  • tatiangtatiang Posts: 11,949
    Accepted Answer
    By "sek" do you mean "second?"

    Each lane spawner actor can have a timer that runs every second and increases its self.column (integer) value and then spawns an actor based on tableCellValue(tableName,self.myRow,self.column).

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • tatiangtatiang Posts: 11,949
    edited May 2013 Accepted Answer
    In each spawner actor, create the following attributes:
    self.column (integer) set to 0
    self.spawnChoice (integer) set to 0
    self.lane (integer) set to the lane number where that actor is (e.g. 1, 2, 3, etc.)

    In each spawner actor, create the following timer:
    Timer every 1 second
         change attribute self.column (integer) to self.column+1
         change attribute self.spawnChoice (integer) to tableCellValue(tableName,self.lane,self.column)
         When attribute self.spawnChoice=1
              Spawn actor [cannonball]
         When attribute self.spawnChoice=2
              Spawn actor [powerpickup]
         etc.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

Answers

  • luckyleafluckyleaf Member Posts: 7
    By "sek" do you mean "second?"

    Each lane spawner actor can have a timer that runs every second and increases its self.column (integer) value and then spawns an actor based on tableCellValue(tableName,self.myRow,self.column).
    That sounds good! but can u give an ex:

    i'm a new user so, a little push in the right direction would be nice :D
    if you have the time..

    tried with what you gave me in your post, but can figure it out..

    thanks for your help so far!
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Argh! The forums bug deleted my comment... brb with a demo.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    @luckyleaf Here you go. Each lane spawner instance needs to have its self.lane attribute set manually. Let me know if you have questions.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • luckyleafluckyleaf Member Posts: 7
    thanks mate
  • luckyleafluckyleaf Member Posts: 7
    Works perfect the way you did it, with the lanes!! thank you so much..

    But what if i what to loop the table.. so when it hits the last collumn, it restarts again at the first column?
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Instead of change attribute self.column to self.column+1, use this:

    change attribute self.column to mod(self.column,tableColCount(tableName))+1

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • luckyleafluckyleaf Member Posts: 7
    Instead of change attribute self.column to self.column+1, use this:

    change attribute self.column to mod(self.column,tableColCount(tableName))+1
    couldn't get it to work.. nothing spawns :S
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Sorry, take it out of the rule that says When self.column < tableColCount. That isn't needed if you're looping through the columns.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

Sign In or Register to comment.