I'm having problems with my inventory; if you have any better ideas, I'd appreciate it.

Not favoritedFavorited Favorited 0 favourites
  • 3 posts
From the Asset Store
Inventory Aid
$4.90 USD
Create grid-based game inventories and items easily.
  • I'm working on an inventory system.

    The functions are to drop items into empty spaces, and if the space is occupied, the items are swapped if they don't have the same ID.

    However, I'm having a problem when adding the sum.

    I have two arrays, one called hotbar and the other INV.

    I'm supposed to have keys so that each action function is executed. When the key is 0, it saves the information to the variables in G and clears the information from the INV array, or the same happens in the hotbar array.

    When the key is 1, it loads the information from the variables in G into empty spaces, either in the INV or hotbar array.

    The issue is that when the function is 1 and I compare the variables G_ID=DES_ID to apply the sum, if that's active, I get a strange error that I don't understand.

    If I click on the item with the function set to 0, it should save the information, but instead, it sends that information to the hotbar array, which shouldn't happen.

    But this only happens if the sum is active. which is inside the key of function 1, meaning function 1 is not activated if the data has not been loaded.

    But if I deactivate the summing within function 1, everything works correctly again without performing summations.

    Here's a video of the ones I've programmed.:

    youtu.be/PPqjTRO5l9k

    Here is a copy of the programming:

    [click to take 3]

    ----+ Mouse: The cursor is over SLOT

    ----+ System: InvOpen is true

    --------+ System: SLOT.ZONE = ZONE_INV

    ---------> System: Set DES_ID to Inv.En(SLOT.POSX,SLOT.POSY,Z_ID)

    ---------> System: Set DES_QTY to Inv.En(SLOT.POSX,SLOT.POSY,Z_QTY)

    ---------> System: Set DES_X to SLOT.POSX

    ---------> System: Set DES_Y to SLOT.POSY

    ---------> System: Set DES_ZONE to SLOT.ZONE

    --------+ System: SLOT.ZONE = ZONE_INVBAR

    ---------> System: Set DES_ID to HotBar.En(SLOT.POSX, SLOT.POSY, Z_ID)

    ---------> System: Set DES_QTY to HotBar.En(SLOT.POSX, SLOT.POSY, Z_QTY)

    ---------> System: Set DES_X to SLOT.POSX

    ---------> System: Set DES_Y to SLOT.POSY

    ---------> System: Set DES_ZONE to SLOT.ZONE

    ----+ Mouse: [X] Cursor is over SLOT

    ----+ System: InvOpen is true

    -----> System: Set DES_ID to 0

    -----> System: Set DES_QTY to 0

    -----> System: Set DES_X to 0

    -----> System: Set DES_Y to 0

    -----> System: Set DES_ZONE to 0

    ----+ Mouse: On Left Click on SLOT

    ----+ System: Is InvOpen true

    --------+ System: G_DRAGacti = 0

    ------------+ System: SLOT.ZONE = ZONE_INV

    ------------+ System: DES_ID > 0

    -------------> System: Set G_ID to Inv.En(SLOT.POSX,SLOT.POSY,Z_ID)

    -------------> System: Set G_QTY to Inv.En(SLOT.POSX,SLOT.POSY,Z_QTY)

    -------------> System: Set G_X to SLOT.POSX

    -------------> System: Set G_Y to SLOT.POSY

    -------------> System: Set G_IDSUMA to Inv.En(SLOT.POSX,SLOT.POSY,Z_ID)

    -------------> System: Set G_QTYSUMA to Inv.En(SLOT.POSX, SLOT.POSY, Z_QTY)

    -------------> System: Set G_XSUMA to SLOT.POSX

    -------------> System: Set G_YSUMA to SLOT.POSY

    -------------> System: Set G_ZONE to SLOT.ZONE

    -------------> Inv: Set value in (G_X, G_Y, Z_ID) to 0

    -------------> Inv: Set value in (G_X, G_Y, Z_QTY) to 0

    -------------> System: Set G_STACKMAX to SLOT.MAXSTACK

    -------------> System: Set G_STACKEABLE to SLOT.STACKEABLE

    -------------> System: Set G_DRAGGING to True

    -------------> System: Set G_DRAGacti to 1

    -------------> System: Set UI_DIRTY to 1

    ------------+ System: SLOT.ZONE =ZONE_INVBAR

    ------------+ System: DES_ID > 0

    -------------> System: Set G_ID to HotBar.En(SLOT.POSX,SLOT.POSY,Z_ID)

    -------------> System: Set G_QTY to HotBar.En(SLOT.POSX,SLOT.POSY,Z_QTY)

    -------------> System: Set G_X to SLOT.POSX

    -------------> System: Set G_Y to SLOT.POSY

    -------------> System: Set G_IDSUMA to HotBar.En(SLOT.POSX,SLOT.POSY,Z_ID)

    -------------> System: Set G_QTYSUMA to HotBar.En(SLOT.POSX,SLOT.POSY,Z_QTY)

    -------------> System: Set G_XSUMA to SLOT.POSX

    -------------> System: Set G_YSUMA to SLOT.POSY

    -------------> System: Set G_ZONE to SLOT.ZONE

    -------------> HotBar: Set value in (G_X, 0, Z_ID) to 0

    -------------> HotBar: Set value in (G_X, 0, Z_QTY) to 0

    -------------> System: Set G_STACKMAX to SLOT.MAXSTACK

    -------------> System: Set G_STACKEABLE to SLOT.STACKEABLE

    -------------> System: Set G_DRAGGING to True

    -------------> System: Set G_DRAGacti to 1

    -------------> System: Set UI_DIRTY to 1

    --------+ System: G_DRAGacti = 1

    ------------+ System: SLOT.ZONE = ZONE_INV

    ----------------+ System: DES_ZONE = G_ZONE

    --------------------+ System: DES_ID = 0

    --------------------+ System: G_DRAGacti = 1

    ---------------------> Inv: Set value in (DES_X, DES_Y, Z_ID) to G_ID

    ---------------------> Inv: Set value in (D

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Can you share your project file? The quality of the video you posted is quite low and all code is in Spanish..

  • I don’t think that it’s something that can be debugged from videos or even screenshots of events. Generally, more events means it takes more effort to get familiar with what you’re doing before even being able to debug it.

    Since it sounds like it’s become complex and is hard to debug you could rewrite it from scratch after working out on paper exactly what you want it to do. Then just do a bunch of tests to verify it’s working as expected as you actually add the events. That’s my usual strategy when making stuff.

    Or you could outline how you want it to work and I’m sure there are lots of users that would give suggestions or examples how they would do it.

    Personally I’d make such an inventory with sprites instead of arrays. I’d make two sprites: slot and item. Then I’d place instances of the slot sprite all over and place items on top of them. You could indicate if slots are occupied or not and the number of items with some instance variables.

    Then with minimal events you could place items into slots, or swap out the item you’re holding with the one in the slot. But ultimately it’s up to you how you want to go about it.

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