→Details: Explain how getfenv() works equally well
No edit summary |
(→Details: Explain how getfenv() works equally well) |
||
| Line 26: | Line 26: | ||
== Example == | == Example == | ||
script setglobal( "MyVariable", 1234 ); | |||
script setglobal( "MyVariable", 1234 ); | |||
=== Result === | |||
MyVariable = 1234 | MyVariable = 1234 | ||
== Details == | |||
: | As of the introduction of [[API getfenv|getfenv]]() into the API, setglobal() and [[API getglobal|getglobal]]() are somewhat superfluous. You can always do something along the lines of: | ||
local globalenv = getfenv(); | |||
local prevval = globalenv["MyVariable"]; ''-- "getglobal()"'' | |||
globalenv["MyVariable"] = 1234; ''-- "setglobal()"'' | |||