Difference between revisions of "(global)"

From GiderosMobile
m
 
(13 intermediate revisions by 2 users 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]][[File:Platform linux.png]]<br/>
 +
'''Available since:''' Gideros 2011.6<br/>
  
'''<translate>Supported platforms</translate>:''' [[File:Platform android.png]][[File:Platform ios.png]][[File:Platform mac.png]][[File:Platform pc.png]]<br/>
+
=== Description ===
'''<translate>Available since</translate>:''' Gideros 2011.6<br/>
 
 
 
=== <translate>Description</translate> ===
 
 
Global scope of Lua environment.
 
Global scope of Lua environment.
  
=== <translate>Example</translate> ===
+
=== Example ===
 
'''Prints all current global variables:'''
 
'''Prints all current global variables:'''
<source lang="lua">
+
<syntaxhighlight lang="lua">
 
local function globalVariable()
 
local function globalVariable()
 
for k,v in pairs(_G) do
 
for k,v in pairs(_G) do
Line 19: Line 17:
 
   
 
   
 
globalVariable()
 
globalVariable()
</source>
+
</syntaxhighlight>
 +
 
 +
=== Reference ===
 +
https://github.com/gideros/luau/blob/master/VM/src/lbaselib.cpp</br>
 +
https://create.roblox.com/docs/reference/engine/globals/LuaGlobals
 +
 
 
{|-
 
{|-
 
| style="width: 50%; vertical-align:top;"|
 
| style="width: 50%; vertical-align:top;"|
=== <translate>Methods</translate> ===
+
=== Methods ===
[[Special:MyLanguage/assert|assert]] ''<translate>error if v nil or false, otherwise returns v</translate>''<br/>
+
[[assert]] ''error if v nil or false, otherwise returns v''<br/><!--GIDEROSMTD:assert(v,message) error if v nil or false, otherwise returns v-->
<!-- GIDEROSMTD:assert(v,message) error if v nil or false, otherwise returns v -->
+
[[collectgarbage]] ''opts: stop, restart, collect, count, step, setpause, setstepmul''<br/><!--GIDEROSMTD:collectgarbage(opt,arg) opts: stop, restart, collect, count, step, setpause, setstepmul-->
[[Special:MyLanguage/collectgarbage|collectgarbage]] ''<translate>opts: stop, restart, collect, count, step, setpause, setstepmul</translate>''<br/>
+
[[ColorValue]] ''sets a Color the r,g,b,a channel values''<br/><!--GIDEROSMTD:ColorValue(r,g,b,a) sets a Color the r,g,b,a channel values-->
<!-- GIDEROSMTD:collectgarbage(opt,arg) opts: stop, restart, collect, count, step, setpause, setstepmul -->
+
[[dofile]] ''executes as Lua chunk, default stdin, returns value''<br/><!--GIDEROSMTD:dofile(filename) executes as Lua chunk, default stdin, returns value-->
[[Special:MyLanguage/dofile|dofile]] ''<translate>executes as Lua chunk, default stdin, returns value</translate>''<br/>
+
[[error]] ''terminates protected func, never returns''<br/><!--GIDEROSMTD:error(message,level) terminates protected func, never returns-->
<!-- GIDEROSMTD:dofile(filename) executes as Lua chunk, default stdin, returns value -->
+
[[gcinfo]] ''returns the total memory heap size in kilobytes''<br/><!--GIDEROSMTD:gcinfo() returns the total memory heap size in kilobytes-->
[[Special:MyLanguage/error|error]] ''<translate>terminates protected func, never returns</translate>''<br/>
+
[[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)-->
<!-- GIDEROSMTD:error(message,level) terminates protected func, never returns -->
+
[[getmetatable]] ''returns metatable of given object, otherwise nil''<br/><!--GIDEROSMTD:getmetatable(object) returns metatable of given object, otherwise nil-->
[[Special:MyLanguage/getfenv|getfenv]] ''<translate>gets env, f can be a function or number(stack level)</translate>''<br/>
+
[[ipairs]] ''returns an iterator function, table t and 0''<br/><!--GIDEROSMTD:ipairs(t) returns an iterator function, table t and 0-->
<!-- GIDEROSMTD:getfenv(f) gets env, f can be a function or number(stack level) -->
+
[[loadfile]] ''loads chunk without execution, returns chunk as function, else nil plus error''<br/><!--GIDEROSMTD:loadfile(filename) loads chunk without execution, returns chunk as function, else nil plus error-->
[[Special:MyLanguage/getmetatable|getmetatable]] ''<translate>returns metatable of given object, otherwise nil</translate>''<br/>
+
[[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-->
<!-- GIDEROSMTD:getmetatable(object) returns metatable of given object, otherwise nil -->
+
[[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-->
[[Special:MyLanguage/ipairs|ipairs]] ''<translate>returns an iterator function, table t and 0</translate>''<br/>
+
[[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-->
<!-- GIDEROSMTD:ipairs(t) returns an iterator function, table t and 0 -->
+
[[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-->
[[Special:MyLanguage/loadfile|loadfile]] ''<translate>loads chunk without execution, returns chunk as function, else nil plus error</translate>''<br/>
+
[[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-->
<!-- GIDEROSMTD:loadfile(filename) loads chunk without execution, returns chunk as function, else nil plus error -->
+
[[print]] ''prints values to stdout using tostring''<br/><!--GIDEROSMTD:print(e1,e2,...) prints values to stdout using tostring-->
[[Special:MyLanguage/loadstring|loadstring]] ''<translate>loads string as chunk, returns chunk as function, else nil plus error</translate>''<br/>
+
[[rawequal]] ''non-metamethod v1==v2, returns boolean''<br/><!--GIDEROSMTD:rawequal(v1,v2) non-metamethod v1==v2, returns boolean-->
<!-- GIDEROSMTD:loadstring(string,chunkname) loads string as chunk, returns chunk as function, else nil plus error -->
+
[[rawget]] ''non-metamethod get value of table[index], index != nil''<br/><!--GIDEROSMTD:rawget(table,key) non-metamethod get value of table[index], index != nil-->
[[Special:MyLanguage/next|next]] ''<translate>returns next index,value pair, if index=nil(default-, returns first index</translate>''<br/>
+
[[rawiter]] ''non-metamethod table iteration''<br/><!--GIDEROSMTD:rawiter(table,key) non-metamethod table iteration-->
<!-- GIDEROSMTD:next(table,index) returns next index,value pair, if index=nil(default-, returns first index -->
+
[[rawlen]] ''non-metamethod length of the string or table''<br/><!--GIDEROSMTD:rawlen(table) non-metamethod length of the string or table-->
[[Special:MyLanguage/pairs|pairs]] ''<translate>returns the next function and table t plus a nil, iterates over all key-value pairs</translate>''<br/>
+
[[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-->
<!-- GIDEROSMTD:pairs(t) returns the next function and table t plus a nil, iterates over all key-value pairs -->
+
[[require]] ''loads package, updates _LOADED, returns boolean''<br/><!--GIDEROSMTD:require(packagename) loads package, updates _LOADED, returns boolean-->
[[Special:MyLanguage/pcall|pcall]] ''<translate>protected mode call, catches errors, returns status code first</translate>''<br/>
+
[[select]] ''returns items in a list or number of items in a list''<br/><!--GIDEROSMTD:select(index,...) returns items in a list or number of items in a list-->
<!-- GIDEROSMTD:pcall(f,arg1,arg2,...) protected mode call, catches errors, returns status code first -->
+
[[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-->
[[Special:MyLanguage/print|print]] ''<translate>prints values to stdout using tostring</translate>''<br/>
+
[[setmetatable]] ''sets metatable, nil to remove metatable''<br/><!--GIDEROSMTD:setmetatable(table,metatable) sets metatable, nil to remove metatable-->
<!-- GIDEROSMTD:print(e1,e2,...) prints values to stdout using tostring -->
+
[[setsafeenv]] ''sets a safe env''<br/><!--GIDEROSMTD:setsafeenv(flags) sets a safe env-->
[[Special:MyLanguage/rawequal|rawequal]] ''<translate>non-metamethod v1==v2, returns boolean</translate>''<br/>
+
[[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-->
<!-- GIDEROSMTD:rawequal(v1,v2) non-metamethod v1==v2, returns boolean -->
+
[[tostring]] ''convert to string, returns string''<br/><!--GIDEROSMTD:tostring(e) convert to string, returns string-->
[[Special:MyLanguage/rawget|rawget]] ''<translate>non-metamethod get value of table[index], index != nil</translate>''<br/>
+
[[type]] ''returns type of v as a string''<br/><!--GIDEROSMTD:type(v) returns type of v as a string-->
<!-- GIDEROSMTD:rawget(table,key) non-metamethod get value of table[index], index != nil -->
+
[[typeof]] ''returns type of v as a string''<br/><!--GIDEROSMTD:typeof(v) returns type of v as a string-->
[[Special:MyLanguage/rawset|rawset]] ''<translate>non-metamethod set value of table[index], index != nil</translate>''<br/>
+
[[unpack]] ''returns all elements from list''<br/><!--GIDEROSMTD:unpack(list) returns all elements from list-->
<!-- GIDEROSMTD:rawset(table,key,value) non-metamethod set value of table[index], index != nil -->
+
[[vector]] ''vector with up to 3 values''<br/><!--GIDEROSMTD:vector(x,y[,z]) vector with up to 3 values-->
[[Special:MyLanguage/require|require]] ''<translate>loads package, updates _LOADED, returns boolean</translate>''<br/>
+
[[xpcall]] ''pcall function f with new error handler err''<br/><!--GIDEROSMTD:xpcall(f,err) pcall function f with new error handler err-->
<!-- GIDEROSMTD:require(packagename) loads package, updates _LOADED, returns boolean -->
 
[[Special:MyLanguage/setfenv|setfenv]] ''<translate>sets env, f can be a function or number(stack level, default=1-, 0=global env</translate>''<br/>
 
<!-- GIDEROSMTD:setfenv(f,table) sets env, f can be a function or number(stack level, default=1-, 0=global env -->
 
[[Special:MyLanguage/setmetatable|setmetatable]] ''<translate>sets metatable, nil to remove metatable</translate>''<br/>
 
<!-- GIDEROSMTD:setmetatable(table,metatable) sets metatable, nil to remove metatable -->
 
[[Special:MyLanguage/tonumber|tonumber]] ''<translate>convert to number, returns number, nil if non-convertible, 2<=base<=36</translate>''<br/>
 
<!-- GIDEROSMTD:tonumber(e,base) convert to number, returns number, nil if non-convertible, 2<=base<=36 -->
 
[[Special:MyLanguage/tostring|tostring]] ''<translate>convert to string, returns string</translate>''<br/>
 
<!-- GIDEROSMTD:tostring(e) convert to string, returns string -->
 
[[Special:MyLanguage/type|type]] ''<translate>returns type of v as a string</translate>''<br/>
 
<!-- GIDEROSMTD:type(v) returns type of v as a string -->
 
[[Special:MyLanguage/unpack|unpack]] ''<translate>returns all elements from list</translate>''<br/>
 
<!-- GIDEROSMTD:unpack(list) returns all elements from list -->
 
[[Special:MyLanguage/xpcall|xpcall]] ''<translate>pcall function f with new error handler err</translate>''<br/>
 
<!-- GIDEROSMTD:xpcall(f,err) pcall function f with new error handler err -->
 
  
 
| style="width: 50%; vertical-align:top;"|
 
| style="width: 50%; vertical-align:top;"|
=== <translate>Events</translate> ===
+
=== Events ===
=== <translate>Constants</translate> ===
+
=== Constants ===
[[Special:MyLanguage/_G|_G]]<br/><!-- GIDEROSCST:_G -->
+
[[_G]]<br/><!--GIDEROSCST:_G-->
[[Special:MyLanguage/_VERSION|_VERSION]]<br/><!-- GIDEROSCST:_VERSION Lua 5.1.x-->
+
[[_VERSION]]<br/><!--GIDEROSCST:_VERSION Lua 5.x.x-->
 
|}
 
|}
  
 
{{GIDEROS IMPORTANT LINKS}}
 
{{GIDEROS IMPORTANT LINKS}}

Latest revision as of 18:43, 21 February 2025

Supported platforms: Platform android.pngPlatform ios.pngPlatform mac.pngPlatform pc.pngPlatform linux.png
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://github.com/gideros/luau/blob/master/VM/src/lbaselib.cpp
https://create.roblox.com/docs/reference/engine/globals/LuaGlobals

Methods

assert error if v nil or false, otherwise returns v
collectgarbage opts: stop, restart, collect, count, step, setpause, setstepmul
ColorValue sets a Color the r,g,b,a channel values
dofile executes as Lua chunk, default stdin, returns value
error terminates protected func, never returns
gcinfo returns the total memory heap size in kilobytes
getfenv gets env, f can be a function or number(stack level)
getmetatable returns metatable of given object, otherwise nil
ipairs returns an iterator function, table t and 0
loadfile loads chunk without execution, returns chunk as function, else nil plus error
loadstring 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
newproxy 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
pcall protected mode call, catches errors, returns status code first
print prints values to stdout using tostring
rawequal non-metamethod v1==v2, returns boolean
rawget non-metamethod get value of table[index], index != nil
rawiter non-metamethod table iteration
rawlen non-metamethod length of the string or table
rawset non-metamethod set value of table[index], index != nil
require loads package, updates _LOADED, returns boolean
select returns items in a list or number of items in a list
setfenv sets env, f can be a function or number(stack level, default=1-, 0=global env
setmetatable sets metatable, nil to remove metatable
setsafeenv sets a safe env
tonumber convert to number, returns number, nil if non-convertible, 2<=base<=36
tostring convert to string, returns string
type returns type of v as a string
typeof returns type of v as a string
unpack returns all elements from list
vector vector with up to 3 values
xpcall pcall function f with new error handler err

Events

Constants

_G
_VERSION