Spawning actor with different attribute each time

Jfg619Jfg619 Member Posts: 23
edited April 2014 in Working with GS (Mac)

Hi, I need to create a menu with the amount of buttons equaling the number of rows in a table. So I created an attribute called ButtonCount and a rule that says:
If ButtonCount is < TableRowCount
Then change ButtonCount attribute to ButtonCount +1 and spawn a button actor underneath it.

So lets say if the table has 5 rows, there are now 5 buttons on the screen. But what I haven't been able to achieve is this: I need each button that's spawned to display the value of each row. So far I have only been able to make ALL 5 buttons display the SAME row value, I need each value to be different.

So for example: My table rows are Cat, Dog, Fish, Bird, Cow and I need each button to display each row value. My table is eventually gonna have around 100 rows so that's why I need to do it this way.

Hope my explanation wasn't confusing, I'd really appreciate any help :)

Comments

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

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

  • Jfg619Jfg619 Member Posts: 23

    Thank you but I wasn't able to open it.. Is it for PC? I have a mac...

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

    It's for Mac but as I noted in that post, you'll need the Nightly Build to open it.

    http://forums.gamesalad.com/discussion/66768/forum-faq#variousbuilds

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

  • Jfg619Jfg619 Member Posts: 23
    edited April 2014

    Thanks, I was able to open it. So from what I understood, I would need to create an instance actor for each menu item and change its self.MenuNumber manually? My table has more than 100 rows, so I was looking for a way for GameSalad to do it for me automatically...

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

    Another way to do it is to calculate the menu item's location by it's x/y position. As an example, if each item is 30 pixels high starting at y=500 and going down the scene, you would do:

    Change Attribute self.myRow to ceil((500-self.Position.Y)/30).

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

  • stueynetstueynet TorontoMember Posts: 166

    I talk about this exact issue in a tutorial. Basically what you can do is on each table iteration, change a global / game attribute to something. Then within the spawned actor's prototype, set a self attribute to be whatever that is.

    So in your iteration loop start with a change attribute to change the game attribute to cat, dog etc...

    Then in your prototype, the first thing in its rules should be a change attribute to the game attribute above.

    Its part of this larger video but its at around 14 or 15 minutes where I talk about the individual actor's level which is analogous to what you're doing I believe.

    My Latest GS Game - Tiny Spirit
    My First GS Game - Dashing Ralph

  • Jfg619Jfg619 Member Posts: 23

    @stueynet I was following your tutorial but couldn't find the "loop over table" behavior, why doesn't my gamesalad have that or the loop behavior? I just downloaded the latest version and I can't find those behaviors anywhere...

  • stueynetstueynet TorontoMember Posts: 166

    @Jfg619 said:
    stueynet I was following your tutorial but couldn't find the "loop over table" behavior, why doesn't my gamesalad have that or the loop behavior? I just downloaded the latest version and I can't find those behaviors anywhere...

    They are definitely there. Look harder ;)

    My Latest GS Game - Tiny Spirit
    My First GS Game - Dashing Ralph

  • Jfg619Jfg619 Member Posts: 23

    They're supposed to be above the Move behavior but they're not there... maybe they're exclusive to the pro version? it looks like you have it..

  • stueynetstueynet TorontoMember Posts: 166

    @Jfg619 said:
    They're supposed to be above the Move behavior but they're not there... maybe they're exclusive to the pro version? it looks like you have it..

    Ah perhaps that's it. Maybe @tatiang‌ can she's some light.

    My Latest GS Game - Tiny Spirit
    My First GS Game - Dashing Ralph

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

    @stueynet @Jfg619‌ You'll need a nightly build or the release candidate to use the Loop over Table behavior. See http://forums.gamesalad.com/discussion/66768/forum-faq#variousbuilds. They are not Pro behaviors.

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

  • stueynetstueynet TorontoMember Posts: 166

    @tatiang said:
    stueynet Jfg619‌ You'll need a nightly build or the release candidate to use the Loop over Table behavior. See http://forums.gamesalad.com/discussion/66768/forum-faq#variousbuilds. They are not Pro behaviors.

    Ah there ya go. Yeah in the tutorial I mention it's with an RC. it's a great feature.

    My Latest GS Game - Tiny Spirit
    My First GS Game - Dashing Ralph

Sign In or Register to comment.