View Single Post
11-01-10, 04:26 PM   #1
Zasurus
A Cyclonian
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 42
Lightbulb 3rd Party Addon Interface to Carbonite Update?

Hi Carbonite,
I am an AddOn author and make a few AddOn's that add icon's & area's to Carbonite's maps and although there doesn't seem to be an official interface I found an old post a while back with info from you guys on how to interface with Carbonite. Although it didn't work (it looks like the functions have long been forgotten about and are not out of date and useless) it DID point me in the correct direction and I have since managed to as I mentioned earlier add points and even area's to the Carbonite map using its own functions so they all work nice!

The problem is I have had to change a few of the Carbonite's functions to get the desired effect. I do this with hooks and you are likely to know about them due to a badly named file "Fix_ZasCarboniteFixs.lua" it has appeared on the forums with users thinking it was your fault twice now! I have tried to track these down and correct them as soon as they crop up and while I was changing the file name so it didn't lead people to you guys I figured due to the recent increase in development due to Cata you might be willing to do a few TINY code changes so I can get rid of that annoying file! ;-)
I will explain how I am adding stuff to the map first so you can see where my problems are coming from. MAYBE you know a better way! :-)
First to add icons (like waypoints etc) I use two bits of code. The first one sets up the point types etc with Carbonite and that is:

Code:
local icT;
if (Nx) then -- Carbonite exits so setup the icon types for it (Also clears any existing icons)
	----------------------------------------------------------
	-- Setup the icon types for this addon (also wipes all old
	-- icons from the same addon)
	----------------------------------------------------------
		local CarbMap=Nx.Map:GeM(1);
		icT = "!"..tostring(self.Name); -- Name of the addon
		local drM = "WP"; -- This specifies it's a waypoint
		local tex = ""; -- This is a texture. Don't know what this is for as it's almost always blank.
		local w = 10; -- This is the Width of the icon
		local h = 10; -- This is the Hight of the icon
		CarbMap:IIT(icT,drM,tex,w,h);
		
		CarbMap:SITA("!WorldExplorer",1); -- Set the Alpha of these points.
		CarbMap:SITAS("!WorldExplorer",0.3); -- Sets the scale these points disapears at.
	----------------------------------------------------------
end;
This basically checks Carbonite exists and then sets up the types and wipes any points that are already on the map from earlier. I will run this at the start of any function that adds points to the map.

The next section is run for every point I want to add to the map:

Code:
if (Nx and ZoneName) then -- Carbonite exits so add the icons to that as well
	----------------------------------------------------------
	-- Creates an icon
	----------------------------------------------------------
		local mapName = ZoneName; -- This is the name of the zone e.g. "Tirisfal Glades"
		local zoneX = CordX * 100; -- This is how from the left to the right of the zone the icon is in %. So if this was 0 it would be the far left if it was 100 it would be far right and if it was 50 it would be half way across
		local zoneY = CordY * 100; -- This is a % of the Hight of the zone (same as the width)
		local texture = Icon.Texture; -- This is the texure that will be used for the icon(Picture)
		local iconNote = SeperatingLine.."\n"..tostring(IconNote).."\n"..SeperatingLine.."\n"..IconNoteEnd; -- This is the note text(the text that pops up when you mouse over the icon)
		
		local map2=Nx.Map:GeM(1);
		local maI=Nx.MNTI1[mapName];
		if maI then
			local wx,wy=map2:GWP(maI,zoneX,zoneY);
			local icon = map2:AIP(icT,wx,wy,Colour,texture);
			map2:SIT(icon, iconNote); -- This sets the note(the text that pops up when you mouse over the icon)
		end;
	----------------------------------------------------------
end;
Again the first thing it does is checks that Carbonite exists (it will already have added the same icon to the original map...
It then passes in the location of the point, it's texture, colour etc and links it to the "icT" setup at the start of the function...


This works great!... Apart from the Colour the colour is passed and stored but I guess as you never sore a need for it you hard coded the colour to white on line 17728 (in Carbonite V4.013).

To get around this I replaced line 17728 (via a really crap hook) with:

Code:
local r,g,b = 1,1,1
if (ico.Col1) then
r,g,b = c2r1(ico.Col1)
end;
f.tex1:SetVertexColor(r,g,b,v.Alp)
As you can see this stores the default of white then if the icon has a colour stored (which was stored earlier with the standard Carbonite code (used for your shapes etc)) it uses that. I can't see a reason this would cause any problems and have been using it this way without any problems for quite some time which is why I added it to my addon's release and have not had one bug report about it (I hope you guys haven't!). If there are no colours specified it will use the original code.


The second problem was with my newest version of my AddOn "WorldExplorer" that now puts shapes on the Carbonite Map. It does this using again two bits of code... the same with SLIGHT changes for shapes!

Code:
local icT_Icons;
if (Nx) then -- Carbonite exits so setup the area types for it (Also clears any existing icons)
	----------------------------------------------------------
	-- Setup the Area(icon) values for this addon (also wipes all old
	-- icons from the same addon)
	----------------------------------------------------------
		local CarbMap=Nx.Map:GeM(1);
		icT_Areas = "!"..tostring(self.Name).."_Areas"; -- Name of the addon
		local drM = "ZR"; -- This specifies it's a "World point"
		local tex = ""; -- This is a texture. Don't know what this is for as it's almost always blank.
		local lev = -6; -- This is the frame level this icon should have. (Setting it to -1 seems to put it behind icons)
		CarbMap:IIT(icT_Areas,drM);
		
		CarbMap:SITL(icT_Areas,lev);
		CarbMap:SITAS(icT_Areas,0.3); -- Sets the scale these points disapears at.
	----------------------------------------------------------
end;
This is the first one and does the setup of the shapes linking to my addon and the second bit:

Code:
if (Nx and LangZoneName) then -- Carbonite exits so add the icons to that as well
	----------------------------------------------------------
	-- Creates a coloured rectangle
	----------------------------------------------------------
		do
			local mapName = LangZoneName; -- This is the name of the zone e.g. "Tirisfal Glades"
			local zoneX = Left * 100; -- This is how from the left to the right of the zone the icon is in %. So if this was 0 it would be the far left if it was 100 it would be far right and if it was 50 it would be half way across
			local zoneY = Top * 100; -- This is a % of the Hight of the zone (same as the width)
			local zoneX2 = Right * 100; -- This is how from the left to the right of the zone the icon is in %. So if this was 0 it would be the far left if it was 100 it would be far right and if it was 50 it would be half way across
			local zoneY2 = Bottom * 100; -- This is a % of the Hight of the zone (same as the width)
			local AreaNote2 = AreaNote; -- This is the note text(the text that pops up when you mouse over the icon)
			
			local map2=Nx.Map:GeM(1);
			local maI=Nx.MNTI1[mapName];
			if maI then
				local Rectange = map2:AIR(icT_Areas,maI,zoneX,zoneY,zoneX2,zoneY2,Colour)
				map2:SIT(Rectange, AreaNote2); -- This sets the note(the text that pops up when you mouse over the Rectange)
			end;
		end;
	----------------------------------------------------------
end;
This again just adds each shape to the map! It works perfectly! Thanks for making such a versitile addon!


The problem I had is that as the shapes doesn't have a "typ" Carbonite doesn't know what to do with it when you right click on it so defaults to nothing. I just wanted it to pretend the shape isn't there and you can right click "though" it

To do this I changed line 9978 from

Code:
end
to:

Code:
else
map.OMD(map.Frm,but)
end
So basically giving it an else click though... Again I can't see any problems from Carbnoites side as I didn't find any of your data displayed in this way or at least it wouldn't mind the right click working as if it isn't there!

Hope I didn't step on your toes or break any rules. :O If you have better ways of fixing this then I would love to give them a try! :-)

I know there is a lot of info there but I wanted to make sure you understood what I was trying to do any why! I feel that the changes are quite small so if you have read this far you have done the hard part!

Well that was a HUGE post! Glad you still here! LOL Unless you skipped to the bottom then

Regards,

Zas