cbcerquiaga / YouMeAndTheEndOfTheWorld

A 2 player RPG set in a post-asteroid Earth and created with the Godot engine
MIT License
13 stars 4 forks source link

Inventory shows incorrect number of items when picking up items #157

Closed cbcerquiaga closed 5 years ago

cbcerquiaga commented 5 years ago

It looks like it's multiplying item counts, not adding or showing a random number. I was working on dropping items from the menu, and so I picked up the coins and tried to drop them from the menu. The console read:

Added 5 Coin to p1's inventory Added 10 Coin to p1's inventory Added 20 Coin to p1's inventory Added 40 Coin to p1's inventory inventory loaded quests: [] weapons: [] equippables: [] consumables: [] misc: [[StaticBody2D:1519]] discovered places: [] Added 80 Coin to p1's inventory Added 160 Coin to p1's inventory Added 320 Coin to p1's inventory Added 640 Coin to p1's inventory misc item Added 1280 Coin to p1's inventory Added 2560 Coin to p1's inventory Added 5120 Coin to p1's inventory emit signal 2

"emit signal 2" is from the inventoryOptionPopup, so that's not relevant here. It looks like it's just continuously multiplying the 5 coins by 2- maybe every cycle that the action button was pressed.

dzwiener commented 5 years ago

Yes, the issue likely has to do with a delay of deactivation of the dropped item and the in game ticks.

dzwiener commented 5 years ago

Added an instance variable to each item so that it can detect if it has already been picked up. Then re-enables it when dropped. This has fixed the issue.