U E D R , A S I H C RSS

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




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