ID:156708
 
Is it possible to make Click() click something other than the src? If so, can somebody tell me how? I was thinking along the lines of:
obj/Button
Click()
var/obj/card/O.Click()

But that doesn't seem to like me very much.
What are you trying to do? It sounds like you should just make a procedure on that object and call it manually, instead of hijacking a built-in procedure
obj/card/proc/effect(mob/M)
if(M)
M << "Card goes BOOM!"
del src


HUD/button/Destroy_cards()
for(var/obj/card/O in usr) // One safe procedure to use usr in is proc.
O.effect(usr)
The click proc for an atom is much different from the click proc for a client. When you alter the default behavior of the atom's click proc you are basically telling that atom what you want it to do when it is clicked. You won't receive info on the thing that clicks it.

obj/Button
var/enabled=1
Click(location, control, params) //these arguments are explained in the reference
//do stuff related to the button and only the button here
if(enabled)
Button.enabled=0


However, the arguments for a client's click proc allow you to tell which object the client is clicking as well as information about that object.

client
Click(object, location, control, params) //these arguments are explained in the reference
//do stuff related to the user who clicked as well as the object that was clicked
..()
if(istype(object,/obj/Button))
usr<<"You clicked a button!"
object<<"You were clicked, congrats!"



I'm not really sure what you were trying to do there, but it looks like you were trying to get an object to click something else...

EDIT: Also might be worth noting that when you override the default action of client/Click() if you do not remember to call the default action it will not process object.Click().
if you want the button to call Click() on another object you would need to fist predetermined which object that is, then call the click for that object.

obj
card
Click()
..()
//here is were the cards click procedure should be
button
var
obj/card
New //this is for the sake of making sure the object isn't null
..()
card=new/obj/card

Click()
..()
card.Click()


With this. you're looking for a variable of the clicked button and then calling the click for that variable. In this case the button has a variable called "card" which will be the obj/card that you want to be clicked as a result.
you can then change which obj/card is the variable for the button, and upon clicking the button it will call the click proc for the card.
In response to Bravo1
Thank-you guys. I guess I should have explained in more detail, but Bravo1 showed me what I was looking for. I have read the references for the Click() procedure. I'll be back if I have any more issues, what I basically am trying to do is have a macro system based off of clicking one main object by calling:

.click macro_one

On repeat for key 1. Then I could have that click procedure call the click procedure of another object, so that I can set up macros at runtime.
In response to Darkjohn66
Or you could just... set up macros at runtime? Using winset()?