Jump to content

Midweek Bugfix - Inventory Item Adds


Oafkad

Recommended Posts

So! Sorted the bug that was giving me tons and tons of copies of the items to our inventory. It was actually quite simple and very silly. We might as well cover it really quick.

The original code, first adding, and then removing.

image.png

image.png

So the mistake here is very subtle, specifically how does equality work with Datum? For two datum to match they must be the same in ALL ways. Their name, their ID, and their count. But what if, lets say, you are adding a single copy of an item to your inventory and you've got...oh I don't know, 25 of them?

Well congratulations you just got another entry in your inventory. Following this we increase the count of the original instance and thus you are left with a 0 entry of your items. So what did I actually need to do?

image.png

image.png

Well there you go! That was a very silly mistake, but at least it is good now! I also realized I haven't tested adventure recovery when saving and loading. We won't do that this week but I've got it on my mind.

Tomorrow hopefully we'll get even more done! I'm pretty pleased with catching this bug, as small as it is, AND getting most of our lawn mowed.

Link to comment
Share on other sites

×
×
  • Create New...