In my game I have it so that you can have different clothes in your inventory and that if you click the clothing item, it adds it to your character as an overlay.
But I also want it so that if you click the clothing item when it's already on you, it'll check if that clothing icon's already in your overlays variable and take off the clothing overlay if it is.
So how do I detect if a certain icon (like the icon of certain clothing items being clicked on) is already being used as a user's overlay?
"if(M.icon in src.mob.overlays)" and "if(M in src.mob.overlays)" in "client/Click(mob/M)" always come out as false for me.
ID:157532
Feb 20 2010, 1:29 pm
|
|
Feb 20 2010, 1:39 pm
|
|
How about you just subtract the overlay regardless. If it's in the overlays list, it'll be remove.
|
In response to Spunky_Girl
|
|
It's because there's a bunch of different type of clothes in my game that can be worn at the same time (hats, glasses, jackets)
so when something is clicked, it checks if the mob's accessory variable is 1, and if so then that's where the overlay check would happen. It can't just subtract the overlay since it's different depending on what cloth item was clicked. For example of what I'm trying to explain, my code that doesn't work looks like this so far: if(M.accessory==1) |
In response to MartialArtistAbu
|
|
set up a different variable for each item 0_0. Since there are different layers for clothing anyways. Its more time consuming but less mind boggolingg.
|
In response to Darkjohn66
|
|
I thought of that before and it was how I handled it in the game 6 years ago, but I'd prefer a way that doesn't involve multiple variables and checks ...
Although there's different types of clothing, there's still multiple things people can wear just on their head at the same time like glasses and a bow and a little cap |
In response to MartialArtistAbu
|
|
There's two solutions to this problem I believe.
1. If you'd like, create a variable for each "body part", ie hands, torso, etc, that stores the object itself that's being added to the overlays, and then when you want to "replace" that overlay, subtract it from the overlays before storing the other object. mob/var/hands = list() 2. Do what I do, and have a separate list to handle overlays that stores objects themselves rather than just the icons like what the overlays list does. Then you can use that list instead of the "special" built in one. mob/var/list/overs = list() |
You could always set the users overlays to null every time they equip/unequip an item, and then just re-add all the overlays they will need.
|
//our equipment |