Problem Making an inventory for a game

Not favoritedFavorited Favorited 1 favourites
  • 4 posts
From the Asset Store
Inventory Aid
$4.90 USD
Create grid-based game inventories and items easily.
  • Hello, I wanted to make an inventory for my game, where you can have 3 bags with 9 slots of items each. However, I tried giving the first bag 3 items at the beginning and I noticed they are not put in the correct slots. Then out of curiosity I let myself use hotkeys to unlock the other 2 bags and I saw that instead of being empty as intended they all are filled with the same item.

    I tried using for each and for commands but I do not understand what is wrong, tho I suspect the mistake is inside the itemFill function where I set the itemID for each slot. I would give more frunctions to this but since I cant even make it load properly I didnt

    I will send a c3p file with jsut the inventory code inside

    thanks

    cdn.discordapp.com/attachments/960278860161765436/1342716564985610250/itemtest.c3p

    Tagged:

  • Instead of using the slot IID to track its 'ID', use an instance variable on the slot that is set in the editor beforehand that is used to match the co-ord from the array, then only put items in the array not numbers, for testing filling with 1,2,3 can be confusing so use 'sword' 'potion' or whatever.

    So in bag 1 the slot.ID for the 3 slots can be 1 2 and 3, and they read from x=1, 2 and 3 in the array. To 'fill' or assign an item to the slot you can use a string variable on the slot like itemname and it reads from the array indexof(slot.ID) which should be an item.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I tried using Strings like you said and it didnt seem to make things better

    for example I set the first value of the array to sword to test things out and gave 2 other names to the 2nd and 3rd slot. Then instead of frames I switched to animations, so the game will fetch the strings from the array and play the animation with the same name as the value, if value is 0 it will be "empty"

    so I used debug and I noticed that the itemName values didnt get anything inside, at least it didnt cause a mess with bags 2 and 3 this time. I do not understand what I did wrong, also yes I did give each slot an individual ID in the editor, and depending on the bag they will have a "second ID" that matches the bag number (bag 1 is items to 8, bag 2 is items 9 to 15 etc)

    I should mention at the start of layout I clear the array to 0 and set the values like this: Set Value at 0 "sword"

  • I wouldn't set the secondID in the function but again have this as set in the editor. Then you know it is correct for the following events in the function. Also check the array in debug to see if the items are in the correct place.

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