GameSalad

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

How to randomly spawned and decrease have been used actor next time ?

WeiyuWeiyu Posts: 215Member, PRO

Hello everyone!

I have a idea and that is I want to randomly spawned and decrease have used actor next time when I use it.

If I touch button, Actor_A will randomly spawned A、B、C、D、E、F


First time touch button: randomly spawned B
And next can randomly spawned just only A、C、D、E、F

Second time touch button: randomly spawned E
And next can randomly spawned just only A、C、D、F
.
.
.
.

Like this: http://imgur.com/5ra9rTl

Comments

  • tatiangtatiang Posts: 11,791Member, Sous Chef, PRO, Senior Sous-Chef

    Create a table with these text row values:
    A
    B
    C
    D
    E
    F

    Change Attribute self.row to random(1,tableRowCount(tableName))
    When tableCellValue(tableName,self.row,1) = "A"
         Spawn actor [A]
    When tableCellValue(tableName,self.row,1) = "B"
         Spawn actor [B]
    When tableCellValue(tableName,self.row,1) = "C"
         Spawn actor [C]
    When tableCellValue(tableName,self.row,1) = "D"
         Spawn actor [D]
    When tableCellValue(tableName,self.row,1) = "E"
         Spawn actor [E]
    When tableCellValue(tableName,self.row,1) = "F"
         Spawn actor [F]
    Delete Row at index self.row

    Repeat that each time you want to spawn a random actor.

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

  • WeiyuWeiyu Posts: 215Member, PRO
    edited June 2016

    @tatiang said:
    Create a table with these text row values:
    A
    B
    C
    D
    E
    F

    Change Attribute self.row to random(1,tableRowCount(tableName))
    When tableCellValue(tableName,self.row,1) = "A"
         Spawn actor [A]
    When tableCellValue(tableName,self.row,1) = "B"
         Spawn actor [B]
    When tableCellValue(tableName,self.row,1) = "C"
         Spawn actor [C]
    When tableCellValue(tableName,self.row,1) = "D"
         Spawn actor [D]
    When tableCellValue(tableName,self.row,1) = "E"
         Spawn actor [E]
    When tableCellValue(tableName,self.row,1) = "F"
         Spawn actor [F]
    Delete Row at index self.row

    Repeat that each time you want to spawn a random actor.

    Thank you for your answer.

    And I'm sorry I don't often use table function,so I don't know that what the "Change Attribute 【 self.row 】 to random(1,tableRowCount(tableName))" mean?

    Could you tell me that where can I find the self.row ? And those function are used on button?

    Are you mean it? : http://imgur.com/8xMGAZe

    Please forgive my ignorance. :'(

  • IceboxIcebox Posts: 1,483Member

    when you see "self."anything self refers to a self attribute , so he means create an actor and create an integer attribute call it row. (self.row)

    then place a change attribute self.row to random(1,tableRowCount(tableName)),

    then you place a rule and choose numeric expression

    When tableCellValue(tableName,self.row,1) = "A"
    Spawn actor [A]
    When tableCellValue(tableName,self.row,1) = "B"
    Spawn actor [B]
    When tableCellValue(tableName,self.row,1) = "C"
    Spawn actor [C]
    When tableCellValue(tableName,self.row,1) = "D"
    Spawn actor [D]
    When tableCellValue(tableName,self.row,1) = "E"
    Spawn actor [E]
    When tableCellValue(tableName,self.row,1) = "F"

  • tatiangtatiang Posts: 11,791Member, Sous Chef, PRO, Senior Sous-Chef

    It sounds like you're very new to GameSalad so it might make sense for you to watch a few tutorial videos before trying my suggestion.

    This:

    Change Attribute self.row to random(1,tableRowCount(tableName))

    Changes the value of self.row (an Integer attribute that I created within an actor) to a value between 1 and the number of rows in the table. The idea is that you want to pick a random row but you need to know how many rows are in the table (you wouldn't want to pick a number from 1 to 20 if you only have 8 rows). Because the table size will change when you delete a row, you can't just put in the number 8 for an 8 row table. It will next become a 7 row table, then a 6 row table, etc.

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

  • WeiyuWeiyu Posts: 215Member, PRO
    edited June 2016

    @Icebox said:
    when you see "self."anything self refers to a self attribute , so he means create an actor and create an integer attribute call it row. (self.row)

    @tatiang said:
    It sounds like you're very new to GameSalad so it might make sense for you to watch a few tutorial videos before trying my suggestion.

    Thank you for your explanation :D
    And sorry for the late reply. :s

    Is this the correct way? : http://imgur.com/6jzzXWS

    I meet a trouble.
    It only can spawned same actor replication when I touch the button.
    Like this : http://imgur.com/f4yzETg

    Can you please help me? 。゜(゜´Д`゜)゜。

  • tatiangtatiang Posts: 11,791Member, Sous Chef, PRO, Senior Sous-Chef

    @mme5566123twww said:
    Is this the correct way? : http://imgur.com/6jzzXWS

    Any chance you can upload the project file? There could a number of reasons why it's not working, including leaving out quotes in the "A" expression.

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

Sign In or Register to comment.