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/" .
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 ! ¶
기 기 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 걸 . .. !!! : 그 구 == 기고 ==