ID:165446
 
I know you can use mouse procs for statpanels and I'm wondering how to make it so when you double click an item in the stat panel.
You could add the double click to the item itself and check if(src in usr) to make sure that the person is carrying it.
then you can do w/e you want with it.(you didnt really mention what you wanted to do after the usr dbl clicks the item)
(the Double click is DblClick() I believe)
In response to Rky_nick
Yes. if(!src in usr) return will stop the procedure if the clicked object isn't in the player (in his inventory, contents var).
You can also use DblClick()'s argument to see EXACTLY in which statpanel the object was clicked (look it up for more info).
In response to Kaioken
I was going to make equipping.
In response to Kaioken
Liar, it'll not work the way you want it to because what you are saying is if(0 in usr).. the in takes a lesser priority, I recall... you meant if(!(src in usr))... than again, it has been a VERY long time since I used something like that so I don't know if the priority changed :/

- GhostAnime

Knowledge is a danger!
In response to GhostAnime
GhostAnime wrote:
Liar, it'll not work the way you want it to because what you are saying is if(0 in usr).. the in takes a lesser priority, I recall... you meant if(!(src in usr))... than again, it has been a VERY long time since I used something like that so I don't know if the priority changed :/

- GhostAnime

Knowledge is a danger!

I believe that they both work. Yet they produce an error when i try to use the if.

obj/weapons
Sword()
Dblclick()
if(!(src in usr))
Equip(Sword)


And the proc i am calling looks like this.

mob
proc
Equip(n)
equipped = "[n]"


I don't see a problem with the proc and it's only producing error in the if statement.

error: proc definition not allowed inside another proc
In response to Animay3
Ditch the brackets after 'sword'. They're making the compiler think 'sword' is a procedure.
In response to Jp
Jp wrote:
Ditch the brackets after 'sword'. They're making the compiler think 'sword' is a procedure.

Ok, After that it seems to think this:

error:Equip:undefined proc
error:Dblclick :undefined proc

code again:

obj/weapons
Sword
Dblclick()
if(!(src in usr))
Equip("Sword")
In response to Animay3
The procedure is 'DblClick()'. Capitalisation is important.

The procedure 'Equip' belongs to mobs. You're calling it by calling 'src.Equip(stuff)' (src is assumed if no source is provided). src is a /obj/sword, which doesn't have equip.

usr is, in general, safe in DblClick(), so changing that to usr.Equip(stuffs) will fix that issue.

Your equipment system has some problems, though - Rather then storing a text string representing what object the player has equipped, why not store the object itself?

proc/Equip(obj/o)
equipped=o


And then you'd call it like this (In the DblClick() proc):
usr.Equip(src)


That way, you always have the objects variables around and know which exact object the player has equipped.
In response to GhostAnime
GhostAnime wrote:
Liar,

;'(

Yes, you're right. I posted that late and forgot it back then. The 'in' operator has low precedence (sp?), you need the extra parenthesis.