Actors inside of another actor?
dixondonald
Member Posts: 33
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?
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
http://gshelper.com/shop/gamesalad-templates/expanding-menu-template/
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
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
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... This is an empty table. I'll call it "Inventory". 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.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
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