Hello, I was searching in my Lua book and I saw some functions that I don’t saw and use these functions. Are someone using these in real games (not testing)? The functions:
collectgarbage:
Used
Not used
0voters
getfenv:
Used
Not used
0voters
newproxy:
Used
Not used
0voters
setfenv:
Used
Not used
0voters
type over typeof:
Used
Not used
0voters
select:
Used
Not used
0voters
Some of these functions I know how to use them but I don’t know why someone would use them.
If you vote something, please say what you voted and why.
Some of these I don’t know what do, and some of them I just don’t find useful in my code. Type() is probably the one I use most, but other than that, I don’t use any of these
I used getfenv on my admin system, as I wanted to call the function with the name of the command that player typed. Soo I didnt had to do a if statement for every function I made.
i often don’t use newproxytoo much but it can be useful, to create userdata (which i don’t think there is a replacement for ) and for making unique values and such.
function Hi()
print("Hello!")
end
getfenv()[Message]() -- (Message is a string value that is "Hi") doing this will call the function that has the name of that string. Which is the function Hi.
collectgarbage - No real reason to use this. You cannot control the garbage collector in Roblox. If you want information on memory usage, there are other functions available for this.
getfenv/setfenv - There are actually a variety of uses for these functions. Off the top of my head, some include sandboxing, cheat detections, and well, environment manipulation. Not used much in game development, but for other purposes it can be quite useful.
newproxy - As others have stated, making your own objects. Off the top of my head, some other uses include locking modules/data and sandboxing purposes.
type over typeof - When I want to know if something is just a userdata (I have no care what kind). I’ve used this for serializing data.
select - Parameter counting. Argument manipulation. I don’t use this often.