Spawning actors with unique attributes from tables

jbguidajbguida Member, BASIC Posts: 8

Hello,

I am very new to this (I just downloaded the program yesterday), and I have been spending hours trying to figure out a way to take data from a table and use it to spawn actors (about 200), each with some unique attributes.

As of right now, I am trying to use a Loop Over Table behavior. However as I set up the Loop, under "Do" I select "Spawn Actor" - and I don't know how to edit many of the attributes of the newly spawned actor - only it's location, direction, etc.

Is there a way to "Change Attribute" of actors that will be spawned? If so, how do I tell the program to change the attributes of only recently spawned actors. (I can't do this in the "Actor Prototype" because I don't want these values to be randomly selected for each instance and I don't want all the instances to have the same values for certain attributes).


Ideally, also, you might be able to suggest a resource (or method) for me to extract data from a single row and assign the values from multiple columns to various attributes of each instance - I imagine I could do it one at a time, but there's probably a more efficient way.

Comments

  • BunkerBunker Member, PRO Posts: 36
    edited March 2018

    What I do is set 2 game level 'integer' attributes: and 1 self attribute in the actor to be spawned;

    1-game.INDEX = 0
    2-game.Max# = 50 (or whatever)

    Then in the loop
    ( while ) (game.INDEX) < (game.Max#)

    1• Change attribute ( game.INDEX = game.INDEX+1)
    2•Spawn actor [whatever]

    Then inside the spawned actor - 1 integer attribute to hold the INDEX value

    (self attribute) self.ID# = 0


    • Change attribute (self.ID#) = (game.INDEX)

    Then you can do rules based off that index..

    • Display Text = (tablecellvalue, TestTable, (self.ID#) , 1)
    ^
    // using the id# as row or col index!

  • jbguidajbguida Member, BASIC Posts: 8

    Thanks for your help. Very quick, and clearer than most! I've made some progress, but I'm still not sure I totally understand. I follow until you get to the "actor" section. I have a global variable INDEX and MAX#, and my actors have an ID attribute, but I don't see how/where to "change attribute" in order to assign ID = INDEX. Do you do it inside one of the drop down bars that say "in the direction:" or "from position"?

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

    Change Attribute is a behavior.

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

  • BunkerBunker Member, PRO Posts: 36

    Fig 1: You can see the two actors “MGR” and “Actor”

    Fig2: You can see the table I begin with ( need to start with 1 row and 1 column )

    Fig3: You can see the .game level attributes (game.Count #) and (game.MaxCount)

    Fig4: You can see the .self Attribute (self.ActorID)

    Fig5: This is the loop that spawns an actor while sending a numeric value to .gameCount#

    Fig6: This is how the Change attributes sets the ID depending on it’s spawn sequence.

    Fig7: Here you can see I’ve added the Add row behaviour in the Loop on the MGR

    Fig8: Here you can see I’m using a Display Text Behaviour to display the cell value of it’s ID#

    Let me know if you’d like me to send you a work file to look at or if you need more clarification!!

  • jbguidajbguida Member, BASIC Posts: 8

    GOT IT! THANKS SO MUCH! Needed figure 6!

  • BunkerBunker Member, PRO Posts: 36

    You're welcome jbguida. glad to help out!

Sign In or Register to comment.