U E D R , A S I H C RSS

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



1.


2.1. Lua

WOW Lua Ruby .

Programming in Lua . 마 빌 1.

Lua 는데 .

Lua-Eclipse를 받 . (LunarEclipse )


Eclipse Java 돌리 러를 . Lua를 . LuaProfiler LuaInterpreter는데 를 못 .



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 .


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.0645 sec