Function Dump/Roblox Specific Functions: Difference between revisions
>Legend26 code and output and ` template |
>Legend26 code and output and ` template |
(No difference)
|
Revision as of 23:07, 27 January 2012
Unlocked Functions
These functions, methods and otherwise were added to Lua by the developers to make scripting easier and more powerful. These may include functions for specific objects, such as Vector3 or CFrame classes. They are listed here as well as on the Scripting page for easier reference.
Delay(Float t, Function f) or delay(Float t, Function f)
Executes function "f" after "t" seconds have elapse. The function "f" is called with 2 arguments: The elapsed time and the current game time.
LoadLibrary(String libraryName)
Returns a library, 'libraryName' if it exists. Else, it returns nil and an error message for use with the assert function. LoadLibrary can be used by anyone.
printidentity(v, ···)
Echos the security level of the current thread, and the last argument passed in, if supplied.
Spawn(Function f)
Executes function "f" after thread next yields. The function "f" is called with 2 arguments: The elapsed time and the current game time.
tick()
Returns the time in UNIX time, which is the number of seconds since the Unix epoch, January 1st, 1970. This time advances without game running, network synchronization, or wait(). Using tick() in a LocalScript may result in a differrent number that if you were to use it in a Script, which will fetch a user's computer time. tick() is very accurate. Because of its high accuracy, it can be used to measure the time a certain function takes to execute by calling it before and after an operation has been done, then finding the difference.
print( math.floor( tick() / (60 * 60 * 24) ) )
Results in how many days have passed since January 1, 1970.
More information on tick can be found here
time()
Returns returns the current game time in seconds. Game time only updates during wait() and must be synchronized across network.
Start your place and let it run for a little while. In the Command Line type:
print(time())
Will result in some number, indicating how many seconds the game has been running for.
version() or Version()
Returns Roblox's current version.
print(version())
Will result in a string that represents the current version of your roblox client. Formatted as x.x.x.x
Wait(Float t) or wait(Float t)
Yields the current thread until "t" seconds have elapsed. If t is not specified, then it yields for a very short period of time (usually close to 1/30th of a second). The function returns 2 values: The elapsed time and the current game time.
Locked Functions
These are functions that are used by the game to protect it, its clients, and its clients' computers. Using them will cause the error 'Unknown exception' unless you are using the Command Bar or a CoreScript which have higher security levels than normal or local scripts.
PluginManager()
Returns the PluginManager object that plugins can use to create a Plugin object.
crash__()
Crashes the game. This is used by the game when it can no longer function correctly. You can run it in your Command Bar but make sure you save your work prior to that.
crash__() --> crashes the gameIf using a Script or LocalScript...
crash__() --> Unknown exception
LoadRobloxLibrary(String libraryName)
Returns a developer library, 'libraryName' if it exists. Else, it returns nil and an error message for use with the assert function. LoadRobloxLibrary is restricted for Roblox developers only.
settings()
Returns the Client's Global Settings object. The Global Settings this returns are the exact same as the settings you see when you go to Tools > Settings.
If you're using the Command Bar or a CoreScript...
print( settings() ) --> Global Settings
If you're using a Script or a LocalScript...
print( settings() ) --> Unknown exception
Stats() or stats()
Returns the Client's Stats object. The Stats it returns are the ones you see on you screen when you press Ctrl+F1 or Ctrl+F2 in a game.
print( stats() ) --> Stats print( stats() == game.Stats ) --> trueIf you're using a Script or a LocalScript...
print( stats() ) --> Unknown exception print( stats() == game.Stats ) --> Unknown exception
UserSettings()
Returns the Client's GlobalBasicSettings object. The GlobalSettings this returns are edited when you use the Control Editor to change your controls.
print( UserSettings().className == "GlobalBasicSettings" ) --> trueIf you're using a Script or a LocalScript...
print( UserSettings().className == "GlobalBasicSettings" ) --> Unknown exception