I'm working on my first addon and I keep hitting a wall with it. I'm very familiar with VB coding and can get a basic idea of what the code is saying when I read it.
The first problem which cropped up is that my close button doesn't seem to work at all. I figured I'd start fixing the simple problems first.
function Button1_OnClick()
Frame1:Hide();
end
Sweet and simple code. Funny story, it works when I'm also running my "Hello World" app which I did to familiarize myself with the new language. If I'm running my addon by itself, the button shows itself pressing down but the frame never hides.
Also, as a general tip, you should never use generic names like "Button1" and "Frame1" for your objects in the global namespace. Such names make it very difficult to identify which addon owns a particular object in-game if there is a problem, and is very likely to conflict with other addons that are poorly written or are unintentionally leaking variables into the global namespace.
Well, I tried changing the name of the frame and the close button is still not working. Very annoying...
local PROSPECT_ID = 31252
local MILLING_ID = 51005
local DE_ID = 13262
local PROSPECT = GetSpellInfo(PROSPECT_ID)
local MILLING = GetSpellInfo(MILLING_ID)
local DE = GetSpellInfo(DE_ID)
local getContents = false
local version = "v20122101"
local pairs
function BIDFrame1_OnLoad()
this:RegisterEvent("ADDON_LOADED");
this:RegisterEvent("LOOT_OPENED");
this:RegisterEvent("VARIABLES_LOADED");
DEFAULT_CHAT_FRAME:AddMessage("|cffff000Break it Down is ready for work")
end
function Button1_OnClick()
BIDFrame1:Hide();
end
function BIDFrame1_OnEvent()
if event == "UNIT_SPELLCAST_INTERRUPTED" then
local unitID, spell, rank = ...
if unitID == "player" and spell == PROSPECT or spell == MILLING or spell == DE then
getContents = false
end
end
if event == "LOOT_OPENED" then
if getContents then
WorkResults()
end
end
if event == "LOOT_CLOSED" then
getContents = false
end
end
function Button2_OnClick()
myResults = {}
BIDFrame1:Update();
end
local function WorkResults()
for i = 1, GetNumLootItems() do
local itemName = select(2, GetLootSlotInfo(i))
local quantity = select(3, GetLootSlotInfo(i))
if not myResults[itemName] then
MakeTableEntry(itemName)
end
if myResults[itemName] then
myResults[itemName] = myResults[itemName] + quantity
else
myResults[itemName] = quantity
end
end
end
local function ShowResults()
if myResults > 0 then
for itemName, num in pairs(myResults[itemName]) do
if itemName = quantity then
FSResults:SetText(itemName.." - "..quantity);
end
end
end
local function MakeTableEntry(itemName)
local name = GetItemInfo(itemName)
myResults[itemName] = {}
end
hooksecurefunc("CastSpell", function(...)
local spellName = GetSpellInfo(...)
if spellName:lower() == PROSPECT:lower() or spellName:lower() == MILLING:lower() or spellName:lower() == DE:lower() then
getContents = true
end
end)
hooksecurefunc("CastSpellByID", function(spellID)
if spellID == PROSPECT_ID or spellID == MILLING_ID or spellID == DE_ID then
getContents = true
end
end)
hooksecurefunc("UseAction", function(actionID)
local spellID = select(2, GetActionInfo(actionID))
if spellID == PROSPECT_ID or spellID == MILLING_ID or spellID == DE_ID then
getContents = true
end
end)
hooksecurefunc("CastSpellByName", function(spellName, onSelf)
if spellName:lower() == PROSPECT:lower() or spellName:lower() == MILLING:lower() or spellName:lower() == DE:lower() then
getContents = true
end
end)
That's the whole thing. Some of it is bits and pieces from other addons and some of it is mine. Mostly I've been working on creating a frame that shows the number of gems, pigments, and DE mats you end up getting in a large session. I figured I could add in general commands later, like a start recording type command (or button). At the moment, all that happens is the frame loads with all the labels and buttons in place. I can move it around. But it doesn't seem to do a thing.
I also have the following showing up in my FrameXML file.
1/26 18:52:56.714 Loading add-on BreakItDown
1/26 18:52:56.714 ** Loading table of contents Interface\AddOns\BreakItDown\BreakItDown.toc
1/26 18:52:56.714 Couldn't open Interface\AddOns\BreakItDown\BreakItDown
1/26 18:52:56.714 Interface\AddOns\BreakItDown\BreakItDown.lua:28: cannot use '...' outside a vararg function near '...'
1/26 18:52:56.714 ++ Loading file Interface\AddOns\BreakItDown\BreakItDown.xml
1/26 18:52:56.714 Interface\AddOns\BreakItDown\BreakItDown.lua:28: cannot use '...' outside a vararg function near '...'
1/26 18:52:56.714 [string "*:OnDragStart"]:2: function arguments expected near '='
1/26 18:52:56.714 [string "*:OnDragStop"]:2: function arguments expected near '='
First thing: you only need to include the Lua file once. Either in the .toc or in the .xml, but not both.
(Truthfully, you don't need the XML at all. If you're more comfortable learning with it, that's fine. Most people on these forums tend to prefer using only Lua, and bringing in XML only when strictly required.)
Second thing: there are no global "this" or "event" variables set automatically for you. That went away many, many patches ago; whatever you're using for a reference is badly outdated.
When you write <Stuff> blocks in XML, they get turned into Lua functions with some parameters already declared for you (listed here). If you want to have your XML blocks call functions defined in your Lua file, you need to pass those parameters along. Namely, "self", "event", and any event parameters (like the ones you're expecting to receive in "...").
A typoo in the .xml will make the whole ting fail.
for example using <!-- instead of <!--- and so on.
A trick i use is to open the xml file in internet explorer, or find a xml-validator online. It will usually tell you the line and offset of where the issue is.
First thing: you only need to include the Lua file once. Either in the .toc or in the .xml, but not both.
(Truthfully, you don't need the XML at all. If you're more comfortable learning with it, that's fine. Most people on these forums tend to prefer using only Lua, and bringing in XML only when strictly required.)
Second thing: there are no global "this" or "event" variables set automatically for you. That went away many, many patches ago; whatever you're using for a reference is badly outdated.
When you write <Stuff> blocks in XML, they get turned into Lua functions with some parameters already declared for you (listed here). If you want to have your XML blocks call functions defined in your Lua file, you need to pass those parameters along. Namely, "self", "event", and any event parameters (like the ones you're expecting to receive in "...").
I was mostly using the xml to help me visually see what the frames would end up looking like. I'm going to read through the link you put up and start making changes to work with the updated version.
For reference, here is how your XML would be translated into Lua. I left eveything in the same order you had it in your XML file, and added explanatory comments where I omitted or changed anything.
local frame = CreateFrame("Frame", "BidFrame1", UIParent)
frame:SetToplevel(true)
frame:SetMovable(true)
frame:EnableMouse(true)
frame:SetWidth(282)
frame:SetHeight(348)
frame:SetPoint("CENTER", -149, 71)
--
-- I removed the TitleRegion, because you don't need it,
-- because you explicitly enable dragging on your frame
-- and set OnDragStart and OnDragStop scripts.
--
frame:SetBackdrop({
edgeFile = [[Interface\DialogFrame\UI-DialogBox-Background]],
edgeSize = 32,
insets = { left = 11, right = 12, top = 12, bottm = 11 }
})
--
-- The following regions/children of your frame no longer
-- have global names. Instead of writing "FSTitle" in your
-- code, you would write "frame.titleText". This is faster,
-- and it's generally considered good practice to avoid
-- putting anything in the global namespace that doesn't
-- absolutely need to be there.
--
local titleText = frame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
titleText:SetText("Break It Down")
titleText:SetJustifyV("TOP")
titleText:SetWidth(250)
titleText:SetHeight(22)
titleText:SetPoint("TOPLEFT", 16, -15)
frame.titleText = titleText
local resultsText = frame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
resultsText:SetJustifyV("TOP")
resultsText:SetWidth(250)
resultsText:SetHeight(256)
resultsText:SetPoint("TOPLEFT", 16, -34)
frame.resultsText = resultsText
local closeButton = CreateFrame("Button", nil, frame, "UIPanelButtonTemplate")
closeButton:SetText("Close")
closeButton:SetWidth(75)
closeButton:SetHeight(23)
closeButton:SetPoint("TOPLEFT", 171, -296)
closeButton:SetScript("OnClick", function(self, mouseButton)
--
-- All "Button1_OnClick" did was hide the frame,
-- so I just wrote that here.
--
frame:Hide()
end)
frame.closeButton = closeButton
local resetButton = CreateFrame("Button", nil, frame, "UIPanelButtonTemplate")
resetButton:SetText("Reset Data")
resetButton:SetWidth(75)
resetButton:SetHeight(23)
resetButton:SetPoint("TOPLEFT", 32, -296)
resetButton:SetScript("OnClick", function(self, mouseButton)
--
-- Put the contents of "Button2_OnClick" here.
--
end)
frame.resetButton = resetButton
frame:RegisterForDrag("LeftButton")
--
-- Setting an "isMoving" flag on your frame doesn't do anything
-- on its own, so I removed it. It would only useful if other parts
-- of your code need to know if the frame is currently being moved.
--
frame:SetScript("OnDragStart", frame.StartMoving)
frame:SetScript("OnDragStop", frame.StopMovingOrSizing)
--
-- OnLoad scripts don't work for frames created in Lua, so any code
-- you need to run as soon as the frame is loaded should just go
-- here, in the main chunk.
--
frame:RegisterForEvent("ADDON_LOADED")
frame:RegisterForEvent("LOOT_OPENED")
--
-- Also, VARIABLES_LOADED is not an appropriate event for detecting
-- when the loading process is finished. It used to work for this, years
-- ago, but now it fires many times during the loading process, whenever
-- key bindings or game settings are loaded, and has nothing to do
-- with addons. Use PLAYER_LOGIN instead.
--
frame:RegisterForEvent("PLAYER_LOGIN")
--
-- I removed the "Addon is loaded!" chat message, because most
-- chat addons will wipe messages printed this early in the loading
-- sequence anyway, and it's generally considered spam to show
-- such messages every time the addon loads. If someone installed
-- your addon, they already know it's there. :)
--
-- If you want to add messages just for debugging, to help you
-- visualize what's going on, that's fine, but if you're using a chat
-- addon you may need to delay such messages until after the
-- PLAYER_LOGIN event has fired.
--
frame:SetScript("OnEvent", function(self, event, ...)
--
-- Put the contents of "Frame1_OnEvent" here.
--
end)
There are also a number of errors in your Lua. Here are a few, with things that need to be added in green, things that need to be removed in red, and things that I have no idea what they were intended to do in purple. After each code snippet, I've given a brief explanation.
function BIDFrame1_OnLoad([COLOR="SeaGreen"]self[/COLOR])
As was already mentioned, global variables are no longer set for events or scripts. Your code must accept the arguments that are passed directly to the relevant script. OnLoad scripts are given just one argument, a reference to the frame they're running on. Your other script handler functions suffer from the same problem.
[COLOR="seagreen"]local myResults = {}[/COLOR]
function Button2_OnClick()
[COLOR="#cc0000"]myResults = {}[/COLOR]
[COLOR="seagreen"]wipe(myResults)[/COLOR]
BIDFrame1:Update()
end
Your original code was creating a new table object every time the button was clicked; this eats up a significant amount of memory. Also, names like "myResults" are bad choices for global names, as they are not descriptive enough for in-game debugging, and are likely to conflict.
local function WorkResults()
for i = 1, GetNumLootItems() do
local itemName = select(2, GetLootSlotInfo(i))
local quantity = select(3, GetLootSlotInfo(i))
if not myResults[itemName] then
[COLOR="Purple"]MakeTableEntry(itemName)[/COLOR]
end
Firstly, MakeTableEntry doesn't exist in this scope, since it isn't defined yet when this section of code loads.
Secondly, the MakeTableEntry function is completely unneeded, and calls GetItemInfo for no apparent reason (it doesn't use the data returned by that function). Just replace the purple line above with this:
On a side note, since you don't appear to ever put anything into this table you're creating, so it probably doesn't need to be a table. If you're more specific about what kind of information you expect the myResults table to contain, we can probably be more helpful.
local function ShowResults()
if myResults > 0 then
for itemName, num in pairs(myResults[itemName]) do
if itemName = quantity then
FSResults:SetText(itemName.." - "..quantity);
end
end
end
You're missing an "end" in there, and proper indentation of your code would have made that obvious. Here's the same code with the indentation fixed:
local function ShowResults()
if myResults > 0 then
for itemName, num in pairs(myResults[itemName]) do
if itemName = quantity then
FSResults:SetText(itemName.." - "..quantity);
end
end
end
The missing "end" at the end is obvious now. :)
On a related note, the above code (even if the missing "end" is added) will result in only the last item showing on your frame, since you are just changing the contents of the results text for each item, not appending new information.
Also, to see if the two values are identical, you must use "a == b", with two equals-signs. A single equals-sign assigns a value:
local myVariable = "myValue"
Finally. I don't know where the "quantity" variable is supposed to come from, so this check will likely never pass, even if the other syntax stuff is fixed.
A simple (though inefficient) method to add information to the text instead of overwriting it would be to use string concatenation, appending each additional item followed by a linebreak:
local text = ""
for keyName, keyValue in pairs(myTable) do
text = text .. keyName .. "\n"
end
fontString:SetText(text)
Finally, secure-hooking CastSpell etc. shouldn't be necessary. If you want to know when the player starts casting a spell, register for the UNIT_SPELLCAST_SENT event. It only fires for the player unit, and it provides the spell ID, so you wouldn't need spell names at all (except maybe for display in your addon's UI).
local spellsToTrack = {
[13262] = true, -- Disenchant
[51005] = true, -- Milling
[31252] = true, -- Prospecting
}
frame:RegisterEvent("UNIT_SPELLCAST_START")
frame:SetScript("OnEvent", function(self, event, ...)
if event == "UNIT_SPELLCAST_START" then
local unit, spellName, _, _, spellID = ...
if unit == "player" and spellsToTrack[spellID] then
getContents = true
end
end
end)
Here I also created a table with a list of spell IDs to track; it's much easier (and faster) to look up "spellsToTrack[spellID]" than to individually check "if arg == value1 or arg == value2 or arg == value 3 then", and it makes it easier to add new spells in the future if you ever need/want to.
You're missing an "end" in there, and proper indentation of your code would have made that obvious. Here's the same code with the indentation fixed:
local function ShowResults()
if myResults > 0 then
for itemName, num in pairs(myResults[itemName]) do
if itemName = quantity then
FSResults:SetText(itemName.." - "..quantity);
end
end
end
The missing "end" at the end is obvious now. :)
Ugg, this is what I get for not using Notepad++ from the start. I was trying to shortcut things and use the AddonStudio thing. So far, it seems to be more trouble then it's worth. Back to the basics for me. As for what I'm wanting to show, I'd like to show the results of a session of milling/DE'ing/prospecting in a simple window. For example, if I need to prospect 30 stacks of ore for my guild and I forgot to check my bags for gems first. It'd be nice to have a simple visual to check and see what I've done. I found an old addon which did something similar but to the tooltip. I'm just trying to modify it and update it.
So what I'd end up seeing at the end of a boring day of clicking:
Amberjewel - 4
Carnelian - 12
Ember Topaz - 3
Zephyrite - 22
If I was more advanced at Addon coding, I'd love to see it sorted by gem type. Granted, if I was making it for just Cata and above mats, I could probably make a big framework of individual font strings. I'm hoping to also make it user friendly for lower levels just for fun.
Addon Studio hasn't worked properly since sometime in early Wrath, if not Burning Crusade, and even when it did work and its API was current (which was for about a week) it generated bloatcode.
Maybe it has been updated since then, but it doesn't matter; it is a tool that should never be used.
Now I can't get the frame to show back up to test my code. I tried adding a slash command to show the frame but it's not registering /breakitdown as a command.
-- Author : Kali
local PROSPECT_ID = 31252
local MILLING_ID = 51005
local DE_ID = 13262
local PROSPECT = GetSpellInfo(PROSPECT_ID)
local MILLING = GetSpellInfo(MILLING_ID)
local DE = GetSpellInfo(DE_ID)
local getContents = false
local version = "v20122101"
local pairs
local frame = CreateFrame("Frame", "BidFrame1", UIParent)
frame:SetToplevel(true)
frame:SetMovable(true)
frame:EnableMouse(true)
frame:SetWidth(282)
frame:SetHeight(348)
frame:SetPoint("CENTER", 0, 71)
frame:SetBackdrop({
edgeFile = [[Interface\DialogFrame\UI-DialogBox-Background]],
edgeSize = 32,
insets = { left = 11, right = 12, top = 12, bottm = 11 }
})
local titleText = frame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
titleText:SetText("Break It Down")
titleText:SetJustifyV("TOP")
titleText:SetWidth(250)
titleText:SetHeight(22)
titleText:SetPoint("TOPLEFT", 16, -15)
frame.titleText = titleText
local resultsText = frame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
resultsText:SetJustifyV("TOP")
resultsText:SetWidth(250)
resultsText:SetHeight(256)
resultsText:SetPoint("TOPLEFT", 16, -34)
frame.resultsText = resultsText
local closeButton = CreateFrame("Button", nil, frame, "UIPanelButtonTemplate")
closeButton:SetText("Close")
closeButton:SetWidth(75)
closeButton:SetHeight(23)
closeButton:SetPoint("TOPLEFT", 171, -296)
closeButton:SetScript("OnClick", function(self, mouseButton)
BidFrame1:Hide()
end)
frame.closeButton = closeButton
local resetButton = CreateFrame("Button", nil, frame, "UIPanelButtonTemplate")
resetButton:SetText("Reset Data")
resetButton:SetWidth(75)
resetButton:SetHeight(23)
resetButton:SetPoint("TOPLEFT", 32, -296)
resetButton:SetScript("OnClick", function(self, mouseButton)
myBIDResults = {}
wipe(myBIDResults)
BIDFrame1:Update();
end)
frame.resetButton = resetButton
frame:RegisterForDrag("LeftButton")
frame:SetScript("OnDragStart", frame.StartMoving)
frame:SetScript("OnDragStop", frame.StopMovingOrSizing)
frame:RegisterForEvent("ADDON_LOADED")
frame:RegisterForEvent("LOOT_OPENED")
frame:RegisterForEvent("PLAYER_LOGIN")
frame:SetScript("OnEvent", function(self, event, ...)
if event == "LOOT_OPENED" then
if getContents then
WorkResults()
end
end
end)
local function BIDHelp()
print("Show Break It Down : /breakitdown show")
end
local function handler (msg, editbox)
if msg == '' then
BIDHelp()
elseif msg == 'show' then
BidFrame1:Show()
end
end
SlashCmdList["BREAKITDOWN"] = handler;
SLASH_BREAKITDOWN1 = "/breakitdown"
local myBIDResults = {}
local lootIcon, lootName, lootQuantity, rarity, locked = GetLootSlotInfo(i);
local function WorkResults()
for i = 1, GetNumLootItems() do
local BIDitemName = GetLootSlotLink(i)
local BIDquantity = select(3, GetLootSlotInfo(i))
if not myBIDResults[BIDitemName] then
myBIDResults[BIDitemName] = {}
end
if myBIDResults[BIDitemName] then
myBIDResults[BIDitemName] == myBIDResults[BIDitemName] + BIDquantity
else
myBIDResults[BIDitemName] == BIDquantity
end
end
end
local function ShowResults()
local text = ""
if myBIDResults > 0 then
for BIDitemName, BIDquantity in pairs(myBIDResults) do
text = BIDitemName.." - "..BIDquantity"\n"
end
end
fontString:SetText(text)
end
local spellsToTrack = {
[13262] = true, -- Disenchant
[51005] = true, -- Milling
[31252] = true, -- Prospecting
}
frame:RegisterEvent("UNIT_SPELLCAST_START")
frame:SetScript("OnEvent", function(self, event, ...)
if event == "UNIT_SPELLCAST_START" then
local unit, spellName, _, _, spellID = ...
if unit == "player" and spellsToTrack[spellID] then
getContents = true
end
end
end)
1. Remove that 'local pairs' line, what's that supposed to be doing there?
(I'll answer that: It's destroying your ability to call a global function used to iterate tables by setting it to nil)
2. Remove the second parameter 'editbox' from your handler function.
There's 3 reasons you frame might not be showing:
a. No visible elements on it.
b. Your command handler is broken (but /run BidFrame1:Show() works)
c. You've dragged it off-screen.
There's no way that code didn't error in-game.
Make sure you have "show errors" checked in game options or even better get a dedicated addon like BugGrabber + BugSack.
I can't see lines in your snippet but after looking at the error you posted there's a couple lines that stand out.
= is the assignment operator.
== is the test for equality operator.
if myBIDResults[BIDitemName] then
myBIDResults[BIDitemName] == myBIDResults[BIDitemName] + BIDquantity
else
myBIDResults[BIDitemName] == BIDquantity
end
Both of those should be = not == (you're assigning a new value not testing for equality)
There might be more errors, those are just the 2 I spotted right away.
Like I said at the start of the post make sure you have a way to see lua errors in-game or you're coding "blind". :wink:
Edit: If your .toc file is still what shows here remove that Breakitdown line at the top,
it does nothing except tell the game to load a file named Breakitdown (no extension) that doesn't exist.
The first problem which cropped up is that my close button doesn't seem to work at all. I figured I'd start fixing the simple problems first.
Sweet and simple code. Funny story, it works when I'm also running my "Hello World" app which I did to familiarize myself with the new language. If I'm running my addon by itself, the button shows itself pressing down but the frame never hides.
That's the whole thing. Some of it is bits and pieces from other addons and some of it is mine. Mostly I've been working on creating a frame that shows the number of gems, pigments, and DE mats you end up getting in a large session. I figured I could add in general commands later, like a start recording type command (or button). At the moment, all that happens is the frame loads with all the labels and buttons in place. I can move it around. But it doesn't seem to do a thing.
I also have the following showing up in my FrameXML file.
1/26 18:52:56.714 Loading add-on BreakItDown
1/26 18:52:56.714 ** Loading table of contents Interface\AddOns\BreakItDown\BreakItDown.toc
1/26 18:52:56.714 Couldn't open Interface\AddOns\BreakItDown\BreakItDown
1/26 18:52:56.714 Interface\AddOns\BreakItDown\BreakItDown.lua:28: cannot use '...' outside a vararg function near '...'
1/26 18:52:56.714 ++ Loading file Interface\AddOns\BreakItDown\BreakItDown.xml
1/26 18:52:56.714 Interface\AddOns\BreakItDown\BreakItDown.lua:28: cannot use '...' outside a vararg function near '...'
1/26 18:52:56.714 [string "*:OnDragStart"]:2: function arguments expected near '='
1/26 18:52:56.714 [string "*:OnDragStop"]:2: function arguments expected near '='
There's already some obvious problems in the part you already posted,
but is better if we see the whole picture and go item by item.
'this' global for one is no longer valid so the template you used to start your addon is old.
Anyway, post your .xml (and .toc wouldn't hurt)
Ah, I was wondering if it was a lost in translation type of problem.
(Truthfully, you don't need the XML at all. If you're more comfortable learning with it, that's fine. Most people on these forums tend to prefer using only Lua, and bringing in XML only when strictly required.)
Second thing: there are no global "this" or "event" variables set automatically for you. That went away many, many patches ago; whatever you're using for a reference is badly outdated.
When you write <Stuff> blocks in XML, they get turned into Lua functions with some parameters already declared for you (listed here). If you want to have your XML blocks call functions defined in your Lua file, you need to pass those parameters along. Namely, "self", "event", and any event parameters (like the ones you're expecting to receive in "...").
for example using <!-- instead of <!--- and so on.
A trick i use is to open the xml file in internet explorer, or find a xml-validator online. It will usually tell you the line and offset of where the issue is.
I was mostly using the xml to help me visually see what the frames would end up looking like. I'm going to read through the link you put up and start making changes to work with the updated version.
As was already mentioned, global variables are no longer set for events or scripts. Your code must accept the arguments that are passed directly to the relevant script. OnLoad scripts are given just one argument, a reference to the frame they're running on. Your other script handler functions suffer from the same problem.
Your original code was creating a new table object every time the button was clicked; this eats up a significant amount of memory. Also, names like "myResults" are bad choices for global names, as they are not descriptive enough for in-game debugging, and are likely to conflict.
Firstly, MakeTableEntry doesn't exist in this scope, since it isn't defined yet when this section of code loads.
Secondly, the MakeTableEntry function is completely unneeded, and calls GetItemInfo for no apparent reason (it doesn't use the data returned by that function). Just replace the purple line above with this:
On a side note, since you don't appear to ever put anything into this table you're creating, so it probably doesn't need to be a table. If you're more specific about what kind of information you expect the myResults table to contain, we can probably be more helpful.
You're missing an "end" in there, and proper indentation of your code would have made that obvious. Here's the same code with the indentation fixed:
The missing "end" at the end is obvious now. :)
On a related note, the above code (even if the missing "end" is added) will result in only the last item showing on your frame, since you are just changing the contents of the results text for each item, not appending new information.
Also, to see if the two values are identical, you must use "a == b", with two equals-signs. A single equals-sign assigns a value:
Finally. I don't know where the "quantity" variable is supposed to come from, so this check will likely never pass, even if the other syntax stuff is fixed.
A simple (though inefficient) method to add information to the text instead of overwriting it would be to use string concatenation, appending each additional item followed by a linebreak:
Finally, secure-hooking CastSpell etc. shouldn't be necessary. If you want to know when the player starts casting a spell, register for the UNIT_SPELLCAST_SENT event. It only fires for the player unit, and it provides the spell ID, so you wouldn't need spell names at all (except maybe for display in your addon's UI).
Here I also created a table with a list of spell IDs to track; it's much easier (and faster) to look up "spellsToTrack[spellID]" than to individually check "if arg == value1 or arg == value2 or arg == value 3 then", and it makes it easier to add new spells in the future if you ever need/want to.
Ugg, this is what I get for not using Notepad++ from the start. I was trying to shortcut things and use the AddonStudio thing. So far, it seems to be more trouble then it's worth. Back to the basics for me. As for what I'm wanting to show, I'd like to show the results of a session of milling/DE'ing/prospecting in a simple window. For example, if I need to prospect 30 stacks of ore for my guild and I forgot to check my bags for gems first. It'd be nice to have a simple visual to check and see what I've done. I found an old addon which did something similar but to the tooltip. I'm just trying to modify it and update it.
So what I'd end up seeing at the end of a boring day of clicking:
Amberjewel - 4
Carnelian - 12
Ember Topaz - 3
Zephyrite - 22
If I was more advanced at Addon coding, I'd love to see it sorted by gem type. Granted, if I was making it for just Cata and above mats, I could probably make a big framework of individual font strings. I'm hoping to also make it user friendly for lower levels just for fun.
Maybe it has been updated since then, but it doesn't matter; it is a tool that should never be used.
(I'll answer that: It's destroying your ability to call a global function used to iterate tables by setting it to nil)
2. Remove the second parameter 'editbox' from your handler function.
3. What does /run BidFrame1:Show() do?
Well, I named the frame BIDFrame1 so I assumed it would show the frame since it's currently hidden.
There's 3 reasons you frame might not be showing:
a. No visible elements on it.
b. Your command handler is broken (but /run BidFrame1:Show() works)
c. You've dragged it off-screen.
Here is the information from my FrameXML log.
There's no way that code didn't error in-game.
Make sure you have "show errors" checked in game options or even better get a dedicated addon like BugGrabber + BugSack.
I can't see lines in your snippet but after looking at the error you posted there's a couple lines that stand out.
= is the assignment operator.
== is the test for equality operator.
Both of those should be = not == (you're assigning a new value not testing for equality)
There might be more errors, those are just the 2 I spotted right away.
Like I said at the start of the post make sure you have a way to see lua errors in-game or you're coding "blind". :wink:
Edit: If your .toc file is still what shows here remove that Breakitdown line at the top,
it does nothing except tell the game to load a file named Breakitdown (no extension) that doesn't exist.