Problem with Inventory item dropping and item switching from hand to Inv. slot. [Solved]

0 favourites
  • 8 posts
From the Asset Store
Experience the true heartbeat of combat with "Combat Hits - Hand To Hand Fighting SFX."
  • I'm not that good with arrays, but I've been trying to fix this for hours now and I'm stuck. Any help would be greatly appreciated.

    I made a video showing the bugs found here:

    Subscribe to Construct videos now

    Bug 1: When the inventory sprite is visible, left clicking on an Inventory Slot removes the item and item amount from the array, and then it puts the item amount into Player.HandAmount and creates a new GroundItem instance, pins it the to mouse and it's frame is set from the Inventory Slot. Then when clicking on an inv slot while you have something in your hand it switches the items and values, but something is wrong with the amount displays in Hand and Inv. Slot.

    Bug 2: When items are switched, and then switched again, RMB anywhere packs it back into the inventory. But, when you switch it normally and then RMB, it just adds the dropped amount into the other inventory slot.

    download project:

  • Clicking an inventory slot does nothing for me, what did I break?

  • The Inventory needs to be opened first with F. When it's open you can start using the inventory.

  • Ok I've done some investigation and I believe the cause could be :

    bug 1 - the values in the back end array are actually correct it's just the text hasnt updated because you didnt run the update inventory function again when you swap items, you only run it when you pick items up

    bug 2 - you don't update the anim frame value at X to reflect the new item, your focus was on changing the amount at Y which is correct, but the X remains for the previous item. So you update the animation of the item in hand, and the hand amount in the array but not the X value for the type.

  • The first bug fix works, but I still just can't make the second one work. I'm confused :/

  • Do you understand the issue though? I don't really have time to look into a fix but you should be able to make one based on your method. The bug occurs at the item switching, not on the right click. If you look at the array in debug mode you will see when you switch items, the X value remains the same which means the old animation frame is in the array, if you replace a 1 with a 2, it stays as 1, but the amount at Y updates correctly, you need to detect the anim frame of the other item and replace the value at X as currently you don't have any logic to do that.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Yes I understand it now, took me thirty minutes to figure it out. Not sure why I couldn't see it after the explanation, my mind was a bit blind there as I had changing an event in mind instead of adding another. I can't thank you enough for this plinkie! Can't describe you how much you helped me right now after hours of blindness to the issues! =]

  • Great, no problem :)

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