• 0

    posted a message on Check if i am raid leader or assistant

    Does this work in random battlegrounds. What i wonder is if a random battleground is a raid Group?

     

    found what was wrong

     

    local playerName = UnitName("playerName")    --- shall be

    local playerName = UnitName("player")

     

    tyvm for tip

    Have a great new year

    Posted in: Lua Code Discussion
  • 0

    posted a message on Check if i am raid leader or assistant

    I am trying to check if i am raid leader or assistant in a raid Group. I was thinking of using GetRaidRosterInfo().

    It is the rank that gives me the information i need. 2=raid leader, 1=assistant and 0=all other players

    ex.

    if (GetRaidRosterInfo(self,rank,_,_,_,_,_,_,_,_,_)==2 or GetRaidRosterInfo(self,rank,_,_,_,_,_,_,_,_,_)==1) then

            ... some code

     

    But i cant do like this so my question is how the code will look like to get information from GetRaidRosterInfo()

    Posted in: Lua Code Discussion
  • 0

    posted a message on event timers

    Hi

    i have an addon called BGCallouts that reports for battlegrounds if a capping object need help or is safe (in Arathi Basin for ex. Blacksmith is safe.)

    Now i want to add a timer for that so it says how long iti is before it get fully capped. I know there is many good addon that do that but i want it on my addon too. Where can i find the API for getting the timers on capped object. I think its not so easy but if i can get an start it will help.

    Posted in: Lua Code Discussion
  • 0

    posted a message on Call an function from another Lua file
    Hi
    i am after a confirmation if i am right how to call a funtion from Another Lua file.
    This is how i didi it. I maked a table and put the function in it and put all in namespace.cf.
    Am i doing right?

    File BGCallouts.lua
    ============
    local ADDON_NAME, namespace = ...
    local cf = namespace.cf
    local BGFrame = {"ab","dwg","tbfg","eots","ssm"}
    ... some code
    cf.createFrames(BGFrame)
    


    and
    Battlegrounds.lua
    ===========
    local ADDON_NAME, namespace = ...
    local L = namespace.L
    local cf = {}
    namespace.cf = cf
    ... some code
    function cf.createFrames(name)
    .. some code
    end
    
    Posted in: Need Help?
  • 0

    posted a message on Convert String to table?
    Hi
    i am confused. I have "L" as a my localised strings (you helped me alot with that).
    1. Should i create a new Metatable as i did with "L" (using rawset...?) or can i create just a table ( i also seen you can have Modules but i dont know what that is)?
    2. Should i also create a new namespace ?
    3. Is it possible to get out the information in the table in same order they are put in? Now the addon swap order so my buttons is not where i would like to have them?

    Hope my questions is relevant as i dont really understand this with namespace and modules and tables.
    Posted in: Need Help?
  • 0

    posted a message on Convert String to table?
    Hi,
    i solved it this way. I put the local tables in main table.

    1. Do i have to have a counter to get lenght of each subtable?
    OBS! 2. The Icons is not showing up in same order as in table. Can i fix that? OBS! important

    function L.createFrames()
    	L.BGFrame = {ab = {farm = "Farm",mine = "Mine",blacksmith = "Blacksmith",lumbermill = "Lumber Mill",stable = "Stable"},
    				dwg = {pandaren = "Pandaren Mine",center = "Center Mine",goblin = "Goblin Mine"},
    				tbfg = {mine = "Mine",lighthouse = "Lighthouse",waterworks = "Waterworks"},
    				eots = {felreaver = "Fel Reaver ruins",magetower = "Mage tower",draenei = "Draenei ruins",bloodelf = "Blood Elf tower",flag = "Flag at middle"},
    				ssm = {lava = "Lava cart",oil = "Oil cart",lake = "Lake cart"}
    				}	
    	for i,v in next,L.BGFrame do
    		L.BGFrame[i] = CreateFrame("FRAME", i, UIParent)
    		SetupBGFrame(L.BGFrame[i])
    		local count = 0
    		for j,w in next,v do
    			AddLocationButton(L.BGFrame[i], w, j)
    			count = count + 1
    		end
    		if (count==5) then
    			L.BGFrame[i]:SetSize(58, 218)
    		else
    			L.BGFrame[i]:SetSize(58, 138)
    		end
    	end
    end
    Posted in: Need Help?
  • 0

    posted a message on Convert String to table?
    Hi
    I try to add image and name to my buttons on a frame. The problem in the code are that variable v is a string and i get an error for it wants an table. Is there a possibility to convert the string to a table. v Points to string 'ab' but i want it to point to table ab {}????

    function L.createFrames()
    	L.BGFrame = {"ab","eots","dwg","tbfg","ssm"}
    	local ab = {farm = "Farm",mine = "Mine",...}
    	local dwg = {pandaren = "Pandaren Mine",...}
    	local tbfg = {mine = "Mine",lighthouse = "Lighthouse",...}
    	local eots = {felreaver = "Fel Reaver ruins",...}
    	local ssm = {lava = "Lava cart",oil = "Oil cart",lake = "Lake cart"}
    	
    	for i,v in pairs(L.BGFrame) do
    		L.BGFrame[i] = CreateFrame("FRAME", v, UIParent)
    		SetupBGFrame(L.BGFrame[i])
    		if (v=='ab' or v=='eots') then
    			L.BGFrame[i]:SetSize(58, 218)
    		else
    			L.BGFrame[i]:SetSize(58, 138)
    		end
    		for j,w in pairs(v) do                                ---------->>> here is my problem
    			AddLocationButton(L.BGFrame[i], w, j)
    		end
    	end
    end
    Posted in: Need Help?
  • 0

    posted a message on Stuck on Tables
    I think i solved it myself. If u are interessted to see how download my addon 'BGCallouts'
    Posted in: Need Help?
  • 0

    posted a message on Stuck on Tables
    Hi
    i have a problem using tables. My addon has worked but then i realized that my tables didnt send right value . Before i got a "tablenumber" of some sort and now i try to create Frames with names as 'ab', 'eots' etc... In my main file i using namespace 'L' to call for function createFrames().

    Question 1:
    I want to set up the created Frames in same namespace 'L' for use in main file. So her is the code and i dont know how to set up L.BGFrame or if is is even nessessary since the name is same as in bgframe...????

    Question 2
    in function setupBGframe i get stuck on setMovable() even if it prints out 'ab'???

    function L.createFrames()
    	local bgframe = {"ab","eots","dwg","tbfg","ssm"}
    	L.BGFrame = {}
    	for i,v in pairs(bgframe) do
    		L.BGFrame[i] = CreateFrame("FRAME", v, UIParent)
    		SetupBGFrame(v)
    
    
    local function SetupBGFrame(frame)
    	print(frame)
       frame:SetMovable(true)
       frame:EnableMouse(true)
    


    PS! tables in lua is a pain. DS!

    /thanks Niclas
    Posted in: Need Help?
  • 0

    posted a message on Frame not visible
    Hi
    ofc it was my real code.. i am not a pro coder but i couldnt find anything else that affected the code. Now it works and i am happy and thank you very much for taking your time to help me. /hug
    Posted in: Lua Code Discussion
  • 0

    posted a message on Frame not visible
    Hi
    I solved using Backdrop.. it was hard to find "UI-DialogBox-<whatever>" that really linked as i should.
    Do you have a list of what possible "backdrop textures" that is avaliable?

    local function SetupBGFrame(frame)
    frame:SetMovable(true)
    frame:EnableMouse(true)
    frame:RegisterForDrag("LeftButton")
    frame:SetScript("OnDragStart", frame.StartMoving)
    frame:SetScript("OnDragStop", frame.StopMovingOrSizing)
    frame:SetPoint("CENTER", UIParent, "CENTER")
    -- The code below makes the frame visible
    frame:SetBackdrop({
    bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background-Dark", tile = true, tileSize = 20,
    edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border", edgeSize = 32,
    insets = { left = 10, right = 10, top = 10, bottom = 10 }
    })
    frame:SetBackdropColor(0.8,0.8,0.8,1)
    frame:SetBackdropBorderColor(0.8,0.8,0.8,1)
    return frame
    end
    Posted in: Lua Code Discussion
  • 0

    posted a message on Frame not visible
    It do not work.. can it be because i play LIVE version of Legion and not PTR version
    Posted in: Lua Code Discussion
  • 0

    posted a message on Frame not visible
    It still don't work.. and i don't know where to look.. Do you have Another idea?
    Posted in: Lua Code Discussion
  • 0

    posted a message on Frame not visible
    Hi
    thanks now my addon is up to date and i have no bugs in it. But the frame is still green or not visible... Can it have something to do with

    frame.texture = frame:CreateTexture("ARTWORK")

    You said ...File path incorrect, unsupported dimensions, unsupported file-type, etc.

    /thanks
    Posted in: Lua Code Discussion
  • 0

    posted a message on Frame not visible
    Hi this is for my wow addon BGCallouts
    In last patch 7.3 my frame is not visible anymore. Also it says that mu addon is out of date but i have no bugs in it. should i wait or can u help me solve this?

    If i change the values in frame.texture:SetTexture(0, 0, 0, 1) the frame turns green but i want it black,

    Toc file have this row
    =============
    ## Interface: 70300

    Here i creat my frame:
    ===============
    local function SetupBGFrame(frame)
    frame:SetMovable(true)
    frame:EnableMouse(true)
    frame:RegisterForDrag("LeftButton")
    frame:SetScript("OnDragStart", frame.StartMoving)
    frame:SetScript("OnDragStop", frame.StopMovingOrSizing)
    -- frame:SetPoint("CENTER", UIParent, "CENTER")
    -- The code below makes the frame visible
    frame.texture = frame:CreateTexture("ARTWORK")
    frame.texture:SetAllPoints()
    frame.texture:SetTexture(0, 0, 0, 1)
    return frame
    end
    Posted in: Lua Code Discussion
  • To post a comment, please or register a new account.