[Solved] Hotbar/inventory system

That looks different than the version I downloaded, Here’s how my copy looks.

Heck, I copied it that way and it worked almost perfectly.

I only found a bug if I messed around too much with the order of the previous cards already in the slots



I don’t know how to explain the bug, but I think you can see from the screenshots that the sunflower wasn’t supposed to be in place of the other purple card

Note: It’s a bit difficult to make this bug

Now the bug has returned where the cards in the inventory have to be clicked twice to actually leave the inventory

IDK, double check your events. The version I downloaded seems fine. All I changed was the “and” and “or” section.


The current state of the code.

I tried opening the debugger when I click the [refresh] the preview crashes. IDKW.

I’m done for the night. Keep looking. Post any updates. Tomorrow is a new day.

Okay, thanks for everything! I’ll try to fix the rest of the game

I did some more testing. It seems to work fine as long as I previewed it from the first scene. If I forgot and previewed it from a different scene, the cards would stack up on the hot bar. I set the first scene as the default. Either I didn’t save it that way or the setting resets either by itself or some action. IDKW.

I can understand if things weren’t set to an initial value but the code is setting the boolean and should prevent that. Variables must not behave the same way when the scenes aren’t started from the beginning. Maybe they don’t retain their value when other scenes or external events are run first.

This bug report said the objects were doubled when run from and external layouts maybe the sames true with external events.

As far as I can tell, that’s probably what it is. In what I’ve tested, it works perfectly if I leave the scene as default forever and everything. But to make sure that one of the bugs doesn’t happen, how should I make sure that the card is NEVER on top of the other? Should I just set collision detecting or something?

Also, this bug makes total sense here. Since it’s a mixture of external layout + external events

Now that I have an idea of what might be happening, I want to do more testing. I think the easiest way is with a text object that shows the value of the objects under the cursor. It would be easier than trying to find the object in the debugger. Show the boolean values of the object under the cursor in a text object in real-time.

The boolean variable should prevent it. I guess you could check for collisions or multiple collisions or even collision between cards but until we know what is happening, I don’t know what to do.

Okay, one hypothesis I have for now is that this card collision bug could also be the fault of the external events. Because so far, I haven’t had any more after always testing in the initial phase as standard

Ok, I just tested it and if you launch it from the external event sheet it doubles the sprites. Not only are there twice as many cards but also twice as many slots. So, mechanically, everything is working, It’s just that there are basically 2 stacked games running at the same time.

I changed the x,y for the create objects from external layout It shows the ones in the layout and then the ones that get added. This should only happen at design time if you preview from a different scene or layout.

(The extra text objects were added for testing)

The fix is to preview from the Day scene or check if the objects exist before adding the external layout.

This seems to work

Was that print you sent the only configuration/change you made? To make it work

yes, I just moved the create objects down and added a condition to check if there are already cards. That should only be needed during design mode. If the objects don’t exist, it creates them.

Ok, ok! Thanks so much!

1 Like

This print fixes the first card duplication bug, correct? And the colliding card bug?

From what I can tell, the cards were colliding because there was double of everything. Two sets of cards and two sets of slots. It looked like the cards were going into the same slots but they were really going into 2 diffent stacked slots. A top and bottom slot. They would then both return to where they started which was on top of each other. It was like playing 2 games at the same time.

That part should be fixed. It’s not really broken. It’s just how GDevelop works. If not previewed from the beginning it adds the external layout for some reason and then your events add what should be the set. The new condition checks if there are already objects. If not it adds them.

Okay, that was the first problem. But there’s still the second bug, which is kind of rare. This occurs if you remove 2 cards already selected from the slots and then put 2 other cards back in (which may or may not be different).
I’ve even sent a screenshot of the bug

Note: It can be between a resealed card and 2 cards.

Is it still happening. That seems related to the first.

There were at least 2 issues. First, if the slots were full and 2nd starting from externals caused duplicate sprites.

1 Like

Exactly, except that the first bug is that you can somehow overlap one card with another.
The second bug has already been fixed, as far as I can see