Difference between revisions of "(global)"
(language stuff) |
|||
(4 intermediate revisions by 2 users not shown) | |||
Line 9: | Line 9: | ||
=== Example === | === Example === | ||
'''Prints all current global variables:''' | '''Prints all current global variables:''' | ||
− | < | + | <syntaxhighlight lang="lua"> |
local function globalVariable() | local function globalVariable() | ||
for k,v in pairs(_G) do | for k,v in pairs(_G) do | ||
Line 17: | Line 17: | ||
globalVariable() | globalVariable() | ||
− | </ | + | </syntaxhighlight> |
{|- | {|- | ||
Line 24: | Line 24: | ||
[[assert]] ''error if v nil or false, otherwise returns v''<br/><!--GIDEROSMTD:assert(v,message) error if v nil or false, otherwise returns v--> | [[assert]] ''error if v nil or false, otherwise returns v''<br/><!--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--> | [[collectgarbage]] ''opts: stop, restart, collect, count, step, setpause, setstepmul''<br/><!--GIDEROSMTD:collectgarbage(opt,arg) opts: stop, restart, collect, count, step, setpause, setstepmul--> | ||
+ | [[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--> | ||
[[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--> | ||
Line 39: | Line 40: | ||
[[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--> | ||
+ | [[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--> | ||
[[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--> | ||
Line 45: | Line 47: | ||
[[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--> | ||
[[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 02:39, 8 November 2024
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()
Methodsassert error if v nil or false, otherwise returns v |
EventsConstants |