WoW:API setglobal: Difference between revisions

→‎Details: Explain how getfenv() works equally well
No edit summary
 
(→‎Details: Explain how getfenv() works equally well)
Line 26: Line 26:


== Example ==
== Example ==
<!-- If it helps, include an example here, though it's not required if the usage is self-explanatory -->
script setglobal( "MyVariable", 1234 );
script setglobal( "MyVariable", 1234 );


====Result====
=== Result ===
<!-- If it helps, include example results here, though they are not required. You're allowed to cheat liberally since WoW isn't a command line language. -->
  MyVariable = 1234
  MyVariable = 1234




<!--==Details==
== Details ==
Details not appropriate for the main description can go here.
    REMOVE the section if you're just going to restate the intro line!


: Does something particularly detailed. -->
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()"''
-[[User:Tigerheart|Tigerheart]] 21:42, 30 June 2006 (EDT)
  globalenv["MyVariable"] = 1234;            ''-- "setglobal()"''
Anonymous user