ID:1296895
 
(See the best response by Albro1.)
Problem description:

So I've done a few searches for how to do this, but found nothing that seemed to pertain to me. What I'm trying to do is assign an attack verb to a mouseclick. I understand how macros work for keystrokes, but they don't seem to apply to mouseclicks.

I've also tried re-writing Click() for areas, thinking that if anyone clicked anywhere inside the screen it would simply execute the attack(), but to no avail.

Additionally, if there is a legitimate way to do this, will it conflict with my target system? Essentially, what I'm aiming for is for players to be able to click mobs to target them, then click anywhere else on screen to initiate the attack().

Here is the code where I rewrote Click() for mobs to incorporate targeting.
Code:
mob
Click()
var/C = src
if (usr == src)
return
usr:Target(C)


The code is just to show you how my target control works and see if it'd be compatible with a mouseclick attack() assignment.
And what is happening instead of what you want/expect?
You're probably looking for call(), however, I do suggest that you make it a habit not to fill your verbs with things that could be used/called internally. For example, an attack proc would be much easier to work with internally than an attack verb - you could make an attack verb that calls the attack proc, and then you could still call the attack proc anywhere else you needed to.
Sorry if my original post was confusing. I want for players to be able to click their mouse button and it trigger the attack verb. Is this possible?

As for call(), I'm a bit confused...If I have a proc to call, can't I just outright type the name of the proc? Why is using call() more beneficial?
Ah, I came to a semi resolution.

I added the attack proc into the client/Click() which made it work just fine.

However, that has cancelled out the click-to-target.

Anyone know of a way I can make these two work together?
mob
Click()
var/C = src
if (usr == src)
return
usr:Target(C)

client
Click()
usr.attack()
..()
And then one last question. I couldn't make use of right-click could I?
Best response
If you have a proc to call, you can outright call the proc.

You were saying you were wanting to call an attack verb.

You can use right-click, but it's a bit more complicated. I believe it is done somewhat like this:
Click()
var l[0] = params2list(params) // params is one of the arguments in Click()
// access the right click by using l["right-click"]


I haven't ever personally messed with right-clicking, but I've seen it utilized and that's what I remember. If anyone would care to elaborate, please do.
Well that's gotten me in the right direction. I did some poking around the DM Reference and found a section called "mouse control" as well. It goes over the params and such, but I still can't seem to piece it together.
Okay, I've got the code portion down it seems.

I've been perusing the forums a bit more though, and it seems that in order for it to work I'll need to enable a "Send right-clicks to mouse proc" option in the map control. I created an interface file, but I was unable to find this option. Could anyone point me in the right direction?
Did you create the map control in that interface file? It should be a checkbox in one of the tabs (Forgive me, I can't check which one right now).

If my memory serves me correctly it is on the first tab, with the name setting and such.
params = params2list(params)
if("right" in params)
//etc.

To right click

You also need to make sure it's enabled in the window you're right clicking on in your interface.
In response to JunK Games
He already got that part lol
Huh my window originally only loaded to post 7, that's odd.
Think through what you want to do:

If the player clicks on a mob, target them
If the player clicks elsewhere on the screen, and has a target, attack them.

mob/verb/testverb()
var/a = pick(1 to 80)
world << a

client/Click(clicked)
if (ismob(clicked) && clicked != mob)
.=..()
else
var/mob/player/player_mob = mob // whatever type your player is
if (player_mob.has_a_target()) // however you store targeting.
player_mob.attack(target) // however your attack works


You probably don't want to be using the colon operator in your mob/Click(). Make a typecast variable and set it to usr - that way if you change how your targeting procedure works you'll get a compile-time error, not a runtime error.

And finally, you can just call a verb directly, like it was a proc. Because it is a proc.