lua:scripting
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| lua:scripting [2022/11/12 15:08] – [Loops] utedass | lua:scripting [2022/11/12 22:12] (current) – [Examples] utedass | ||
|---|---|---|---|
| Line 12: | Line 12: | ||
| ====== Lua in WoW ====== | ====== Lua in WoW ====== | ||
| + | * ''/ | ||
| * ''/ | * ''/ | ||
| * ''/ | * ''/ | ||
| + | * ''/ | ||
| + | * ''/ | ||
| + | * [[https:// | ||
| + | * [[https:// | ||
| + | * [[https:// | ||
| + | * [[https:// | ||
| ====== Cheat sheet ====== | ====== Cheat sheet ====== | ||
| + | ===== Conditions ===== | ||
| + | * < (less than) | ||
| + | * <= (less than or equals) | ||
| + | * > (greater than) | ||
| + | * >= (greater than or equals) | ||
| + | * == (equals) | ||
| + | * ~= (not equals) | ||
| + | * and | ||
| + | * or | ||
| + | * not | ||
| + | |||
| + | ===== Variables ===== | ||
| + | Type depending on assignment. String, number and boolean. | ||
| + | |||
| + | <code lua> | ||
| + | local a = "Yo man's dude" -- locally scoped | ||
| + | b = 432.12 -- global | ||
| + | </ | ||
| + | |||
| + | ===== Tables ===== | ||
| + | <code lua> | ||
| + | greetings = {} | ||
| + | greetings[" | ||
| + | greetings[" | ||
| + | greetings.Thalassian = " | ||
| + | </ | ||
| + | |||
| + | <code lua> | ||
| + | greetings = { | ||
| + | [" | ||
| + | [" | ||
| + | [" | ||
| + | } | ||
| + | |||
| + | for key, value in pairs(greetings) do | ||
| + | print(" | ||
| + | end | ||
| + | </ | ||
| + | |||
| + | <code lua> | ||
| + | number = 1 | ||
| + | potencies = {} | ||
| + | |||
| + | while(number < 4096) do | ||
| + | number = number * 2 | ||
| + | table.insert(potencies, | ||
| + | end | ||
| + | |||
| + | print(" | ||
| + | print(" | ||
| + | |||
| + | print(" | ||
| + | |||
| + | for i = 1, #potencies, 1 do | ||
| + | print(potencies[i]) | ||
| + | end | ||
| + | </ | ||
| ===== Loops ===== | ===== Loops ===== | ||
| Line 59: | Line 122: | ||
| </ | </ | ||
| + | ===== Examples ===== | ||
| + | |||
| + | <code lua> | ||
| + | -- Create a frame and register this frame to run code on an event. | ||
| + | local function PrintStuff() | ||
| + | print(" | ||
| + | end | ||
| + | |||
| + | local EventFrame = CreateFrame(" | ||
| + | EventFrame: | ||
| + | |||
| + | EventFrame: | ||
| + | if(event == " | ||
| + | C_Timer.After(1, | ||
| + | end | ||
| + | end) | ||
| + | </ | ||
lua/scripting.1668265709.txt.gz · Last modified: 2022/11/12 15:08 by utedass
