2.1. Lua 및 ¶
WOW Lua Ruby 립 를 는 .
Programming in Lua는 빌. 마 빌 1 됬.
Lua 는데 .
Lua-Eclipse를 받 . (LunarEclipse는 )
5.1.4-35 2010-04-07 13:09
LuaForWindows_v5.1.4-35.exe
LuaForWindows_v5.1.4-35.exe
. .
를 따 Eclipse Profiler말 Interpreter lua.exe path를 면 Eclipse Project를 만뒤 는 Lua 볼 .
2.2. 바 빼 ¶
WOW 를 만들 문.
빼 .
봤더 UTF-8방 빼 .
데 데 UNICODE 빼더만.
: 보 UNICODE를 는 방 . 데 더 모르는데... U-00000800 - U-0000FFFF 범 들 는데??
모르!! 링를 본.
: 보 UNICODE를 는 방 . 데 더 모르는데... U-00000800 - U-0000FFFF 범 들 는데??
모르!! 링를 본.
바 는 .
/////////////////////////////////////////////
package utfencoding;
/////////////////////////////////////////////
package utfencoding;
public class UtfEncoding {
final static char[] first = {
final static char[] middle = {
final static char[] last = {
/**
}'','','','','','','ㅁ','ㅂ','ㅃ','ㅅ','ㅆ','o','ㅈ','ㅉ','ㅊ','','ㅌ','ㅍ','ㅎ'
};final static char[] middle = {
'ㅏ','ㅐ','','ㅒ','ㅓ','ㅔ','','ㅖ','ㅗ','','','ㅛ','ㅙ','ㅚ','','','ㅞ','ㅟ','ㅡ','ㅢ','ㅣ'
};final static char[] last = {
'\0','','','','','','','','','','','','','','ㅀ','ㅁ','ㅂ','','ㅅ','ㅆ','o','ㅈ','ㅊ','','ㅌ','ㅍ','ㅎ'
}; /**
- @param args
- /
////////////////////////////////////////
보면 만 바 는 UNICoDE(마?)
Eclipse 문 Encoding UTF-8방.
빼 UTF-8 따 0xACC00 (<- UTF-8시작) 을 빼고 초성 중성 종성을 다음으로 빼온다
빼 UTF-8 따 0xACC00 (<- UTF-8시작) 을 빼고 초성 중성 종성을 다음으로 빼온다
= (문 /21 /28)
= ( (문%(21*28))/28)
= ( a%28)
= ( (문%(21*28))/28)
= ( a%28)
문 따 빼.
를 보면 .
를 보면 .
2.3. Addon 만들 ¶
리 Hello World!부는 따
떻 동는를 보.
떻 동는를 보.
본 램 보를 는 *.toc.
리 UI LUA를 Mapping 는 *.xml
리 는 *.lua
리 UI LUA를 Mapping 는 *.xml
리 는 *.lua
보
본 "/World of Warcraft/interface/addons/명" 더 만들.
Interface는 보 들.
http://www.wowwiki.com/Getting_the_current_interface_number
보를 볼 .
내 는 4.2 40200 보를 놓면 '' 대 .
http://www.wowwiki.com/Getting_the_current_interface_number
보를 볼 .
내 는 4.2 40200 보를 놓면 '' 대 .
Title 대
노는 냥 명
Author .
노는 냥 명
Author .
HelloWoW.xml
<UI xmlns="http://www.blizzard.com/wow/ui" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui">
<script file="HelloWoW.lua"/>
<Frame name="HelloWoWFrame">
<Scripts>
</Frame>
</UI>
<script file="HelloWoW.lua"/>
<Frame name="HelloWoWFrame">
<Scripts>
</Frame>
</UI>
HelloWoW.lua
면 Hello WOW! .
2.4. WOW API를 불러! ¶
WOW는 WOW API를 는 wiki를 API를 보면 들 .
http://www.wowwiki.com/World_of_Warcraft_API
Widget LuaFunction 보를 볼 .
http://www.wowwiki.com/World_of_Warcraft_API
Widget LuaFunction 보를 볼 .
본 DB를 . 데 WOW 만 7만 는. 는 index . 뭥미. 마 suffix문 . suffix란 부 붙 item index 부르는 말데 따 index 는 더. ( 는 모른)
리 리를 번 는 는 랍, 블루 ID 보 놓 더만.. 보 놀랐.
보 면 50760 .
4.2 는 불 데 .
4.2 는 불 데 .
번 를 면 보 들는 동 . DB를 WOW 리 는 데 . Addon 빼는 만 는 블루 랍럼 보놓 Addon 돌보는 .
WOW addon 대 모르는 . WOW 는 몇몇 료 . . Item 뭔 부보 많 붙!! 대는 번 루보.
HelloWoW를 만 번 보
function HelloWoW_ShowMessage()
local baseName
local count = 1
local base = {}
baseName = GetItemInfo(25)
for i=25, 70000 do
end
for i = 1, #base do
endlocal count = 1
local base = {}
baseName = GetItemInfo(25)
for i=25, 70000 do
end
for i = 1, #base do
print(basei)
end 번는 7만 는 wow보 i 는 item '낡' 25부 1만 base블 .
는 . 느리만 DB 놓 듯 . 따 리 보.
보 25번 부 7만 덤변를 불러
보 면 !
들 모 는 보 르. 만..
보 면 !
들 모 는 보 르. 만..
function HelloWoW_ShowMessage()
local baseName = nil
repeat
until baseName ~= nil
print(baseName)
endrepeat
until baseName ~= nil
print(baseName)
럼 보
2.5. Lua 빼 ¶
빼
UTF-8 바 뒤 몇바를 는 문 보는 를 Lua 바보.
UTF-8 바 뒤 몇바를 는 문 보는 를 Lua 바보.
더 바 범 UTF-8 바 내 00000000 ~ 01111111 : 1 byte (0 ~ 127) 11000000 ~ 11011111 : 2 bytes (192 ~ 223) 11100000 ~ 11101111 : 3 bytes (224 ~ 239) 11110000 ~ 11110111 : 4 bytes (240 ~ 247) 11111000 ~ 11111011 : 5 bytes (248 ~ 251) 11111100 ~ 11111101 : 6 bytes (252 ~ 253)
는 문 들면 몇 byte를 는 는
function charLen(str) calc = string.byte(str:sub(1,1)) --lua byte char 변면 0 . if(calc >= 0 and calc <= 127) then return 1 elseif(calc >= 192 and calc <= 223) then return 2 elseif(calc >= 224 and calc <= 239) then return 3 elseif(calc >= 240 and calc <= 247) then return 4 elseif(calc >= 248 and calc <= 251) then return 5 elseif(calc >= 252 and calc <= 253) then return 6 else return 0 end end
번 말면 3byte.
3byte를 문 문 만 내는데는 무 문 .
받 만 보.
3byte를 문 문 만 내는데는 무 문 .
받 만 보.
~lua Chosung = {"","","","","","","ㅁ","ㅂ","ㅃ","ㅅ","ㅆ","o","ㅈ","ㅉ","ㅊ","","ㅌ","ㅍ","ㅎ"}; Middle = {"ㅏ","ㅐ","","ㅒ","ㅓ","ㅔ","","ㅖ","ㅗ","","","ㅛ","ㅙ","ㅚ","","","ㅞ","ㅟ","ㅡ","ㅢ","ㅣ"}; Last = { "\0","","","","","","","","","","","","","","ㅀ","ㅁ","ㅂ","","ㅅ","ㅆ","o","ㅈ","ㅊ","","ㅌ","ㅍ","ㅎ"}; function samplingFirst(str) -- 1110xxxx 10yyyyzz 10zzwwww local first = string.byte(str:sub(1,1)) - 224 -- 1110xxxx local second = math.floor((string.byte(str:sub(2,2)) - 128)/4) local third = math.floor((string.byte(str:sub(2,2))%4)*4 + (string.byte(str:sub(3,3)) - 128)/16) local fourth = math.floor(string.byte(str:sub(3,3))%16) local unicode = first * 16* 16* 16 + second * 16 * 16 + third * 16 + fourth unicode = unicode - 0xAC00 local cho = math.floor(unicode / 21/ 28) local goong = math.floor((unicode % (21*28))/28) local jong = math.floor((unicode % 28)) return Chosung[cho+1]; end
문 는면 만 빼는 . Lua 3byte 문 릭 '' 면 따 러 . 따 문 " " .
"르\:\:Aldiana"를 만 는 냥 보 보는 보
~lua function cstc(len, str) return {type = len, body = str}; end function makingTable(str) stringtable = {} for i = 1, #str do len = charLen(str:sub(i,i)) if len ~= 0 then -- 데.. stringtable[#stringtable+1] = cstc(len, str:sub(i,i+len-1)) end end chosungtable = {} for i, v in ipairs(stringtable) do if v.type == 3 then chosungtable[#chosungtable+1] = cstc(v.type, samplingFirst(v.body)) else chosungtable[#chosungtable+1] = cstc(v.type, v.body) end end return stringtable, chosungtable end local a = "르\:\:Aldiana" t,x = makingTable(a) for i, v in ipairs(t) do print(v.type .. " " .. v.body) end for i, v in ipairs(x) do print(v.type .. " " .. v.body) end : 르::Aldiana ㅅ:ㅇㅇㅇㅅ:Aldiana
목 불러 빼 는 보
2.6. WOW Slash Command ¶
는 SlashCommand . 뭐냐면..
/명 란 .
Addon 만들 는 SlashCommand .
/ 30
면 30 문 .
면 30 문 .
본 리 만 SlashCommand 동보.
SlashCommand 등는 보.
SLASH_명# = '/명' 변를 면
WOW '/명' 명는 msg를 들 function 들 .
~lua function HelloWoW_OnLoad(self) SLASH_HelloWoW1 = '/hiw'; SLASH_HelloWoW2 = '/hellow'; SLASH_HelloWoW3 = '/HelloWOW'; SlashCmdList["HelloWoW"] = function (msg) HelloWoWF(msg) end end function HelloWoWF(msg, editbox) -- 4. print("Hello WOW") end :/hiw : Hello WOW
SlashCmdList["명"]
= function(msg) 를 SLASH_명# = '/명' 변를 면
WOW '/명' 명는 msg를 들 function 들 .
는 3 명 는
면 는 .
String 리를 며보.
2.7. CommandMessageParsing ¶
맨를 받 msg를 보
parsing 는 문만 보.
parsing 는 문만 보.
됬를 는 는 대 flag를 봤는데
Addon 면 램 문 WOW 메모리 . 따 Addon flag는 따 메모리를 받는 . 따 변는 addon 디 능 리 .
Addon 면 램 문 WOW 메모리 . 따 Addon flag는 따 메모리를 받는 . 따 변는 addon 디 능 리 .
~lua SLASH_HelloWoW1 = '/hiw'; SLASH_HelloWoW2 = '/hellow'; SLASH_HelloWoW3 = '/HelloWOW'; flag = false; function HelloWoW_ShowMessage() SlashCmdList["HelloWoW"] = function (msg) HelloWoWF(msg) end; end function HelloWoWF(msg, editbox) print(msg) local x; if string.find(msg,"") then if flag == false then x = msg:match("%s(%d+)$"); print(x) flag = true; if x then print(" " .. x .. " 문!"); else print(" 본 10 문!"); end else print(" 미 "); end elseif msg:find("료") then if flag == true then print("를 료"); flag = false; else print(" "); end end end WOW : /hiw 료 WOW : WOW : /hiw 50 WOW : 50 문! WOW : /hiw 료 WOW : 를 료 WOW : /hiw 료 WOW : WOW : /hiw WOW : 본 10 문 WOW : /hiw 50 WOW : 미
string.find(msg,"") msg ""란 는 2 며 는 nil 리. 따, if문 면 lua는 nil 모 ( 0 백링"") true .
문 는데 Eclipse string.find(msg,"") WOW 며 동 . 는 무냐 면 WOW Addon더 lua 메모 는데 메모 본 Encoding ANSI. 문 WOW 는 UTF-8는 매 는! 따 메모 -> Encoding UTF-8 면 동 . 들 .
x = string.match(msg,pattern) 는 pattern 따 msg를 매 브 맞는 를 assign (=)를 .
는
x = msg:match("%s(%d+)$");
면 백 문 는 문 x 란 리.
는
x = msg:match("%s(%d+)$");
면 백 문 는 문 x 란 리.
매 . Lua Sub pattern 변를 는 더 봐.
런 런 면 .
: 를 는 !!!
방? 더러 !! !!
방? 더러 !! !!
: lua 동 모 메를 리는 보.
2.8. FrameEventHandling ¶
빡 부 .
UI를 만는데
동, Event Handling, UI미
WOW API를 뒤 뒤 Frame Frame DefaultChatWindow 메를 받 .
Lua Frame 불러면 CreateFrame 봐
frameName
면 String.
면 String.
parentFrame
부모 .
부모 .
inheritsFrame
Frame 는 데 면 . 런..
Frame 는 데 면 . 런..
newFrame:setScript("OnLoad",funcname)
면 OnLoad는 벤 funcname .
MainFrame 보.
들 뭐냐면 만 2. 는데 밖 만. CHAT_MSG_CHANNEL 벤를 더 보내 는는.
메를 받면 는 벤란 리.
는 본 RegisterEvent를 들마 는.
function HelloWoW_ShowMessage() DEFAULT_CHAT_FRAME:RegisterEvent("CHAT_MSG_CHANNEL"); local function eventHandler(self, event, ...) if (event == "CHAT_MSG_CHANNEL") then local arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9 = ...; print(arg1); end end DEFAULT_CHAT_FRAME:SetScript("OnEvent", eventHandler); end.
메를 보.
면 뮤 벤를 볼 는데 내 번 대 는 벤는 "","","","대" Chat 마 는 Event를 .
frame 만들 놓면 Event 받는 대 모 벤 .
.. xml 돌 보.
HelloWoW.xml
<UI xmlns="http://www.blizzard.com/wow/ui" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui"> <script file="HelloWoW.lua"/> <Frame name="HelloWoW"> <Scripts> <OnLoad> HelloWoW_ShowMessage(self) </OnLoad> </Scripts> </Frame> </UI>self 바!! self는 Frame 는.
On_load 면 HelloWoW를 .
HelloWoW.lua
function HelloWoW_ShowMessage(self) local frame = self; frame:RegisterEvent("CHAT_MSG_CHANNEL"); frame:RegisterEvent("CHAT_MSG_SAY"); frame:RegisterEvent("CHAT_MSG_PARTY"); frame:RegisterEvent("CHAT_MSG_YELL"); frame:RegisterEvent("CHAT_MSG_GUILD"); print("Load OK") local function eventHandler(self, event, ...) if (event == "CHAT_MSG_CHANNEL" or event == "CHAT_MSG_SAY") then local arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9 = ...; print(arg1); print(arg2); end end frame:SetScript("OnEvent", eventHandler); end
면 벤 등
frame:RegisterEvent("CHAT_MSG_CHANNEL"); frame:RegisterEvent("CHAT_MSG_SAY"); frame:RegisterEvent("CHAT_MSG_PARTY"); frame:RegisterEvent("CHAT_MSG_YELL"); frame:RegisterEvent("CHAT_MSG_GUILD");만 CHAT_MSG_CHANNEL CHAT_MSG_SAY 만 는 .
면 면 Load_OK 면 .
는 모 문를 print.
eventHandler(self, event, ...)
self는 벤를 받 frame 를 말 event는 벤. 리 변 ... arg1~arg9는 Communication Event 는 를 받는 대 arg1는 msg arg2는 author 들 .
는 머를 는 배보.
2.9. 동 Update timer ¶
먹 는 Addon만들.
Timer는 떻 만들?
WOW API 는 getTime()..
.
.
~lua seconds = GetTime(); print("Current system uptime is: "..seconds.." seconds!");
는 API명. Addon Sleep 놓면 멈는 . 면 를 만들 Sleep . 복면 는 떨? Sleep Lua System OS는 는.
Lua 보.
는 Lua sleep 볼 .
Coroutine 만는듯 데 뭔 .
Coroutine 른 를 는? . Busy Wait 만 Sleep 는데 Thread 른 밍 는 ???
뭐 .
~lua local clock = os.clock function sleep(n) -- seconds local t0 = clock() while clock() - t0 <= n do end end co = coroutine.create(function() print("what") sleep(5) end ) print("what") print("main",coroutine.resume(co));면 what 먼는 맞.
리 sleep(5)를 면 5뒤 . . Millisecond .
뮬 돌본 Coroutine 른 Thread 돌는 main 돌는 . 떤 는.. .
2를 동 0.1 0.2 동 Check를 는 를 매.
러 OnUpdate는 Event를 됬는데 명 보
{{{ How Often Is It Called The game engine will call your OnUpdate function once each frame. This is (in most cases) extremely excessive. Ctrl + R to see the FPS on screen. }} FPS... Frame Per Second마 불린. 러 대략 1/60 마 번 불린. OnUpdate를 Frame 등 보. {{{ <UI xmlns="http://www.blizzard.com/wow/ui" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui"> <script file="HelloWoW.lua"/> <Frame name="HelloWoW"> <Scripts> <OnLoad>self.TimeSinceLastUpdate = 0 </OnLoad> <OnUpdate function="HelloWoW_OnUpdate"></OnUpdate> </Scripts> </Frame> </UI> }}} Frame OnUpdate는 OnUpdate 마 HelloWoW_OnUpdate는 를 . 데 보면..? {{{ function HelloWoW_OnUpdate(self, elapsed) self.TimeSinceLastUpdate = self.TimeSinceLastUpdate + elapsed; if (self.TimeSinceLastUpdate > MyAddon_UpdateInterval) then -- -- Insert your OnUpdate code here -- TimeSet(); self.TimeSinceLastUpdate = 0; end end function TimeSet(){ seconds = GetTime(); print("Current system uptime is: "..seconds.." seconds!"); } }}} 데... ? 를 보. {{{ When Is It Called Edit OnUpdate is not called on any hidden frames, only while they are shown on-screen. OnUpdate will also never be called on a virtual frame, but will be called on any frames that inherit from one. }}} Frame 돌는. .. Frame 만들 . 는 배는 밍 루 는 빌 WOW Addon Studio를 . WOW Addon Studio는 WOW Addon UI디 벤 들링 는 . Addon Studio는 V1.0.1 V2.0 눌 는데 1.0.1 Visual Studio 2008 V2.0 Visual Studio 2010 V2.0 는 능 더 많 . 는 http://www.codeplex.com/WarcraftAddOnStudio 받 . Basic Addon UI ACE UI를 . Project를 Visual Studio 본 만들면 Frame Frame 르 면 Properties EventHandling . 벤를 르 Create 르면 Function Lua 동 Script 등 . 뭐 .. OnUpdate 를 만들 만들 면 {{{ Frame.xml <Ui xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.blizzard.com/wow/ui/"> <Script file="Frame.lua" /> <Frame name="Frame1" parent="UIParent" toplevel="true" movable="true" enableMouse="true"> <Size> <AbsDimension x="359" y="303" /> </Size> <Anchors> <Anchor point="TOPLEFT"> <Offset> <AbsDimension x="100" y="-47" /> </Offset> </Anchor> </Anchors> <Scripts> <OnUpdate>Frame1_OnUpdate();</OnUpdate> <OnMouseDown>self:StartMoving();</OnMouseDown> <OnMouseUp>self:StopMovingOrSizing();</OnMouseUp> </Scripts> <Backdrop bgFile="Interface\DialogFrame\UI-DialogBox-Background" edgeFile="Interface\DialogFrame\UI-DialogBox-Border" tile="true"> <BackgroundInsets> <AbsInset left="11" right="12" top="12" bottom="11" /> </BackgroundInsets> <TileSize> <AbsValue val="32" /> </TileSize> <EdgeSize> <AbsValue val="32" /> </EdgeSize> </Backdrop> </Frame> </Ui> }}} 만들 . {{{ Frame.lua -- Author : June -- Create Date : 2011-08-12 2:23:05 function Frame1_OnUpdate() --put your event handler logic here seconds = GetTime(); print("Current system uptime is: "..seconds.." seconds!"); end }}} {{{ ## X-AutoGenerated: true ## X-GeneratorComment: Basic project properties and project files will be automatically added during deployment. Properties added by the user will be copied without changes. ## Interface: 40200 ## Title: WowAddon1 ## Notes: Basic WoW Addon ## Author: June ## Version: 0.1Beta Frame.xml Frame.lua }}} 동. 돌리면 60 Time 는 볼 . .. 모 맞!!! : 램 리 및 == 남 말 ==