Originally Posted by Zireko
As for Bazooka do you know a currency plugin, bag slot plugin, and a recommended zone plugin for it.
|
There's a dedicated category for Broker plugins here:
http://www.wowinterface.com/downloads/cat108.html
I don't personally use any plugins that do what you described, so I can't offer any recommendations there. I do use plugins to
quickly swap equipment sets,
replace the minimap LFG icon, replace the minimap clock, replace the minimap zone name box,
show my XP or rep, and
quickly drop low-value items when my bags are full.
Additionally, many addons will provide a "launcher" icon that you can click to toggle the addon's display, quickly access the addon's options, etc. I'd say I have 5-10 such icons displayed on my bar, though there are an equal number that I've turned off because I don't care about them.
Originally Posted by Zireko
As for my frame that I want to create I wanted to ask how to set a custom texture like I did before but last time I did it in xml and this time I want to do it in lua? Now if I'm going to do the saved variable for the position and the hiding of the frame can you please show me how to do this on a very simple level with the table because I know I will need tables in any later addon that I do? Thank you in advanced Phanx.
|
I'd suggest doing these one step at a time, and make sure you understand each step before proceeding to the next.
First, make the frame:
Code:
-- Create a frame with a unique global name,
-- and assign it to a local variable for faster local access:
local frame = CreateFrame("Frame", "MyAddonFrame", UIParent)
-- Give it a default position; the middle of the screen is good:
frame:SetPoint("CENTER")
-- And finally, give it a size, since frames need
-- both a location and a size to be displayed:
frame:SetSize(200, 200)
Second, add the texture so there's something to see:
Code:
-- Textures and font strings should generally NOT have global names:
local texture = frame:CreateTexture(nil, "BACKGROUND")
-- Make it fill the frame:
texture:SetAllPoints(true)
-- Make it semi-transparent black:
texture:SetTexture(0, 0, 0, 0.5)
Later you can play around with using actual texture files, but for simple solid-colored areas you can just pass your desired color directly to
SetTexture.
Now make it movable:
Code:
frame:SetMovable(true)
frame:RegisterForDrag("LeftButton")
frame:SetScript("OnDragStart", function(self, button)
-- self = frame
-- button = string describing which mouse button is being used, eg. "LeftButton" or "RightButton"
-- Let's make it only drag with the right button:
if button == "RightButton" then
self:StartMoving()
end
end)
frame:SetScript("OnDragStop", function(self, button)
self:StopMovingOrSizing()
end)
Now you can drag it around. Let's add a saved variable to your TOC:
Code:
## SavedVariables: MyAddonDB
And at the top of your Lua file, before you create the frame, give it a default value:
Now restart WoW (most TOC changes require a full restart). From now on, this will happen:
1. You log in.
2. WoW reads your TOC file. The "SavedVariables" line has no effect at this time.
3. WoW reads your Lua file. "MyAddonDB" is created as a global variable with its value an empty table.
4. WoW reads your addon's saved variables file.
4a. If "MyAddonDB" was previously saved, its saved value overwrites the empty table.
4b. If "MyAddonDB" was not previously saved, its value remains the empty table.
5. You log out.
6. WoW remembers that you told it to save the "MyAddonDB" variable, and writes its current value out to your addon's saved variables file.
Now you can put stuff in it:
Code:
frame:SetScript("OnDragStop", function(self, button)
self:StopMovingOrSizing()
-- Get the new position:
local x, y = self:GetLeft(), self:GetBottom()
-- Save it:
MyAddonDB.x = x
MyAddonDB.y = y
-- And re-anchor it:
self:ClearAllPoints()
self:SetPoint("BOTTOMLEFT", x, y)
end)
The last part isn't strictly necessary, but if you're saving points relative to the bottom left, then it's just a good idea to make sure the frame is always anchored by its bottom left. That way if you change its size later, it'll still be placed where you expect.
Now log out and look at your saved variables file. You should see those x/y coordinates in your table.
Now let's load them:
Code:
frame:RegisterEvent("ADDON_LOADED")
frame:SetScript("OnEvent", function(self, event, arg)
if arg == "MyAddon" then
-- This "addon loaded" event is for your addon.
-- Your saved variables, if they existed, have been loaded. Check for that:
if MyAddonDB.x and MyAddonDB.y then
-- We have saved coordinates. Apply them:
self:ClearAllPoints()
self:SetPoint("BOTTOMLEFT", MyAddonDB.x, MyAddonDB.y)
end
end
end)
Now let's look at handling multiple events. For example, let's make the frame turn red while we're in combat. I'll point you to the
event documentation on Wowpedia and make you find the right events. Once you've found them, register for them:
Code:
frame:RegisterEvent("ADDON_LOADED") -- Keep this around
frame:RegisterEvent("XXXXXX") -- Event for entering combat
frame:RegisterEvent("YYYYYY") -- Event for leaving combat
And adjust your event handler so it doesn't run the "addon loaded" code for every event:
Code:
-- Since different events come with different arguments,
-- use a vararg (looks like a horizontal ellipsis, or three dots)
-- as a generic "catch all" in the function definition:
frame:SetScript("OnEvent", function(self, event, ...)
-- Now check the event first:
if event == "ADDON_LOADED" then
-- Assign the arguments to actual named variables for this event:
local addon = ...
if addon == "MyAddon" then
-- Put the same code you used before here
end
-- Check for the combat starting event:
elseif event == "XXXXXX" then
-- This event does not provide any arguments, so there's
-- no need to do anything with the vararg, since it's empty.
-- Make the texture red:
texture:SetTexture(1, 0, 0, 0.5)
-- Check for the combat ending event:
elseif event == "YYYYYY" then
-- No arguments for this event either.
-- Make the texture black again:
texture:SetTexture(0, 0, 0, 0.5)
end
end)