Thread Tools Display Modes
04-09-14, 03:10 PM   #1
mightyjay
A Murloc Raider
Join Date: Apr 2014
Posts: 6
Need help with XML and Addon studio

hey all im new to xml and lua programming im trying
to make one simple addon that takes the Guild Log and paste it into a textbox could some1 one help me out

i searched online couldnt find anything i know it has to do with GUILD_EVENT_LOG_UPDATE and QueryGuildEventLog but how do i make a function out of it that
i cant find any information on these two functions

how should the guild log event be placed into code to query it? im guessing it should be something like this but i know maybe chatframe is wrong help out please


ChatFrame_AddMessageEventFilter("GUILD_EVENT_LOG_UPDATE",QueryGuildEventLog)

function QueryGuildEventLog(msg)
leveltxt:SetText(msg)
end
  Reply With Quote
04-09-14, 04:01 PM   #2
mightyjay
A Murloc Raider
Join Date: Apr 2014
Posts: 6
if any one knows how to make it just in lua it could help me out still and id owe you the world
  Reply With Quote
04-09-14, 05:58 PM   #3
Dridzt
A Pyroguard Emberseer
 
Dridzt's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2005
Posts: 1,360
Code:
local GLogCopyFrame = CreateFrame("Frame", "GLogCopyFrame", UIParent)
tinsert(UISpecialFrames, "GLogCopyFrame")
GLogCopyFrame:SetBackdrop({
	bgFile = [[Interface\DialogFrame\UI-DialogBox-Background]],
	edgeFile = [[Interface\DialogFrame\UI-DialogBox-Border]],
	tile = true, tileSize = 16, edgeSize = 16,
	insets = { left = 3, right = 3, top = 5, bottom = 3 }
})
GLogCopyFrame:SetBackdropColor(0,0,0,1)
GLogCopyFrame:SetWidth(500)
GLogCopyFrame:SetHeight(400)
GLogCopyFrame:SetPoint("CENTER", UIParent, "CENTER")
GLogCopyFrame:Hide()
GLogCopyFrame:SetFrameStrata("DIALOG")
GLogCopyFrame:SetToplevel(true)

local scrollArea = CreateFrame("ScrollFrame", "GLogCopyScroll", GLogCopyFrame, "UIPanelScrollFrameTemplate")
scrollArea:SetPoint("TOPLEFT", GLogCopyFrame, "TOPLEFT", 8, -30)
scrollArea:SetPoint("BOTTOMRIGHT", GLogCopyFrame, "BOTTOMRIGHT", -30, 8)

local editBox = CreateFrame("EditBox", nil, GLogCopyFrame)
editBox:SetMultiLine(true)
editBox:SetMaxLetters(99999)
editBox:EnableMouse(true)
editBox:SetAutoFocus(false)
editBox:SetFontObject(ChatFontNormal)
editBox:SetWidth(400)
editBox:SetHeight(270)
editBox:SetScript("OnEscapePressed", function(self) 
	if self:HasFocus() then 
		self:ClearFocus() 
	else 
		GLogCopyFrame:Hide() 
	end 
end)
GLogCopyFrame.editBox = editBox

scrollArea:SetScrollChild(editBox)

local close = CreateFrame("Button", nil, GLogCopyFrame, "UIPanelCloseButton")
close:SetPoint("TOPRIGHT", GLogCopyFrame, "TOPRIGHT")

local button = CreateFrame("Button")
local Sanitize = function(text)
	button:SetText(text)
	return button:GetText()
end

GLogCopyFrame.On_Show = function(self)
	GLogCopyFrame:RegisterEvent("GUILD_EVENT_LOG_UPDATE")
	QueryGuildEventLog()
end
GLogCopyFrame.On_Hide = function(self)
	GLogCopyFrame.editBox:SetText("")
	GLogCopyFrame:UnregisterEvent("GUILD_EVENT_LOG_UPDATE")
end
GLogCopyFrame.On_Event = function(self,event,...)
	GLogCopyFrame.editBox:SetText("")
	local numEvents = GetNumGuildEvents()
	local evtype, player1, player2, rank, year, month, day, hour
	local msg
	local buffer = ""
	for i = numEvents, 1, -1 do
		evtype, player1, player2, rank, year, month, day, hour = GetGuildEventInfo(i)
		if ( not player1 ) then
			player1 = UNKNOWN
		end
		if ( not player2 ) then
			player2 = UNKNOWN
		end
		if ( evtype == "invite" ) then
			msg = format(GUILDEVENT_TYPE_INVITE, player1, player2)
		elseif ( evtype == "join" ) then
			msg = format(GUILDEVENT_TYPE_JOIN, player1)
		elseif ( evtype == "promote" ) then
			msg = format(GUILDEVENT_TYPE_PROMOTE, player1, player2, rank)
		elseif ( evtype == "demote" ) then
			msg = format(GUILDEVENT_TYPE_DEMOTE, player1, player2, rank)
		elseif ( evtype == "remove" ) then
			msg = format(GUILDEVENT_TYPE_REMOVE, player1, player2)
		elseif ( evtype == "quit" ) then
			msg = format(GUILDEVENT_TYPE_QUIT, player1)
		end
		if ( msg ) then
 			buffer = buffer..msg.."|cff009999   "..format(GUILD_BANK_LOG_TIME, Sanitize(RecentTimeDate(year, month, day, hour))).."|r|n"
		end
	end
	GLogCopyFrame.editBox:SetText(buffer)
end
GLogCopyFrame:SetScript("OnShow",GLogCopyFrame.On_Show)
GLogCopyFrame:SetScript("OnHide",GLogCopyFrame.On_Hide)
GLogCopyFrame:SetScript("OnEvent",GLogCopyFrame.On_Event)

SLASH_GLOGCPY1 = "/glogcpy"
SlashCmdList.GLOGCPY = function()
	GLogCopyFrame:SetShown(not GLogCopyFrame:IsShown())
end
Drycoded for the most part.
I'm assuming your goal was to get the guild log someplace to copy it from.
/glogcpy should show the editbox with the guild log, ctrl+a to select all, ctrl+c to copy.
To turn this code into an addon you can use http://addon.bool.no/
  Reply With Quote
04-09-14, 06:08 PM   #4
Clamsoda
A Frostmaul Preserver
Join Date: Nov 2011
Posts: 269
Used this to get the text. It is one single line of text, so it is kind of a mess, but you can do with the text whatever you like. Obviously this needs to be restructured to achieve your goal.

Lua Code:
  1. local testFrame = CreateFrame("Frame")
  2. testFrame:RegisterEvent("GUILD_EVENT_LOG_UPDATE")
  3. testFrame:SetScript("OnEvent", function()
  4.     if (not GuildLogHTMLFrame) then return end
  5.  
  6.     QueryGuildEventLog()
  7.  
  8.     local text = GuildLogHTMLFrame:GetRegions():GetText()
  9.  
  10.     print(text)
  11. end)
  Reply With Quote
04-09-14, 07:12 PM   #5
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
Abandon AddOn Studio. It is so far out of date it is laughable. The last public update was in February 2009, which means it does not support the new, or more importantly changed or deleted APIs and events that came with Cataclysm and Pandaria.

I doubt it fully supports the Wrath APIs and events, given that they were changed during the lifetime of the expansion.

Further, the code AddOn Studio produces is bloated; you can write better code yourself.

Last, the majority of AddOn authors never use XML for a variety of reasons. It is still valid to use if you wish, but almost everything can also be accomplished in Lua, and the small things that only XML can do that Lua does not pretty much nobody uses so it won't matter.
  Reply With Quote
04-09-14, 08:15 PM   #6
mightyjay
A Murloc Raider
Join Date: Apr 2014
Posts: 6
FYI addon studio is at 3.0 right now and uptodate with 5.0 FallenWorlds.org - AsWoW 3.0.40327.1 - 3/27/2014 (Change History) since its an open source project
and i know a lot about visual studio and little to nothing in lua it helps me a lot with the intelligent function proposal

so ima continue to use it until it gets out of date thanks to both of you guys who posted the code
special thanks to Dridzt your code has EXACTLY what i wanted tank you

one more thing in your code would it be possible to show only the Quit by typing lets say /glogcpyquit i tryed to remove the other if then but it would then show duplicates of the quit wich are ''I think'' other events still showing as quit

Last edited by mightyjay : 04-09-14 at 08:38 PM.
  Reply With Quote
04-09-14, 09:00 PM   #7
mightyjay
A Murloc Raider
Join Date: Apr 2014
Posts: 6
last message was edited
  Reply With Quote
04-10-14, 03:16 PM   #8
mightyjay
A Murloc Raider
Join Date: Apr 2014
Posts: 6
never mind got it thanks all
  Reply With Quote
04-20-14, 05:04 AM   #9
Digital_Utopia
A Flamescale Wyrmkin
 
Digital_Utopia's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2012
Posts: 110
Originally Posted by myrroddin View Post
Abandon AddOn Studio. It is so far out of date it is laughable. The last public update was in February 2009, which means it does not support the new, or more importantly changed or deleted APIs and events that came with Cataclysm and Pandaria.

I doubt it fully supports the Wrath APIs and events, given that they were changed during the lifetime of the expansion.

Further, the code AddOn Studio produces is bloated; you can write better code yourself.

Last, the majority of AddOn authors never use XML for a variety of reasons. It is still valid to use if you wish, but almost everything can also be accomplished in Lua, and the small things that only XML can do that Lua does not pretty much nobody uses so it won't matter.
I think you're referring to the original. There's a newer one called WoW Addon Studio 2010. Presumably named because it uses the Visual Studio 2010 shell, and the last update shown was in December of 2013.

It's not a perfect solution - it's not going to turn addon development into something as cut and dry as, for instance, making a .NET app; but it does do a good job of handling both XML and Lua. Both indentation, and even comments. No small feat on the Lua side of things, considering how much syntactic sugar is involved.
__________________
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Need help with XML and Addon studio

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off