WoW:API for: Difference between revisions

153 bytes added ,  4 July 2006
m
no edit summary
(Change category from "LUA Functions" to "Lua functions".)
mNo edit summary
Line 1: Line 1:
Native Lua statement:
Native Lua statement:


  for <variable> = <lowvalue>, <highvalue>,<step> do <statements>; end
  for [variable] = [lowvalue], [highvalue],[step] do [statements] end


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 <variable>,<integer> in <array> do <statements>;end'''
for [key],[value] in [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 'variable' with index 'integer' in 'array'.
----
----
Examples:
Examples:
Line 15: Line 16:
   /script for i=1,5 do
   /script for i=1,5 do
     name,description,standingID,barValue,atWarWith,canToggleAtWar,isHeader,isCollapsed=GetFactionInfo(i);
     name,description,standingID,barValue,atWarWith,canToggleAtWar,isHeader,isCollapsed=GetFactionInfo(i);
     DEFAULT_CHAT_FRAME:AddMessage(format("%s %d/%d,name,barValue*21000,21000));
     DEFAULT_CHAT_FRAME:AddMessage(format("%s %d/%d",name,barValue*21000,21000));
   end
   end


Line 30: Line 31:


  /script myTable = {"a","b","c","d"};
  /script myTable = {"a","b","c","d"};
  for var,i in myTable do
  for k,v in myTable do
       DEFAULT_CHAT_FRAME:AddMessage("The value of index "..i.." is "..var);
       DEFAULT_CHAT_FRAME:AddMessage("The value of index "..k.." is "..v);
  end;
  end;


Line 41: Line 42:




[[User:Tigerheart|Tigerheart]] 03:34, 3 Nov 2005 (EST) - Added info on <step>
[[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: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}}
{{LUA}}
Anonymous user