WoW:API for: Difference between revisions

183 bytes removed ,  15 August 2023
m
Move page script moved page API for to WoW:API for without leaving a redirect
mNo edit summary
m (Move page script moved page API for to WoW:API for without leaving a redirect)
 
(4 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{Stub/API|Needs a proper home; we generally don't document Lua language constructs here.}}
Native Lua statement:
Native Lua statement:


Line 5: Line 6:
Executes 'statements' for each value of 'variable' from 'lowvalue' to 'highvalue', at a step value of 'step' inclusive.  Other syntax options yet unknown.
Executes 'statements' for each value of 'variable' from 'lowvalue' to 'highvalue', at a step value of 'step' inclusive.  Other syntax options yet unknown.


  for [key],[value] in [table] do [statements] end
  for [key],[value] in pairs([table]) do [statements] end


Executes 'statements' for each element of the 'table'. 'key' contains element key (index), 'value' contains element value.
Executes 'statements' for each element of the 'table'. 'key' contains element key (index), 'value' contains element value.
Line 31: Line 32:


  /script myTable = {"a","b","c","d"};
  /script myTable = {"a","b","c","d"};
  for k,v in myTable do
  for k,v in pairs(myTable) do
       DEFAULT_CHAT_FRAME:AddMessage("The value of index "..k.." is "..v);
       DEFAULT_CHAT_FRAME:AddMessage("The value of index "..k.." is "..v);
  end;
  end;
Line 40: Line 41:
  The value of index 3 is c
  The value of index 3 is c
  The value of index 4 is d
  The value of index 4 is d
[[User:Tigerheart|Tigerheart]] 03:34, 3 Nov 2005 (EST) - Added info on [step]
[[User:Tigerheart|Tigerheart]] 15:10, 7 Feb 2006 (EST) - Added "for, in" syntax
[[User:Drundia|Drundia]] 20:47, 3 July 2006 (EDT) - One missing qutes, fixed "for v,k in t" to correct "for k,v in t"
{{LUA}}
Anonymous user