m
Move page script moved page API for to WoW:API for without leaving a redirect
(Added "for, in" syntax) |
m (Move page script moved page API for to WoW:API for without leaving a redirect) |
||
| (6 intermediate revisions by 6 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: | |||
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. | ||
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. | ||
---- | ---- | ||
Examples: | Examples: | ||
| Line 17: | Line 17: | ||
/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 32: | Line 32: | ||
/script myTable = {"a","b","c","d"}; | /script myTable = {"a","b","c","d"}; | ||
for | for k,v in pairs(myTable) do | ||
DEFAULT_CHAT_FRAME:AddMessage("The value of index ".. | DEFAULT_CHAT_FRAME:AddMessage("The value of index "..k.." is "..v); | ||
end; | end; | ||
| Line 41: | 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 | ||