09.09.2013, 22:28
Okay I don't know much about it, but I wanted to know about something that has to do with IDs.
Bare with me here.
With unique IDs it's simple counting:
A = 1
B = 2
C = 3
D = 4
F = 5
G = 6
But if I wanted to combine ID's, I'd do:
A = 1
B = 2
C = 4
D = 8
E = 16
F = 32
G = 64
... etc.
And now I can A + B = 3. 3 will be A and B.
This is useful for such systems like a item system, that saves into a database.
new PlayerItem = 7; // Player has Item A, Item B, and Item C.
But my problem is, how do I check if player has Item B if PlayerItem is set to 7?
Bare with me here.
With unique IDs it's simple counting:
A = 1
B = 2
C = 3
D = 4
F = 5
G = 6
But if I wanted to combine ID's, I'd do:
A = 1
B = 2
C = 4
D = 8
E = 16
F = 32
G = 64
... etc.
And now I can A + B = 3. 3 will be A and B.
This is useful for such systems like a item system, that saves into a database.
new PlayerItem = 7; // Player has Item A, Item B, and Item C.
But my problem is, how do I check if player has Item B if PlayerItem is set to 7?