View Single Post
08-02-20, 07:33 PM   #7
Walkerbo
A Cobalt Mageweaver
 
Walkerbo's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 233
Hi actually

I have made some progress on this brick wall.

Now my toc looks like this;
Toc
Lua Code:
  1. ## Title: AAA |cffff0000 Testing Ground
  2. ## Interface: 80300
  3. ## Notes: |cffff0000 Testing Ground
  4. ## Version: AAA
  5. ## Date: Monday 3 August 2020
  6. ## SavedVariables: TableOfItems

AAA.lua
Lua
Lua Code:
  1. local itemName, itemLink, itemID
  2.  
  3. if not TableOfItems then
  4.     TableOfItems = {}
  5. end
  6.  
  7. local function addItemToTable(itemID)
  8.     print("add item function fired", itemID)
  9.     for k, v in pairs(TableOfItems) do
  10.         if v == itemID then
  11.             print("Item all ready listed")
  12.         else
  13.             table.insert(TableOfItems, 1, itemID)
  14.             print("Item added to list")
  15.         end
  16.     end
  17. end
  18.  
  19. SLASH_MYTEST1 = "/qwe"
  20. function SlashCmdList.MYTEST(msg, editbox)
  21.     print("slash command fired")
  22.     if #TableOfItems == 0 then
  23.         print("empty table")
  24.     else
  25.         for k, v in pairs(TableOfItems) do
  26.             print("item", k, v)
  27.         end
  28.     end
  29. end
  30.  
  31. local btn = CreateFrame("BUTTON", "myTest")
  32. SetBindingClick("F5", "myTest", "b1")
  33. SetBindingClick("BUTTON2", "myTest", "b2")
  34. SetBindingClick("G", "myTest", "b3")
  35. btn:SetScript("OnClick", function(self, button)
  36.     GameTooltip:HookScript("OnTooltipSetItem", function(self)
  37.             itemName, itemLink = self:GetItem()
  38.             itemID = tonumber(strmatch(itemLink, "item:(%d+):"))
  39.         end)
  40.     if button == "b1" then
  41.         addItemToTable(itemID)
  42.         print("F5 button clicked", itemLink, itemID)
  43.     elseif button == "b2" then
  44.         print("mouse button 2 clicked")
  45.     elseif button == "b3" then
  46.         print("G button clicked")
  47.     end
  48. end)
Now for some reason when I load in there are no errors showing on bugsack yet the button presses do nothing until I do a /reload.

Also adding the itemID to a table does not work; my prints show the slash command and add item functions are being fired yet no item is saved to the table.

I have probably made a noob mistake but I have not been able to nut this out.

Any further help would be great.
  Reply With Quote