GMS 2 How to set different identification numbers for the same thing?

Hello everyone,

I am a beginner to Game Maker Studio 2 from Russia, sorry for my mistakes
I made an inventory, I want things to have durtability. But there is a nuance, while reducing the durtability of things, it turns out that it will decrease in all the same things, if there are 2 or more of them in the inventory.
My armor is an object, if there are two armors in the inventory, then both of them become identical in durtability, but they need to be different.
As I understand all things, even one type should have different identifiers, how to implement it in GMS2? Or how is this done?
 
Last edited:

TsukaYuriko

šŸŒ 
Forum Staff
Moderator
We would have to see your current implementation to be able to suggest accurate solutions, so please post what you have so far.
 
My armor is an object, if there are two armors in the inventory, then both of them become identical in durtability, but they need to be different
 

TsukaYuriko

šŸŒ 
Forum Staff
Moderator
Please don't only paraphrase your code. That merely tells us its intention, not its actual function, which may differ from the intention. Post the relevant code.

For further information, please check out our topic about how to post code.
 

NightFrost

Member
That is one reason why inventory items should exist as pure data instead of being made as objects. There are gamemaker inventory tutorials around that build inventories in that manner, search for those. In the long run it makes inventory management easier than using objects.
 

Danei

Member
If you are using something like
Code:
obj_armor.durability -= 1
Then it will impact every instance of obj_armor, and you need to use the instance ID instead. You could, for example, have a variable to track the ID of the currently equipped armor, which you change whenever you run your equipment selection code on an instance of obj_armor.
 

samspade

Member
Hello everyone,

I am a beginner to Game Maker Studio 2 from Russia, sorry for my mistakes
I made an inventory, I want things to have durtability. But there is a nuance, while reducing the durtability of things, it turns out that it will decrease in all the same things, if there are 2 or more of them in the inventory.
My armor is an object, if there are two armors in the inventory, then both of them become identical in durtability, but they need to be different.
As I understand all things, even one type should have different identifiers, how to implement it in GMS2? Or how is this done?
While you could do this with objects, you probably shouldn't. I would recommend either of these two videos on inventories.


 
Top