Difference between revisions of "(global)"
| (9 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
__NOTOC__  | __NOTOC__  | ||
<!-- GIDEROSOBJ:(global) -->  | <!-- GIDEROSOBJ:(global) -->  | ||
| − | '''Supported platforms:''' [[File:Platform android.png]][[File:Platform ios.png]][[File:Platform mac.png]][[File:Platform pc.png]]<br/>  | + | '''Supported platforms:''' [[File:Platform android.png]][[File:Platform ios.png]][[File:Platform mac.png]][[File:Platform pc.png]][[File:Platform linux.png]]<br/>  | 
'''Available since:''' Gideros 2011.6<br/>  | '''Available since:''' Gideros 2011.6<br/>  | ||
| Line 18: | Line 18: | ||
globalVariable()  | globalVariable()  | ||
</syntaxhighlight>  | </syntaxhighlight>  | ||
| + | |||
| + | === Reference ===  | ||
| + | '''https://luau.org/library#global-functions'''<br/>  | ||
| + | '''https://github.com/gideros/luau/blob/master/VM/src/lbaselib.cpp'''</br>  | ||
| + | '''https://create.roblox.com/docs/reference/engine/globals/LuaGlobals'''  | ||
{|-  | {|-  | ||
| Line 27: | Line 32: | ||
[[dofile]] ''executes as Lua chunk, default stdin, returns value''<br/><!--GIDEROSMTD:dofile(filename) executes as Lua chunk, default stdin, returns value-->  | [[dofile]] ''executes as Lua chunk, default stdin, returns value''<br/><!--GIDEROSMTD:dofile(filename) executes as Lua chunk, default stdin, returns value-->  | ||
[[error]] ''terminates protected func, never returns''<br/><!--GIDEROSMTD:error(message,level) terminates protected func, never returns-->  | [[error]] ''terminates protected func, never returns''<br/><!--GIDEROSMTD:error(message,level) terminates protected func, never returns-->  | ||
| + | [[gcinfo]] ''returns the total memory heap size in kilobytes''<br/><!--GIDEROSMTD:gcinfo() returns the total memory heap size in kilobytes-->  | ||
[[getfenv]] ''gets env, f can be a function or number(stack level)''<br/><!--GIDEROSMTD:getfenv(f) gets env, f can be a function or number(stack level)-->  | [[getfenv]] ''gets env, f can be a function or number(stack level)''<br/><!--GIDEROSMTD:getfenv(f) gets env, f can be a function or number(stack level)-->  | ||
[[getmetatable]] ''returns metatable of given object, otherwise nil''<br/><!--GIDEROSMTD:getmetatable(object) returns metatable of given object, otherwise nil-->  | [[getmetatable]] ''returns metatable of given object, otherwise nil''<br/><!--GIDEROSMTD:getmetatable(object) returns metatable of given object, otherwise nil-->  | ||
| Line 33: | Line 39: | ||
[[loadstring]] ''loads string as chunk, returns chunk as function, else nil plus error''<br/><!--GIDEROSMTD:loadstring(string,chunkname) loads string as chunk, returns chunk as function, else nil plus error-->  | [[loadstring]] ''loads string as chunk, returns chunk as function, else nil plus error''<br/><!--GIDEROSMTD:loadstring(string,chunkname) loads string as chunk, returns chunk as function, else nil plus error-->  | ||
[[next]] ''returns next index,value pair, if index=nil(default-, returns first index''<br/><!--GIDEROSMTD:next(table,index) returns next index,value pair, if index=nil(default-, returns first index-->  | [[next]] ''returns next index,value pair, if index=nil(default-, returns first index''<br/><!--GIDEROSMTD:next(table,index) returns next index,value pair, if index=nil(default-, returns first index-->  | ||
| + | [[newproxy]] ''creates a blank userdata, with the option for it to have a metatable''<br/><!--GIDEROSMTD:newproxy(addMetatable) creates a blank userdata, with the option for it to have a metatable-->  | ||
[[pairs]] ''returns the next function and table t plus a nil, iterates over all key-value pairs''<br/><!--GIDEROSMTD:pairs(t) returns the next function and table t plus a nil, iterates over all key-value pairs-->  | [[pairs]] ''returns the next function and table t plus a nil, iterates over all key-value pairs''<br/><!--GIDEROSMTD:pairs(t) returns the next function and table t plus a nil, iterates over all key-value pairs-->  | ||
[[pcall]] ''protected mode call, catches errors, returns status code first''<br/><!--GIDEROSMTD:pcall(f,arg1,arg2,...) protected mode call, catches errors, returns status code first-->  | [[pcall]] ''protected mode call, catches errors, returns status code first''<br/><!--GIDEROSMTD:pcall(f,arg1,arg2,...) protected mode call, catches errors, returns status code first-->  | ||
| Line 38: | Line 45: | ||
[[rawequal]] ''non-metamethod v1==v2, returns boolean''<br/><!--GIDEROSMTD:rawequal(v1,v2) non-metamethod v1==v2, returns boolean-->  | [[rawequal]] ''non-metamethod v1==v2, returns boolean''<br/><!--GIDEROSMTD:rawequal(v1,v2) non-metamethod v1==v2, returns boolean-->  | ||
[[rawget]] ''non-metamethod get value of table[index], index != nil''<br/><!--GIDEROSMTD:rawget(table,key) non-metamethod get value of table[index], index != nil-->  | [[rawget]] ''non-metamethod get value of table[index], index != nil''<br/><!--GIDEROSMTD:rawget(table,key) non-metamethod get value of table[index], index != nil-->  | ||
| + | [[rawiter]] ''non-metamethod table iteration''<br/><!--GIDEROSMTD:rawiter(table,key) non-metamethod table iteration-->  | ||
| + | [[rawlen]] ''non-metamethod length of the string or table''<br/><!--GIDEROSMTD:rawlen(table) non-metamethod length of the string or table-->  | ||
[[rawset]] ''non-metamethod set value of table[index], index != nil''<br/><!--GIDEROSMTD:rawset(table,key,value) non-metamethod set value of table[index], index != nil-->  | [[rawset]] ''non-metamethod set value of table[index], index != nil''<br/><!--GIDEROSMTD:rawset(table,key,value) non-metamethod set value of table[index], index != nil-->  | ||
[[require]] ''loads package, updates _LOADED, returns boolean''<br/><!--GIDEROSMTD:require(packagename) loads package, updates _LOADED, returns boolean-->  | [[require]] ''loads package, updates _LOADED, returns boolean''<br/><!--GIDEROSMTD:require(packagename) loads package, updates _LOADED, returns boolean-->  | ||
| Line 43: | Line 52: | ||
[[setfenv]] ''sets env, f can be a function or number(stack level, default=1-, 0=global env''<br/><!--GIDEROSMTD:setfenv(f,table) sets env, f can be a function or number(stack level, default=1-, 0=global env-->  | [[setfenv]] ''sets env, f can be a function or number(stack level, default=1-, 0=global env''<br/><!--GIDEROSMTD:setfenv(f,table) sets env, f can be a function or number(stack level, default=1-, 0=global env-->  | ||
[[setmetatable]] ''sets metatable, nil to remove metatable''<br/><!--GIDEROSMTD:setmetatable(table,metatable) sets metatable, nil to remove metatable-->  | [[setmetatable]] ''sets metatable, nil to remove metatable''<br/><!--GIDEROSMTD:setmetatable(table,metatable) sets metatable, nil to remove metatable-->  | ||
| + | [[setsafeenv]] ''sets a safe env''<br/><!--GIDEROSMTD:setsafeenv(flags) sets a safe env-->  | ||
[[tonumber]] ''convert to number, returns number, nil if non-convertible, 2<=base<=36''<br/><!--GIDEROSMTD:tonumber(e,base) convert to number, returns number, nil if non-convertible, 2<=base<=36-->  | [[tonumber]] ''convert to number, returns number, nil if non-convertible, 2<=base<=36''<br/><!--GIDEROSMTD:tonumber(e,base) convert to number, returns number, nil if non-convertible, 2<=base<=36-->  | ||
[[tostring]] ''convert to string, returns string''<br/><!--GIDEROSMTD:tostring(e) convert to string, returns string-->  | [[tostring]] ''convert to string, returns string''<br/><!--GIDEROSMTD:tostring(e) convert to string, returns string-->  | ||
[[type]] ''returns type of v as a string''<br/><!--GIDEROSMTD:type(v) returns type of v as a string-->  | [[type]] ''returns type of v as a string''<br/><!--GIDEROSMTD:type(v) returns type of v as a string-->  | ||
| + | [[typeof]] ''returns type of v as a string''<br/><!--GIDEROSMTD:typeof(v) returns type of v as a string-->  | ||
[[unpack]] ''returns all elements from list''<br/><!--GIDEROSMTD:unpack(list) returns all elements from list-->  | [[unpack]] ''returns all elements from list''<br/><!--GIDEROSMTD:unpack(list) returns all elements from list-->  | ||
| + | [[vector]] ''vector with up to 3 values''<br/><!--GIDEROSMTD:vector(x,y[,z]) vector with up to 3 values-->  | ||
[[xpcall]] ''pcall function f with new error handler err''<br/><!--GIDEROSMTD:xpcall(f,err) pcall function f with new error handler err-->  | [[xpcall]] ''pcall function f with new error handler err''<br/><!--GIDEROSMTD:xpcall(f,err) pcall function f with new error handler err-->  | ||
Latest revision as of 11:18, 21 July 2025
Supported platforms: ![]()
![]()
![]()
![]()
![]()
Available since: Gideros 2011.6
Description
Global scope of Lua environment.
Example
Prints all current global variables:
local function globalVariable()
	for k,v in pairs(_G) do
		print(k,v)
	end
end
 
globalVariable()
Reference
https://luau.org/library#global-functions
https://github.com/gideros/luau/blob/master/VM/src/lbaselib.cpp
https://create.roblox.com/docs/reference/engine/globals/LuaGlobals
Methodsassert error if v nil or false, otherwise returns v  | 
EventsConstants |