Equipping Trinkets


I’ve got a rather difficult problem to ask here…

I want to add a trinket system to my game, ones that can be added to their own designated slot and be equipped to provide passive effects to the player

The way I set this up is that I have the trinket inventory with 2 pages (Each on their own external layout, then loaded in as a layer). These pages are cycled through by a pagination system. When you click on the trinket after picking it up, it will be equipped or unequipped


However, I’m having issues when trying to equip these trinkets

I want to have the trinkets be equipped relative to the slots they’re in. If you click on a slot, equip/unequip. If it’s equipped, put a blend mode layer on the slot, and remove it when it’s not equipped.

My code isn’t working correctly

Also, whenever I try to equip a trinket from the second page, the trinket from the first page gets equipped since they’re overlapping the same slot

If I click on a trinket from page 1, a page 2 trinket gets equipped. I would like for the inactive pages to not equip trinkets of course

How can I make it so that I can equip the trinkets from the inventory the way I want to while also keeping the paginating trinket tabs in mind?

Are you just using hide for inactive layers? If so maybe you can set up a condition that they’re not hidden (if hiding layers lets that work, not sure it might be only actual object visibility counts to check if an item is visible) or if it’s on a layer that’s visible.
For the other thing, the blend thing, maybe drag it out so it’s an independent condition/action. Worth a shot. If not, I’d tie it to another condition like maybe just a simple boolean is equipped.

Alright, I tweaked the code a bit like you said (Tried the hiding layer thingy) and now the trinkets equip and unequip like they should. Unfortunately, one other problem persists. Here, I’ll show you:


Basically, what’s happening is that when I click on the trinket in slot 2, the hidden slot BEHIND that slot also gets equipped and unequipped. How can I made it so only the trinket on the active page gets selected while the hidden one gets ignored entirely?

I tried uninverting the hide layer condition, but it just straight up prevents trinkets from being equipped…

Is there some sort of special trick to solve this? Thanks

Just checking, the variable trinkPage is spelled like that with the lowercase t?

Add a variable currentPage to differentiate which page you are on.


Like this?

The variable trinkPage already plays the role of currentPage in this case, and it didn’t work either. Any other ideas?

And yes, the t is lowercase

I don’t think the layer is visible is helping. It’s just asking if the layer is visible.
Have you tried using the condition TrinkCell “current layer” is Variable(trinkPage) ?

Just a word of caution. If it’s possible for both [OR] conditions to be true, then both TrinkCell sprites would be “picked”. The one in collision with the selector and the one with the mouse. The “z” key and mouse would have to be pressed at the same time but it’s not tough if you repeatedly do it.

I don’t know enough about your project to know if that’s possible. You could check that the “number of instances picked” equals 1 which would also prevent multiple cells from being touched simultaneously.


Alright, I added the current layer event, and got some new results

The project seems inconsistent now, sometimes both slots equip at once, and other times they behave separately, and sometimes the trinket takes multiple clicks to even equip

Is there anything else I can do here?

Also, I tested, the OR event doesn’t conflict anything here

Can you post a pic of the most recent version of the events?

Okey, here they are

(Note: The new code is inverted because uninverted doesn’t work for some reason)

IDK. It should work without being inverted. I would make sure all of the objects are on the right layers. You can double check with the debugger. I’d also check the value of the trinkPage. Make sure it’s changing properly.

This seems to be your process:

if cursor is on cell and mouse is released then all cells on all layers at that location get picked
if the cells animation isn’t 0 then they get unpicked
if the cell is on “Layer” + Variable(tinkerLayer) should pick only instances left on that layer.

same for the one that uses a collision and the Z key.

There are only 3 options, either the layer variable isn’t the right value, the object(s) isn’t on the right layer or code somewhere else is doing something.

I created a project just to test the process. It uses a text object instead of sprites but it’s the same process.

If you click the numbers, it changes layers. If you click the text object it spins. The “X” is the selector. If you drag it onto one of the text boxes and then press “Z” it will also rotate the text object.

Source: doug13579/Inventory-layers (github.com)

Out of curiosity, are the text objects in TrinketGroup separate text objects? Because I’m using the same trinket cells for both pages. Is THAT the problem?

Also, I tried with the debugger after uninverting the condition, the trinkets don’t equip unless it’s inverted. I did some more debugging, and I can confirm that both trinkPages 1 and 2 are each on their own layers in their own external scenes, and the TrinkPage variable is changing properly

I’m completely lost on what’s wrong with the project. Should I just send it to you?

The problem could be anywhere. It’s usually something small like a typo or something that looks like it should’ve worked. I’d be happy to have look. Send me a link to your project files and I’ll take look today (Monday).

Okey, thanks

Here’s my project file:

To get to the problem code, open the external event “GameManager,” and under the yellow group “Trinket Inventory,” it’s underneath the subgroup “Equipping Trinkets”

Ok, I downloaded it. I’m still trying to understand the way it works.

I noticed the trinkPage variable switches between 0 and 1 while the trink layers are named trinkPage1 and trinkPage2. Also, when you check the layer, you had spaces in the name.


After removing spaces ( I changed "Trink Page " to “TrinkPage”) and added +1

I also removed the [inverted] status.

1 Like

How embarrassing, I can’t believe I didn’t notice that I was one number off

Thank you so much for tracking down the issue ^^

It works properly now. All I need to do now is add the logic to equipping

Thanks againnn

1 Like