Hello Marv, you mean this one? http://www.castles-of-britain.com/mm...ual-arrays.htm ?
I tried to understand it and too be honest, I did an epic fail... *lol*
Hello Marv, you mean this one? http://www.castles-of-britain.com/mm...ual-arrays.htm ?
I tried to understand it and too be honest, I did an epic fail... *lol*
Well you know, for the past couple games I've made I've figured out that actually the List object is fantastic for inventories. It's nice because picking an item up is easy (ListObj -> Add Line "Short Sword") and dropping an item (or equipping it) is just as easy (ListObj -> Delete line(ListIndex(YourSelection))). I use them for data storage only so they're always off screen / frame and not visible to the player.
I've been using list objects for random treasures and holy **** is it ever easier! Honestly this might be the best way I've ever found with MMF2 (IMO of course!)
Here, check this out: Let's say for your game every time the hero opens a chest up there's a 90% chance of getting a regular treasure and a 10% chance of getting something really awesome. What you can do is create 2 list objects that contain all the possible chest rewards- one that holds the regular stuff and one that holds the 'good' stuff. You're going to be taking something from one of those 2 lists and adding it to your hero's own list of gear called LstYOURITEMS.
List boxes are cool because you can add the data at runtime or beforehand (great for testing purposes!)
LstREGULARSTUFF
"Short Sword"
"Health Potion"
"Wooden Club"
LstGOODSTUFF
"Magic Sword"
"Super Axe"
"Bazooka +20"
Then when you have your events to open a chest-
Upon pressing "SPACE BAR"
+ Guy is over a treasure chest object
+ Random # 1-100 is <=90
-> Add Line to LstYOURITEMS(LstREGULARSTUFF(Random(# of Lines of LstREGULARSTUFF)+1))
Upon pressing "SPACE BAR"
+ Guy is over a treasure chest object
+ Random # 1-100 is > 90
-> Add Line to LstYOURITEMS(LstGOODSTUFF(Random(# of Lines of LstGOODSTUFF)+1))
Using this method, you can further tweak your loot drops to better suit your game. Let's say that out of all the regular stuff you want mostly heal potions. Edit your LstREGULARSTUFF so it now looks like this:
LstREGULARSTUFF
"Short Sword"
"Health Potion"
"Wooden Club"
"Health Potion"
"Health Potion"
Now you'll randomly get health potions 50% of the time, 90% of the time.
Hahaha, sorry I hope this makes sense. Anyways, like my old computer teacher told me back in 7th grade (in the 80s!), I may not do things the "right way" but they usually work out okay in the end.
This make perfect sense for Inventory! Thank you!
But how do you display them in a custom made inventory graphics? Is there a good way to sort them automatically, when you get new stuff, in like a 6 by 6 grid? I really thought that making 36 "If... then..." is a bit stress and that arrays are the only way around it. xD
That might be the complicated part, in that case you could use the list box objects to add / delete your overall player stock and then you'd have to assign all that to an array (or maybe global values).
I think what you could do is this:
Create 36 clones of the active objects "INV_GRIDITEMS" and line them up 6 x 6 like you describe above. At the start of the frame, spread value 0 in one of their alt values, and an Alt string called "ITEMNAME$". Give them all the collectible qualifier (this is what I'm currently doing for my game's inventory by the way).
Then you have a line like this:
Always ->
Set "ITEMNAME$" of INV_GRIDITEMS 1 to LstYOURITEMS(1)
Set "ITEMNAME$" of INV_GRIDITEMS 2 to LstYOURITEMS(2)
Set "ITEMNAME$" of INV_GRIDITEMS 3 to LstYOURITEMS(3)
etc...
Yes, all 36 times. I realize this is a big pain in the ass and although I've tried many times using loops and junk they never work correctly so writing it all out that one time is worth it to me to have a working game
Then after that part, you have lines like this:
Always ->
+ Alt String "A" of Group.Collectible = "" then set direction of Group.Collectible to 0
Always ->
+ Alt String "A" of Group.Collectible = "Short Sword" then set direction of Group.Collectible to 1
Always ->
+ Alt String "A" of Group.Collectible = "Health Potion" then set direction of Group.Collectible to 2
Always ->
+ Alt String "A" of Group.Collectible = "Wooden Club" then set direction of Group.Collectible to 3
And etc, for every type of item you're going to have in your game. This only assumes your active object "INV_GRIDITEMS" is using one animation with 32 directions (one for each item picture and 0 being the "blank" grid), but very easily you could have one animation for weapons w/ 32 directions, one for armor w/ 32 directions and etc. Currently, my game is using 4 animations w/ 32 directions apiece.
So all of this will constantly update your inventory icons in the grid with the string values in your off-screen list object "YOURITEMS" and change the grid pictures accordingly. If you were to have the guy drop an item and delete a spot in your list, it'd automatically shuffle your items around for you because that's one of the inherent features of a list object anyway (also why they are so cool for this sort of stuff.)
I hope this helps you, it really does work I swear!
Well I got it...now I know how to handle the listobject and that make perfect sense for an inventory menu. Thanks fior that, I'll try it out later.![]()
But the old problems is stil consistent: I dont get the array objects. xD
Can you post a simple example how to use it for stuff except inventory (like RPG Stats, Quests etc...)?
Thanks again, you helped me out a lot (if I can use it but this makes total sense ^^)!
Marv's example is better than what I could tell you about inventory arrays to be honest.
I'm glad I could help you out, sorry we got so derailed but hey that happens.
When you get something going, you should post info about your game up on the Clickteam blog![]()