Intelligent Inventory

SnowAppleMintSnowAppleMint Member Posts: 23
edited November -1 in Working with GS (Mac)
So I was thinking about making a game like everyone else here. I decided before I decide what type to make I should see what I am capable of doing programming wise. So my first attempt is an intelligent inventory. Say there are 3 items and 3 slots. If i pick up item 1 I want it to go into slot 1, if I pick up item 3 I want it to go into slot 2. And say I use up all of Item 1 in slot 1, then I want item 3 in slot 2 to move to slot 1.
I sorta got this to work, but it required a lot of hard coded rules which is where I think I am messing up (I can post my file if anyone thinks they can help)
The filling of the slots works, the only problem I am running into is this(sorry for the extremely long post)
So again lets say item 1 is in slot 1 and item 3 is in slot 2, so when item 1 has been used up item 3 does move to slot 1 BUT it also remains in slot 2....
Basically I have a bunch of game attributes like itemName1 itemQty1 itemFilled1 and slotFilled1
then I have actors for the slots, (the only attribute i have for the actors is an itemIndex for determining which item it was filled with)

when slotFilled1 = false
check if itemQty1 > 0 AND itemFilled1 = false
change self.itemIndex = 1
then display itemName1 and itemQty1
If itemQty1 >0 AND self.itemIndex = 1
change slotFilled1 = false
I also have rules that change all the itemFilled# to false as well

I probably went about this the most complicated way ever imagined XD. The only TRUE programming experience I have is with java and I must say I never thought I would miss those darn arrays.

Any help is appreciated :)
-I can post the file if anyone is interested in looking at it.

Comments

  • StormyStudioStormyStudio United KingdomMember Posts: 3,989
    Hey there.. I appreciate the pain in getting it working...

    I never setup the moving of items from one slot to another when it becomes free. But I do have it working nicely.

    Check out my 'Point and Click collectables menu template' if your interested... price just dropped to $30

    Video shows it working.

    http://gamesalad.com/forums/topic.php?id=16605&replies=12#post-183572

    Good luck...

    Jon from stormystudio.com
  • SnowAppleMintSnowAppleMint Member Posts: 23
    Ah yes, your inventory inspired me just the other day. I started on this about 3 days ago? The one thing I notice with yours, when you use a key the slot does empty, but the next item does not fill it immediately. I am aiming for something dynamic, where items could be moved around (maybe, I am not sure I can reach that level)
    Kudos to your hard work :)
  • StormyStudioStormyStudio United KingdomMember Posts: 3,989
    I'm sure it's possible, it would be great to be able to able to grab an move items around, so you put the items into a chosen order by the user.
  • BRGKeenBRGKeen Member Posts: 40
    I have been working to accomplish the -exact- same goal, SnowAppleMint. I'm making an adventure game and when the character picks up an item I want it to go to the first immediate available slot. When an item leaves the inventory I want all items to shift to the first available slot.

    So far I'm not having much luck. :(
  • SnowAppleMintSnowAppleMint Member Posts: 23
    aww well if I ever get this working I will be more than happy to share
  • BRGKeenBRGKeen Member Posts: 40
    Much appreciated and I'll do likewise.
  • SnowAppleMintSnowAppleMint Member Posts: 23
    The only way I logically thought the 'shifting' of items would work was to hardcode a rule into each actor,
    slot 2 will not fill unless slot1 is filled.
    slot1 will not empty if slot2 empties, but slot3 will empty

    see where I am going with this?

    I think all my rules are strung out and thus overriding each other but I do not know how to 'contain' them and keep them 'looping' or constantly updating
  • BRGKeenBRGKeen Member Posts: 40
    I'm running into the same issue. I have a massive string of logic going and I think one part of the logic is overruling another. Sometimes multiple slots fill with an item, etc.
  • SnowAppleMintSnowAppleMint Member Posts: 23
    I actually got mine to work, for a second at least. The items would fill up and disappear. I think there is something with how gamesalad executes. When I open up my file in the viewer more than once it gets 'buggy'.
  • IsabelleKIsabelleK Member, Sous Chef Posts: 2,807
    Just want to let you know that the Intelligent Inventory is fully doable. I made inventory like this to my upcoming game The Train episode 02 (I still need to update the first episode with that inventory).

    1. Items in my inventory are placed in the order you take them.
    2. If you take an item, you will see the appropriate information (which item did you get).
    3. If you try to use an item in the wrong place, you'll get the appropriate info.
    4. If you use any item, it will dissapear and other items will automatically move to cover the empty slot.
    5. Player can take every item only once (so you don't get the same item on every slot).
    6. It works properly after changing the scene.
    7. If you choose any item in the inventory, it become highlighted.
    8. You can choose one item. If an item is chosen, and you click the other one, then the first one become inactive.
    9. Player is able to move items freely.
    10. Player is able to close and open the inventory.
    11. I use only 5 game attributes on the entire inventory, and items.

    It was pretty simple, I made it in few days (but I have about 50 items).
  • SnowAppleMintSnowAppleMint Member Posts: 23
    this is very interesting. Congratulations on completing something like that. Do you have any tips?
    I am especially interested in how you managed to use only 5 game attributes....
  • FloridaGamesFloridaGames Member Posts: 328
    SnowAppleMint said:
    this is very interesting. Congratulations on completing something like that. Do you have any tips?
    I am especially interested in how you managed to use only 5 game attributes....

    I would also be very interested in hearing how you managed that.
  • SnowAppleMintSnowAppleMint Member Posts: 23
    So I have managed to create a version that does work. It has a ton of hard coded rules in the actors...
    That does disappoint me. I was hoping for something a little less tedious. I will continue to try and flesh out what I have or scrap it and start over.
    Has anyone used actor tags for anything useful other than collisions?
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    Hi SnowAppleMint; making a decent inventory system is never easy.
    SnowAppleMint said:

    Has anyone used actor tags for anything useful other than collisions?

    I use actor tags in the Scene Editor window, to isolate groups of actors in the Actors Inspector.

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • SnowAppleMintSnowAppleMint Member Posts: 23
    Ah yeah I am finding this out the hard way :)
    I was actually trying to think up some creative ways to manipulate actors with the actor tags(particular related to inventory management etc.)
    Was just thinking out loud

    thanks for the reply gyroscope
  • SnowAppleMintSnowAppleMint Member Posts: 23
    I posted my working file. It is very messy. Attributes names are somewhat off I just did not feel like correcting them at the moment. I also did not get around to adding comments, I am a big supporter of commented code. I hope this file helps some people out though.
    ;)
Sign In or Register to comment.