obj/item/var
item_inHand = 0
item_Slot = "None"
item_slotInhabited="None"
//obj/item/clothing/var
//item_Slot = "None"
obj/item/clothing/shirt/
icon = 'clothing.dmi'
icon_state = "shirt"
item_Slot = "equip_Shirt"
obj/item/clothing/shirt2/
icon = 'clothing.dmi'
icon_state = "shirt2"
item_Slot = "equip_Shirt"
///Picking up///
obj/item/Click()
var/mob/human/player/M=usr
if (M.vars[M.hand_Selected]=="Nothing")
if(usr in view(src,1))
//Pick up item
if(!(src in M))
M.vars[M.hand_Selected]=src
src.item_slotInhabited=M.hand_Selected
src.Move(M)
//Swap item between hands
if(src in M)
if (src.item_slotInhabited == "hand_Left" || "hand_Right")
M.vars[M.hand_notSelected]="Nothing"
M.vars[M.hand_Selected]=src
src.item_slotInhabited=M.hand_Selected
world << "[src] is in, \"[src.item_slotInhabited]\""
//Move item from inventory to hands
//else
//M.vars[src.item_Slot] = "Nothing"
obj/item/clothing/verb/Wear()
var/mob/human/player/M=usr
if(src.item_slotInhabited == "hand_Left" || "hand_Right")
if (M.vars[src.item_Slot] == "Nothing")
M.vars[src.item_slotInhabited] = "Nothing"
M.vars[src.item_Slot] = src
src.item_slotInhabited = src.item_Slot
world << "[src] is in, \"[src.item_slotInhabited]\""
Problem description:
First off, sorry about the length of this post. I just wanted to describe what I'm trying to do as thoroughly as possible.
item_Slot tells the item where it should go when it's equipped.
item_slotInhabited returns the current slot (variable in string form) the item inhabits.
hand_Selected and hand_notSelected returns the current selected hand (variable in string form) and the current unselected hand, respectively.
Basically, when the player clicks on an item while it's on the ground, it moves it the their currently selected hand and updates. If the player switches hands and clicks the item, it moves it to their currently selected hand. If the player uses the Wear() verb while the item is in either of the player's hands, it moves it to the slot designated by the variable item_Slot. With each of these actions, item_slotInhabited is updated to reflect the items current slot.
At the moment, if the player clicks on an item which isn't on the ground or in either of their hands, nothing should happen, because the variable item_slotInhabited doesn't meet the condition if (src.item_slotInhabited == "hand_Left" || "hand_Right"). But, for some inexplicable (for me, at least) reason, it does: the item is "moved" to the currently selected hand, while a duplicate item remains. My first impression was that item_slotInhabited wasn't being updated correctly, but after throwing in a piece of debug text (world << "[src] is in, \"[src.item_slotInhabited]\"") I knew that this wasn't the case
I'm guessing that I've made some sort of syntax error, but I have no idea what. I've tinkered around with it for a while now and haven't really gotten any closer to a solution. Any help would be appreciated.
It's like you have two boxes of balls in front of you, one labeled blue, the other red. Right now, you're trying to dig through the red box to find a blue ball, when you could just look two feet over and check the other one.
Try removing the M.vars[] from your code entirely. I see no real purpose of them and they're just causing more problems than they're solving. Right now, since the game is trying to change variables that don't exist in a certain box, nothing get changed, therefor the variables remain the same and can pass your if() statements without any problems.