-
Notifications
You must be signed in to change notification settings - Fork 540
Using multitool menus.
Multitool menus are menus on machinery for configuring certain settings, such as frequencies, IDs, and other stuff, as the name would suggest you need a multitool to open one.
One of the best examples of a multitool menu is telecomms machinery:
Other examples include :
- Atmospherics machinery
- Cycling airlocks
Procs with a '*' in front of them should be overriden.
NOTE: Don't ask me why but N3X15 placed half the code under /obj and the other half under /obj/machinery, objs only have the code for the basic UI, I don't even know why either.
These are the basic procs and code you're gonna need to setup the multitool menu:
Use this proc to open the multitool menu, while the name does imply also updating it, that's handled for you. The most common place to call this proc is in attackby;
/obj/machinery/yourmachine/attackby(var/obj/item/W as obj, var/mob/user as mob)
if(ismultitool(W))
update_multitool_menu(user)
return 1
Now, using this code as is will just open a blank multitool menu, let's see how to add some stuff to it:
Params:
- var/mob/user: The mob that's using this multitool menu.
- var/obj/item/device/multitool/P: The multitool this multitool menu was opened with.
Should return: Valid HTML markup, this should only be the content, other stuff is handled for you.
Example:
/obj/machinery/atmospherics/unary/vent_pump/multitool_menu(var/mob/user,var/obj/item/device/multitool/P)
return {"
<ul>
<li><b>Frequency:</b> <a href="?src=\ref[src];set_freq=-1">[format_frequency(frequency)] GHz</a> (<a href="?src=\ref[src];set_freq=[1439]">Reset</a>)</li>
<li>[format_tag("ID Tag","id_tag","set_id")]</li>
</ul>
"}
That's the basics of multitool menus down.
This proc will easily format href in relation to vars on the src object, currently it's only used with the 'set_tag' act, as such I will only refer to that.
'set_tag' is an easy way to set a var on the object to input from a user.
'set_id' is used instead by vents, but this is only because they have shit code and are snowflaky, don't use 'set_id'.
Due to HREF exploit reason, you need to make sure the var you're allowing the user to edit is in a special list, this list is at the beginning of machinery.dm
Params:
- var/label: What should be in front of the field containing the variable's data, for clarification for the user.
- var/varname: The name of the variable on the src that the user's input should be outputted to.
- var/act="set_tag": Only set_tag is used, this would determine the action that would happen with the var.
Returns: A preformatted HREF for use in, for example, multitool menus.
Example:
/obj/machinery/atmospherics/unary/vent_scrubber/multitool_menu(var/mob/user,var/obj/item/device/multitool/P)
return {"
<ul>
<li><b>Frequency:</b> <a href="?src=\ref[src];set_freq=-1">[format_frequency(frequency)] GHz</a> (<a href="?src=\ref[src];set_freq=[1439]">Reset</a>)</li>
<li>[format_tag("ID Tag","id_tag")]</li>
</ul>
"}
Will turn out this:
//TO BE CONTINUED WITH MOAR STUFF