How do I make an inventory without array

0 favourites
  • 14 posts
From the Asset Store
Inventory Aid
$4.90 USD
Create grid-based game inventories and items easily.
  • I was studying the manual and this tutorial (https://www.scirra.com/tutorials/583/ea ... ray/page-2) and I couldn't understand at all, specially the expressions and the theory behind the array.

    Please, someone with a good patience could teach me?

  • https://www.scirra.com/tutorials/307/ar ... -beginners

    https://www.scirra.com/tutorials/670/ze ... e-easy-way

    I know this isnt the answer bud, but i found this array tutorial pretty awesome

    also the inventory one is damn good hope it helps until someone can offer an alternative

  • scirra.com/tutorials/307/arrays-for-beginners

    https://www.scirra.com/tutorials/670/ze ... e-easy-way

    I know this isnt the answer bud, but i found this array tutorial pretty awesome

    also the inventory one is damn good hope it helps until someone can offer an alternative

    This is the tutorial which I mentioned <img src="{SMILIES_PATH}/icon_cry.gif" alt=":cry:" title="Crying or Very Sad" /> . I just can't understand this sh**t. Thats why I asked someone to explain me in details. I'd like to know how to do it by myself, because It's a big and important feature in my game and I need to learn it, otherwise, I wont be able to solve any future bugs that may occur.

    But Thanks. I'll keep trying to understand arrays.

    However, I'd like to know if is there a way to do an inventory using just variables, since they can store information, which is what an inventory does, essentially.

    Edit: I'm starting to get it a bit thanks to this tutorial for beginners. Thank you for sharing it.

  • Simple yet very effective Inventory System: https://www.scirra.com/forum/viewtopic.php?t=64557&start=0

    A lot of solutions can be found in Kyatric's FAQ https://www.scirra.com/forum/viewtopic.php?t=63692&start=0.

  • hey, I'm trying to do it but I have a problem

    My array has 5 width,2 Height,1 depth

    X = itens

    Y= amounts.

    So, If I have 5 apples, it's ID would be, for an example, in index(0,0) and it's amount in index(0,1).

    The amounts will be right below of each item.

    But how can I stop to adding apples to all slots, since it's 0 by default?

    and how can I add +1 to amount everytime I "add" a new apple to that slot?

  • Value=arr_inventoryshortcut.At(arr_inventoryshortcut.CurX,1)+1

  • I need to make it general to work with any objects (itens) and not only for this object that I chose. Someone knows how to do that?

    Edit: Using families would work well for that? Because the game will have too many items with different characteristics like an sword or armor that can't be inserted more than one per slot, their different attributes, etc

  • If you need to make it work with several objects, yes families are perfect for that.

    click on "item_family" > push to array

  • If you need to make it work with several objects, yes families are perfect for that.

    click on "item_family" > push to array

    But using families can I get every single instance variables working with arrays?

    Edit: Nevermind, I got it. Thanks.

  • Alright, I'm facing another problem and I don't see how can I solve it.

    After picking the itens....

    I'm trying to put the objects in their repective slots. I tried to set it's animation to the same icon of the item but it seams a bad way to do it since I'll have too many itens in the game. The idea of having hundreds and hundreds of animations in each slot seams really bad.

    Someone knows how to do it?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Anyone?

  • Here's a brief overview of how I handle inventory in Courier. I'll not be posting code snippets, but I think the description will help you.

    First off, I use one big array for most of the data in my game--I use global variables for other stuff. In Courier, you have two types of items. I have 6 items that you can accumulate more of (potions, money, etc), so I just have 6 array slots with a count. Add one, subtract one. That one's pretty simple. I also have 4 slots that can take any one of a ton of essentially quest items. I have a single Quest sprite and all subsequent icons are saved as frames of that same sprite. I have a copy of that sprite with an instance variable sitting in each of the quest slots (be sure to have a blank frame for empty!) I have the 4 cellsin my array and, at the start of a quest, I set that cell to that quest's number. I have an external spreadsheet (ie, excel/google spreadsheet) to help me keep track of this stuff. I also have reminders for what coordinates go with what information. Once that quest is put in that cell, I update the corresponding icon to the frame that matches that quest item. I also have a 5th "holding" cell so I know what the user is deciding about (you can accept or deny taking on quests). Once the user selects where that quest item will go, I reset the holding cell to 0.

    As a side note, I also use my array to keep track of the status of each quest/delivery. If the value is 0, it hasn't been attempted. If it is 1, it is currently in-progress, and if it is 2, it is completed. This helps with characters speaking in context and making game events happen when they should.

    If you want a non-static list of these things, you could go through every slot (coordinate within a certain column, for example) and look for how many 4's you have and say you have 4 potions, etc. So you could take the general list in that column and make a visual display, but you could also loop through it and make a compressed list with quantities. Such is unnecessary for my game, but definitely a logical expansion of it.

    So if you have just quantities of a certain number of items, just have a cell dedicated to each item and run with a total count in each cell. If you have multiple one-off things, I would think of having a certain number of dedicated cells (or dedicate an entire column and just add to the end--pay attention to the dimensions of your array so you don't run out of space) and set those cells to a number that means something to you. So assign each item a number (in your head, on paper, something) and assign cells to those numbers. You now have a list of the items the player is holding can you can make your visual display relative to that data. Just remember to think of arrays as spreadsheets and you'll be fine.

  • C-7

    Thanks man.

    My inventory is working partially because I didn't figure out how I can drop an item "visually". In other words, the picking and dropping is working on my array, but I need to drop right next to my character that item. And that's the problem because i'm using family. I'm trying to get the information on my array that identifies which item I had stored and relate to the object that I must spawn right next to him.

  • Anyone?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)