Thread Tools Display Modes
09-11-08, 10:15 PM   #1
paladinpownage
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Sep 2008
Posts: 9
Lightbulb *Scratches head* A very simple question on printing

Hi, long-time listener, first-time caller, so to speak. I finally got fed up with all the shiny reputation addons that took up way too much screen space so I'm doing my best to hack together my own that only uses one line of text (eventually) right below the existing bits about +100 here, -20 there, etc... With various factions. You know, you kill an enemy, there really isn't a need for a popup, just a bit of handy text that says hey, you just gained this much reputation, if you can keep that up it'll take this many of that reputation to pop the next standing, etc...

Seems though there's every kind of tutorial but the one that explains what a default chat window is and how to find one and well, I tried Self:print but got Self:owned, so I thought I'd wander in and ask.

I'm working with two functions at the moment.


The first is a function that is called when the addon's enabled that generates a table of all the factions and only the useful statistics, current standing, reputation gained within the constraints of the standing, reputation remaining until the next standing

The second is a hook for the UPDATE_FACTION event that generates a new table and checks it against the old one to see which factions have been updated and then in the end hopefully, and this hasn't happened so far, tells you how at your current rate of reputation gain how many are left until you pop a new standing.

Does all of that make sense?

Code:
function AlbyRep:UPDATE_FACTION()
	-- Hook in for when an add is made to a reputation
	
	-- First check amongst the existing factions, ignoring any new ones, for reputation change
	-- Generate a new table and compare it with the old one
	-- Store any changes to reputation for factions in a separate table
	
	AlbyRep.repChanges={};
	AlbyRep.changedReps=0;
	
	for facIndex=1, AlbyRep.curFacCount do
		facName, _, facSID, facBVal, facTVal, facEVal, _, _, facIsHdr, _, _ = GetFactionInfo(facIndex);
		facRepGained=facEVal-facBVal;
		
		if facIsHdr == nil then
			-- First check whether the standing has changed
			if AlbyRep.facList[facName][2]~=facSID then
				self:Print("Increase in standing with %q!", facName);
			end
			
			-- Then do the standard reputation check
			if AlbyRep.facList[facName][3]<facRepGained then
				AlbyRep.changedReps=AlbyRep.changedReps+1;
				AlbyRep.repChanges[AlbyRep.changedReps]={facName,facRepGained-AlbyRep.facList[facName][3]};
				
				self:Print("Increase in reputation of %q with %q!", AlbyRep.repChanges[facIndex][2], facName);
			else if AlbyRep.facList[facName][3]>facRepGained then
				AlbyRep.changedReps=AlbyRep.changedReps+1;
				AlbyRep.repChanges[AlbyRep.changedReps]={facName,AlbyRep.facList[facName][3]-facRepGained};
				
				self:Print("Decrease in reputation of %q with %q!", AlbyRep.repChanges[facIndex][2], facName);
			end
		end
	end	
	
	-- Now deal with any new factions NOT YET IMPLEMENTED
	
	-- Now fix the base table to reflect new values NOT YET IMPLEMENTED

end

function AlbyRep:ParseFactions()
	-- Parses the faction list into several useful tables
	
	-- A more useful faction table: Will contain the following structure
	-- Faction name, faction index, faction standing ID, reputation gained so far inside of current standing (earned value minus bottom value), reputation left (top value minus earned value), last reputation gain
	AlbyRep.curFacCount=GetNumFactions();
	AlbyRep.facList={};
	
	for facIndex=1, AlbyRep.curFacCount do
		facName, _, facSID, facBVal, facTVal, facEVal, _, _, facIsHdr, _, _ = GetFactionInfo(facIndex);
		
		-- Only interested in individual factions, not faction groupings
		
		if facIsHdr == nil then
			AlbyRep.facList[facName]={facIndex, facSID, facEVal-facBVal, facTVal-facEVal, nil};
		end
	end
end
That's what I have so far for the two factions. I have lots of motivation but very little practical experience with LUA and I'm really not having much luck. I kinda suspect it may in fact be my TOC that's the problem, I think the LUA code itself is solid so far, although obviously it's not quite setup to print what it should, I just threw some prints in to test whether it was actually printing anything at all!

Code:
## Title: AlbyRep
## Notes: Displays information relevant to any changes in reputation during gameplay
## Version: 0.1
## Author: Albatross
## Interface: 20400
## OptionalDeps: Ace2

AlbyRep.lua
Libs\AceAddon-2.0\AceAddon-2.0.lua
Libs\AceConsole-2.0\AceConsole-2.0.lua
Libs\AceEvent-2.0\AceEvent-2.0.lua
Libs\AceLibrary\AceLibrary.lua
Libs\AceOO-2.0\AceOO-2.0.lua

That's the code for my TOC... I don't even think WoW is loading my addon. I know it sees it, I can enable it and disable it, but it's not... I don't think it is anyway... Loading it.


Can anybody shed some light?

Much obliged,
Jonjon
Attached Thumbnails
Click image for larger version

Name:	repmockup.gif
Views:	608
Size:	10.0 KB
ID:	1924  
  Reply With Quote
09-11-08, 10:21 PM   #2
Mikord
A Theradrim Guardian
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 61
I haven't look through all of the code, but one thing that popped out at me is that you are depending on Ace2, but you load the libraries you depend on after the file that depends on them (AlbyRep.lua). Try loading the dependencies first.

Code:
Libs\AceAddon-2.0\AceAddon-2.0.lua
...
AlbyRep.lua
Also, if you are just trying to test print something in WotLK you can use print("whatever"). On Live you can use ChatFrame1:AddMessage("Whatever"), but self:Print provided by Ace2 does the same thing.

Last edited by Mikord : 09-11-08 at 10:48 PM.
  Reply With Quote
09-11-08, 11:02 PM   #3
paladinpownage
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Sep 2008
Posts: 9
Originally Posted by Mikord View Post
I haven't look through all of the code, but one thing that popped out at me is that you are depending on Ace2, but you load the libraries you depend on after the file that depends on them (AlbyRep.lua). Try loading the dependencies first.

Code:
Libs\AceAddon-2.0\AceAddon-2.0.lua
...
AlbyRep.lua
Also, if you are just trying to test print something in WotLK you can use print("whatever"). On Live you can use ChatFrame1:AddMessage("Whatever"), but self:Print provided by Ace2 does the same thing.
Okay, cool, I switched them around... That makes sense, yeah. I wish I could figure out what's stopping it from printing though because that didn't change a thing. At least it's more organized now!

Thanks
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » *Scratches head* A very simple question on printing

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