Actors inside of another actor?

dixondonalddixondonald Member Posts: 33
edited February 2014 in Working with GS (Mac)
For example I need one actor that is basically a container for a list of other actors. I'll try to explain it the best that I can. What it will be is a list(container actor) with a bunch of empty spaces(actors) that can be edited at any time.

So you would have something like this

| ITEMS _________|
| 1. _____________|
| 2. _____________|
| 3. _____________|
| 4. _____________|

The box would be the main actor(item_list or something) and the numbers would be the actors that could be edited whenever you acquired a new item(sword, shield, etc). These need to be actors so they can be clicked on. The main container list will not always be on display but it needs to be able to be called upon and display whatever items actors have been added to it.

To expand on this a little more, the way that I thought of to add items to the list would be: whenever a new item is acquired, there will be a check to see if item_slot_1 is empty, and if so change item_slot_1 to the item in question. If not, it would just go down the list until it finds an empty slot. Then, when you pulled up the item screen, it would have a list of these items, in whatever order you got them in. They could then be used for certain actions from that screen.

Does that make sense? Did I come up with a solution that is more complicated than it needs to be?

Comments

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    You're making a drop-down menu that will hold dynamic content. Although this template isn't exactly what you want, it might be useful to you. See the Video tab for a glimpse of it.

    http://gshelper.com/shop/gamesalad-templates/expanding-menu-template/

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

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited February 2014
    The Universal Point and Click template at http://www.deepblueapps.com/stormystudios-templates is also related to what you're trying to do. You can see his thought process in this thread: https://forums.gamesalad.com/discussion/56831/developing-an-adventure-game-inventory-menu-using-tables-video-example-from-stormy-studio.

    One more impressive template is this one: http://gshelper.com/shop/gamesalad-templates/point-and-click-game-template.

    I don't know of any free tutorials or templates for drop-down menus or inventory systems because they are fairly labor-intensive to create. As an example, I created a point & click inventory for a client and it took quite a few hours to craft.

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

  • 3itg3itg Member, PRO Posts: 382
    edited February 2014
    Okie dokie... I work with .Net and moving to Gamesalad from .Net... You tend to notice that parents (containers) are gone.
    I sat down and thought about what they were doing for me, and tried to recreate (a simple version) in gamesalad.
    What I ended up with worked pretty darn well. But to explain it in text requires a wall...
    So incoming...
    a list(container actor) with a bunch of empty spaces(actors) that can be edited at any time.
    This is an empty table. I'll call it "Inventory".
    edited whenever you acquired a new item(sword, shield, etc).
    This is where it gets "labor intensive", but depending on your game data, and how well you have it organized, it doesnt have to be that bad.
    Lets say you "Pick Up" a Sword, and a Shield.
    Well, something about those items makes them "Equipment", so that should be defined somewhere.
    For this example, I am just going to say that my game has 20 pieces of equipment.
    So I make a table that has 20 rows.
    Each piece of equipment should have some data about it, and to control it.
    So I'll have 5 columns, one for each of the following attributes:
    IN ROW 12:
    Name of Item (Blazing Sword)
    Type (Weapon)
    Maximum Amount (1)
    Value (2400)
    Strength (16)

    I can carry one of these... and when I equip it, I can use the "Strength" to add to my attack.

    The Row the item is in, makes a good itemID.
    I also went pretty generic with my columns, because I want other types of items to fit the categories as well.
    Example:
    IN ROW 18:
    Name of Item (Health Potion)
    Type (Consumable)
    Maximum Amount (100)
    Value (25)
    Strength (50)
    I can carry a hundred of these... and when I consume it, I can use the "Strength" to add to my hit points.

    So we have different types of items, that fit a model.
    Make 6 Columns in the "Inventory" Table.
    When your player gets an item, use Add Row to Table (At End), then Change Table Value.
    Random(1,20) to get a random Item,
    He got 18... the Sword, so pick Inventory as the table to change.
    and you can enter tableRowCount(Inventory) for the row.
    and then column by column, move the data from Equipment to Inventory. Use the 6th column to save the itemID (18 in this case).
    The Player should now have a "Blazing Sword" in their inventory... but you cant look at it.
    You can make a single actor, have it be invisible, and loop and spawn inventory buttons based on the contents of the table...
    but for now I am just going to tell you to make a game.attribute, an Integer named "Page" and 1 actor name it "Slot1", add self.attributes to it:
    SlotID = 1
    ItemID = tableCellValue(Inventory, SlotID, 6)
    ItemName = tableCellValue(Inventory, SlotID, 1)
    Type = tableCellValue(Inventory, SlotID, 2)
    Maximum Amount = tableCellValue(Inventory, SlotID, 3)
    Value = tableCellValue(Inventory, SlotID, 4)
    Strength = tableCellValue(Inventory, SlotID, 5)

    Copy it 9 times, and then increment the name and slotID of each of them: Slot2 has SlotID of 2, Slot3 has a SlotID of 3 and so on...

    Place them in a grid like fashion on screen.
    When Display Inventory is true, self.position.X to self.position.X - 800
    OTHERWISE
    self.position.X to self.position.X + 800

    click on em, do stuff... that should get you on the right track.
  • dixondonalddixondonald Member Posts: 33
    Wow. Thank you for taking the time to write all of that out. I haven't worked with tables before so I didn't think of using them, but I think they are the solution for me. I'll have to look into this in more detail on my next day off.
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    You're welcome. I started to make a demo but got a ways into it and realized that it really begs for "Nightly" features available to Pro members including Loop over Tables and other table-related functions. I may make a demo with the Nightly build and I'll post a video if I do. For now, I'll attach my somewhat functional demo.

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

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited February 2014
    So this was much easier/faster to create using the Nightly build:



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

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Update. Man, I love tables!

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

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

    Someone requested the updated project file so I've posted it here: http://forums.gamesalad.com/discussion/comment/461526/#Comment_461526.

    I was really tempted to make into a template and sell it but since it started as a free demo I'm sticking to that.

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

Sign In or Register to comment.