Global Functions
Last updated
Last updated
Global functions are built-in functions which do not belong to any kind of library. The most famous example is print()
, which is a global function that outputs anything entered into it.
Global function names are hardcoded in Powerlang's compiler, therefore it is impossible to overwrite them from within a script. (For example, you can define a custom function called print
, however you will not be able to call it, as the compiler will always use the built-in function)
Below is a table containing all global functions.
Name | Description |
---|---|
print(value: any)
Prints a value to the output.
warn(value: any)
Print but it's orange. Used for warnings.
tonumber(value: string) -> number?
Attempts to convert a string to a number, returns nil if not possible.
tostring(value: any) -> string
Converts a non-string value to a string representation. If value
is a string, no operations are done and the same string is returned.
typeof(value: any) -> string
Returns the type of the value passed. For example, if value
is a string, then the return will be string
.
tick() -> number
Returns the amount of seconds elapsed since the Epoch (January 1st, 1970 at 12:00 AM). Better known as epoch time or UNIX time.
wait(time: number)
Waits for a specified amount of seconds. Does not return anything.
spawn(function: Function)
Launches a function on a separate thread without waiting for it to finish. The function
must be a variable name, for example spawn(myFunction)