Tips and Pointers for TGUI ui_act #19217
Sirryan2002
started this conversation in
Guides
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello everyone, this will be a short post. I just wanted to point out a few nuances about the TGUI
ui_act
proc that people may not be aware of.Act detection
When receiving acts from TGUI, for an object that only takes one act, you use a single if statement, and if you receive multiple acts from TGUI you use a switch statement.
single act
multi_act
Accessing the mob/user
Many ui_acts in the code rely on
usr
to perform actions involving the user or mob using the UI. However, TGUI already has references to the user that are very very accessible, you just need to know how to get it. Allui_act
s have adatum/tgui/ui
parameter as part of the proc. On this tgui datum there is a var calleduser
In order to just be able to use user in your ui_act, all you need to do is use this line of code
Fingerprint Management
Many machines use fingerprints as a way for the detective to forensically detect usage by other players. This means
add_fingerprint(user)
is required. Instead of using this at the end of every act switch statement you can for the most part avoid using it more than once in the proc.By setting the return value
.
you can actively track whether or not a fingerprint should be added.While this is a bit more code than just using
add_fingerprint()
in multiple places, when your ui_act proc gets more and more complext and lengthy, this method quickly becomes the most efficient and easy to use. In addition to simplifying this process, it also helps prevent redundant fingerprint additions.Beta Was this translation helpful? Give feedback.
All reactions