I'm trying to make a decent toolbar but I'm having trouble getting the game to detect that I have something equipped in the toolbar.
I have come up with these errors:
1. I select the sword in slot 1, it changes to the sword sprite and removes it when I stop selecting slot 1, but if I equip a sword in slot 1 and 2 when I select slot 1 not if it changes the sprite when I am in slot 2
2. I select the sword in slot 1, change the sprite of the sword and remove it when I stop selecting it, but if I equip a sword in slot 1 and 2 when selecting slot 2 does nothing and only does it in slot 1
Here is an example of error 2
The code:
I have come up with these errors:
1. I select the sword in slot 1, it changes to the sword sprite and removes it when I stop selecting slot 1, but if I equip a sword in slot 1 and 2 when I select slot 1 not if it changes the sprite when I am in slot 2
2. I select the sword in slot 1, change the sprite of the sword and remove it when I stop selecting it, but if I equip a sword in slot 1 and 2 when selecting slot 2 does nothing and only does it in slot 1
Here is an example of error 2
The code:
GML:
#region Change sprite depending on what you have equipped
if (global.tb_slot1 == item_1)
{
if (global.tb_pos == 1)
{
sprite_index = spr_PlayerWS;
}
else
{
sprite_index = spr_Player;
}
}
else if (global.tb_slot2 == item_1)
{
if (global.tb_pos == 2)
{
sprite_index = spr_PlayerWS;
}
else
{
sprite_index = spr_Player;
}
}
#endregion