ID:140932
 
Code:
    equips
verb
get()
set src in oview(1,usr)
set category = null
if (src.Move(usr))
usr<< "<b> You picked up [src.name]!</b>"
Drop()
set src in usr.contents
set category = null
if (src.Move(usr.loc))
usr<<"<b> You dropped [src.name]!</b>"
proc
equip()
DblClick()
if((src in usr.inventory))
src.equip()
clothing
equip()
var/mob/User=src.loc
if(User)
if(ismob(User))
if((src in User.equipped))
src.suffix=""
User.overlays-=src.icon
User<<"<b> You unequip the [src.name].</b>"
User.equipped.Remove(src,null)
else
src.suffix= "<Equipped>"
User.overlays+=src.icon
User<<"<b>You equip the [src.name].</b>"
User.equipped.Add(src)
cape
icon='Objects.dmi'
icon_state="cape"
equip()
..()


Problem description:

I've been learning how to setup an equip system for my inventory screen and I have ran into a few issues not sure why its not working correctly.

The first problem is DblClick() "when I double click the item it wont use the equip() proc for some reason", "If at all possible is there a way I can make a verb saying equip and then set up a Else verb to unequip items."

The 2nd problem is the icon overlay (through setting up a verb to make the proc just happen) The icon wont overlay which is a cape over the players sprite. I have tried other expressions but nothings overlaying and cant really test taking away the overlaying if the thing will not work in general.


"I'm sort of a newbie to programming on byond code and have been learning from resources and the blue book so very sorry to bother if this is a simple task" ^^ thanks for any advice or help..



So no one knows how to solve it or is it too simple :/
For the first question:

if((src in usr.inventory))

I have no idea what inventory is, but from what I can see you're using contents. So:

if(src in usr.contents)

Would work better. Or, using the src setting will help to!

set src in usr

And yes, the src setting should work for DblClick() (at least, it works for Click()).


For the second question:

var/mob/User=src.loc
if(User)
if(ismob(User))

Quite obviously, User isn't a mob. You've defined it as a mob, but it's equal to src.loc, which is a var, which is usually equal to a turf.
In response to Demon_F0rce
Demon_F0rce wrote
For the second question:

var/mob/User=src.loc
if(User)
if(ismob(User))

Quite obviously, User isn't a mob. You've defined it as a mob, but it's equal to src.loc, which is a var, which is usually equal to a turf.

If an object is in a mob's contents its loc is the person holding it.

If an object isn't in a mob's contents then you're correct, it is equal to a turf.
In response to AJX
I see, my bad.

However, seeing as he's never said anywhere that it's in him, I'd take a guess that he's problem lies in it's loc being equal to a turf.
In response to Demon_F0rce
Demon_F0rce wrote:
I see, my bad.

No problem. Just clarifying for informational purposes.

However, seeing as he's never said anywhere that it's in him, I'd take a guess that he's problem lies in it's loc being equal to a turf.

That's the point though. The check to see if the object is in the inventory is on the equip() proc, and that is an appropriate check. The problem is probably elsewhere.
In response to AJX
Okay I changed usr.inventory to usr.contents "your right it does have a lot more point but I'm still having issues with Dblclick and I even tried changing it to click with the src setting in fact the entire Equipping part does not work either Not sure what I'm doing wrong I might look at some equipping demos the one i used to learn this was most likely outdated since it tried to define usr.inventory as its own var for usr.contents... Any thoughts?
In response to DeathBane
Ok. Diagnosing 101.
Step 1: Track down where your code is stopping.
Explanation: Do this by adding world<<"" messages at each point, seeing where the messages stop

So, do what I listed below, and see what happens.


Step 1:
            get()
set src in oview(1,usr)
set category = null
if (src.Move(usr))
usr<< "<b> You picked up [src.name]!</b>"
usr<<"[src.loc]" // ***Do this, to verify what the object's loc is
> Drop()
> set src in usr.contents
> set category = null
> if (src.Move(usr.loc))
> usr<<"<b> You dropped [src.name]!</b>"
> proc
> equip()
> DblClick()
> if((src in usr.inventory))
> src.equip()
> clothing
> equip()
> var/mob/User=src.loc
> world<<"Equip is being called. [src], [User]" // **Do this, to see that equip is being called
> if(User)
> if(ismob(User))
> world<<"User IS A MOB!"
> if((src in User.equipped))
> src.suffix=""
> User.overlays-=src.icon
> User<<"<b> You unequip the [src.name].</b>"
> User.equipped.Remove(src,null)
> else
> src.suffix= "<Equipped>"
> User.overlays+=src.icon
> User<<"<b>You equip the [src.name].</b>"
> User.equipped.Add(src)
> cape
> icon='Objects.dmi'
> icon_state="cape"
> equip()
> ..()
>