ID:1828408
 
(See the best response by Super Saiyan X.)
Code:
/proc/get_fax_machines()
var/list/faxes = new()
for(var/obj/machinery/faxmachine/F in machines)
faxes += F
return faxes

/client/proc/sendFax(var/obj/machinery/faxmachine/fax in get_fax_machines())
set name = "Send Fax"
set category = "Admin"
if (!istype(fax,/obj/machinery/faxmachine)) return
// Snippped to save space.


Problem description:
This is for space station 13, where you can right click on an object and get a list of procs and verbs etc.

Clicking on a mob gives you a freeze verb etc, I'm trying to add in a new one for sending in a fax to a object type (see above) however it' showing up on say /obj/structure/stool/bed/chair too see this image:

http://i.imgur.com/ds86j6b.png

I was also suggested to add in this as an attempted fix by other devs:
/client/proc/sendFax(var/fax as obj/machinery/faxmachine in get_faxes())


I'm really new to this and I'm quite unsure how all of this works and the IRC is unsure also...
Best response
You can only limit what appears in context menus by atomic type. Though the verb will appear in the context menu, it will give an error if used (because it's not in the list).

There's no way around it if you want to keep sendFax as a client verb.
Giving the sendFax verb to the fax machine object itself would remedy the issue, but then who knows how it'll work as an administrative command.
Using MyVerb(Arg in MyList()) will let you choose from MyList() when you call the verb because MyList() is called when you click or expand (in the input bar) the verb, but it won't cause the elements of MyList() to gain the verb in the context menu. For that to happen, I think the engine would have to check for the object that you right-click, in the arguments of every verb you have. Would be cool, if done right.
/obj/machinery/faxmachine/proc/sendFax(var/obj/machinery/faxmachine/fax in get_fax_machines())
set name = "Send Fax"
set category = "Admin"
if (!istype(fax,/obj/machinery/faxmachine)) return

So, that is being added to the verb lists of admins however it still persists on other objects...


Would there be a way to set src in admins() or something like that?

Edit: I'll be trying something else first actually..
That didn't work, is there a thing like
if (!usr.admin)
set category = null
else
set category = "Admin"


Some way to hide it from the verb list on the right, or hide it from the context menu if a statement is true etc?

Nope, but if you don't use invisibility for anything, set the admins visibility up and use set invisibility on the verbs in question...that will make it so you can code everything else about it however you want while still making it only available to admins.

However this obviously stops you from really using invisibility in any other way.
I ended up just going with my other idea.


However I must ask:

Super Saiyan X wrote:
You can only limit what appears in context menus by atomic type.

Will this ever be changed? I'd love to see this feature it'd be really helpful.