U E D R , A S I H C RSS

WOW Add On/2011년프로젝트/초성퀴즈



1.


2.


2.1. Lua

WOW Lua나 Ruby 는것다.

그래 Programming in Lua라는 빌려다. 빌려 1 됬겠.

Lua 개발 는데 렸다.

Lua-Eclipse를 깔고. (LunarEclipse라는 것 단다)


Eclipse Java 다른것 돌리려면 당 러를 다. 그래 Lua를 다. LuaProfilerLuaInterpreter다는데 를 못겠다 나났다.



http://luaforge.net
Windows 러를 게됬다.

5.1.4-35 2010-04-07 13:09
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 범다고 는데??
모르겠!! 그래 가로 링본다.


드는 다과 같다.
/////////////////////////////////////////////
package utfencoding;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

public class UtfEncoding {

final static char[] first = {
'','','','','','','ㅁ','ㅂ','ㅃ','ㅅ','ㅆ','o','','ㅉ','ㅊ','ㅋ','ㅌ','ㅍ','ㅎ'
};
final static char[] middle = {
'ㅏ','ㅐ','ㅑ','ㅒ','ㅓ','ㅔ','ㅕ','ㅖ','ㅗ','ㅠ','ㅘ','','ㅙ','ㅚ','ㅜ','ㅝ','ㅞ','ㅟ','ㅡ','ㅢ','ㅣ'
};
final static char[] last = {
'\0','','','','','','','','','','','','','','ㅀ','ㅁ','ㅂ','','ㅅ','ㅆ','o','','ㅊ','ㅋ','ㅌ','ㅍ','ㅎ'
};

/**
  • @param args
  • /
public static void main(String[] args) {
String temp = "바";

char a = temp.charAt(0);
a = (char) (a - 0xAC00);
int cho = a/21/28;
int joong = ( (a %(21*28))/28);
int jong = (a%28);
System.out.println(""+ (char)firstcho + (char)middlejoong + (char)lastjong);
}

}
////////////////////////////////////////

보면 되는 UNICoDE다(?)

Eclipse개발 Encoding UTF-8방다.
UTF-8 따라 0xACC00 (<- UTF-8시작) 을 빼고 초성 중성 종성을 다음으로 빼온다

= ( /21 /28)
= ( (%(21*28))/28)
= ( a%28)

렇게 고 문 따라 빼다.
드를 보면 다.

2.3. Addon 만들기


Addon 게 되다.
Hello WoW!!

리길 Hello World!부라는 따라
떻게 동되는보겠다.

기본 로그램 보를 담고는 *.toc.
그리고 UI LUA를 Mapping 는 *.xml
그리고 는 *.lua



기본로 "/World of Warcraft/interface/addons/명" 더가 만들다.

그리고 HelloWoW.toc로 기본
toc 보를 다.
HelloWoW.toc

HelloWoW.xml
HelloWoW.lua

Interface 보가 들다.
http://www.wowwiki.com/Getting_the_current_interface_number
보를 다.
내가 4.2까 40200 보를 로드 '구'대로 로드가 다.

Title 대로고
는 그냥
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>
<OnLoad>
HelloWoW_ShowMessage();
</OnLoad>
</Scripts>
</Frame>
</UI>


HelloWoW.lua

function HelloWoW_ShowMessage()
message("Hello WOW!");
end

WoW API function lua 로 되나보다.
데?

렇게 면 Hello WOW!가 뜬다.

2.4. WOW API를 !


WOW는 WOW API를 는 wiki를 가고 API를 가보면 다것들 다.
http://www.wowwiki.com/World_of_Warcraft_API
Widget과 LuaFunction 보를 볼 다.

기본 DB를 검 다. 근데 WOW 만 7만 는다. 는 index 다. 게 뭥미. suffix때문된다. suffix란 부가로 붙 item index 부르는 말데 그것 따라 index가 결되는것 같더라. ( 는 모른다)

그리고 뽑는것 는 것 구드랍, 블루 ID 보까놓고 더만.. 까보고 놀랐.

보 공 가면 50760개라고 나다.
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
baseName = GetItemInfo(i)
if count > 10000 then
break
end

if baseName ~= nil then
basecount = baseName
count = count+1
end
end
for i = 1, #base do
print(basei)
end
end

는 7만 는다 wow 기로 고 그래 i 는 반 item '낡단검' 25부 1만개 base 다.

결과는 된다. 느리겠 DB 다가 다. 리고 .




보 25 7만 랜덤변
보가 나다면 력!
모두 가는것 보단 빠르다. 만..

function HelloWoW_ShowMessage()

local baseName = nil

repeat
i = random(25,70000)
baseName = GetItemInfo(i)
until baseName ~= nil

print(baseName)
end


그럼

2.5. 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를 문과 만 뽑내는데는 무 문 다.
만 뽑.
~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개된다.

기본 나리 SlashCommand.

SlashCommand 는것 .
~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개 는것

SLASH_HelloWoW1 = '/hiw';
SLASH_HelloWoW2 = '/hellow';
SLASH_HelloWoW3 = '/HelloWOW';

각각 면 같 결과가 나는것 다.

String 나리를 꾸며보.

2.7. CommandMessageParsing


맨드를 msg를 보고
parsing 는 문만 뽑.

때를 되고 flag를 봤는데
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로 가리다.


다. Lua Sub pattern 를 가다.

런 것 다.

: 는것 겹다!!!
방법나? 더러 드!! !!

: 과 lua 모든 메.

2.8. FrameEventHandling


공부가 될각된다.

UI를 만는데

동기, Event Handling, UI꾸미기

WOW API를 뒤고 뒤 Frame 고 Frame DefaultChatWindow 것 같다.

Lua Frame 려면 CreateFrame

CreateFrame()
newFrame = CreateFrame("frameType"[, "frameName"[, parentFrame[, "inheritsFrame"]]]);

frameType
Frame 따라 되는게 달라다 "EditBox","Button" UIObject를 String 된다


frameName
면 된다 String.

parentFrame
부모님 다.

inheritsFrame
Frame 는것 같 된단다. 런..

newFrame:setScript("OnLoad",funcname)
렇게 OnLoad라는 때 funcname 된다.

http://www.wowwiki.com/WoW_constants
로 가는 값들 기 나다.

MainFrame .

관련..
http://www.wowwiki.com/Chat
Event CHAT_MSG_CHANNEL 는데

로 들게 뭐냐만 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가 들다.

머를 는것.

Timer + CommandMessageParsing + FrameEventHandling를 만들 다.


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  다.

..

모든 가 맞다!!!


다  : 로그램 나리 및 구


== 남기고  말 ==

Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:28:23
Processing time 0.0590 sec