ID:273642
 
interface
border
BRC2
layer=9
icon='Buttons.dmi'
icon_state="1"
screen_loc="14:8,1"
var/clicked
Click()if(!clicked)
usr.okay=1
clicked=1
for(var/interface/O in usr.client.screen)usr.client.screen-=O


How can i change the Click() section to a verb called Action(), which is called when the user presses the space bar? (I understand that a macro for Action is required, with a shortkey of the spacebar, but it is the set up of the verb that is confusing me). Or is it even possible?
Generally, a macro can't activate a proc*, so you can't pull it off exactly like what you've said, but you can pull off the exact effect in a different way. You can have the macro execute a verb that calls Click(), but that's not so good, calling Click() manually like that. Instead, you should move the code in Click() over to the verb that's run by the macro, and have Click() call the verb (no need to pass the correct usr to the verb manually, since usr is already the clicking player in Click() so the correct mob is passed).

*: This is because a macro just runs a client command (like those you can execute in an input control or from Options and Messages), and client commands can't arbitrarily run procs (or it'd be a huge stupidity as well as exploit, of course).
But since Click() is a special, verb-like proc, you can call it with a macro using the .click AtomName client command. But doing it this way is not as flexible or reliable as the other methods, so the one I already recommended is far more recommended.


By the way, if the only objects in the player's screen are of the /interface type, then you can replace the for() loop with a simple, instant emptying of the list (such as screen.Cut()) to achieve the exact same effect.
In response to Kaioken
Well, the click() command is on an item that actually appears on screen, and i am using the verb "Action()" as a general verb for anything that the player can use the space bar for, e.g. talking to NPCs or "clicking" this button in the code i presented to remove the clients text boxes and text. If i put "Action()" as a button for the verb, would this still work?
In response to SadKat Gaming
Your question is unclear. For your implementation, however, you could design it like this:
atom/verb/Action() //verb is available on all atoms

mob/NPC/Action() //override it for mobs
set src in oview(3)
src.Talk_With(usr)

obj/item/Action()
set src in usr.loc
if(src.Move(usr))
usr << "You pick up [src]."

Then to make it possible to do the action by clicking, you could do this:
atom/Click()
//calling a verb: need to set the usr value to pass:
//usr = usr // but usr is already the correct value
src.Action()

(Though, you probably don't want to override clicking for absolutely every atom like this, in which case you'd do this instead:)
mob/NPC/Click() src.Action()
obj/item/Click() src.Action()
In response to Kaioken
Well, What i mean is this:

The object, interface/border/BRC2, is a little button that appears on every text box that is shown on screen. The user clicks this button, and the text box dissapears, along with the text.

When the text box is called, it displays the text box and the button on the client's screen, and then starts typing the text on the text box.

What im trying to do is make the Action() verb do the job of this button, with a simple press of the space bar thanks to the macro, but this means that the action verb has to be available to the user at the initiation of the text box proc.

Would what you showed earlier allow this?
In response to SadKat Gaming
What I showed earlier is a general/arbitrary example. You need to adapt it to your situation.

Note that "set src in usr.client.screen" is a valid src setting. This means you can place/override a verb on the screen object itself (that's representing the button) and have the verb available when this object is in the player's screen. Of course, it's just one way of doing things.
In response to Kaioken
Ok, i tried to add this in. However, now if i try to use the Action() verb on the NPC i have, it wont work. However, if i right click and select the action verb on the NPC itself, it will work. How do i prevent this?

<S>EDIT - also, i added in the "set src in usr.client.screen" to the Action() verb in the button's override, and it still wont work. Any idea why?</s>

<s>EDIT 2 - Ok, i changed the location of the src in usr.client.screen to the atom part. The only problem is that it will present the user with a list of all atoms on the users screen, even those that the Action() verb does nothing for. How can i change this so that the only items in the list are those atoms which Action() is relevant to?</s>

EDIT 3 - Ah, found it. I set src in oview(-1) as the default range, so that it found nothing, then i overrode the objects in which the Action() verb was relevant, changing their range to suit. However, is there a way so that once a player has, say, talked to a mob, whos Action() range is view(1), that i can make the only atom in the list the button so that the player has to just press space to end the speech?