• 0

    posted a message on Global & SavedVariables Help
    I am the project manager of DejaView and am looking to implement saved variables for additional features I have planned:

    To-Do
    • Implement saved variables.
    • Implement default settings.
    • Implement object scaling sliders.

    How do I initially use these defaults and how do I save the changes to the table from dragging frames into the desired position when the player logs out?

    So far I have used a method Phanx has shown in several places to get my Saved Variables Per Character table filled but it seems to reset to the default with each login. I have manually edited the saved variable file and changed the values and it resets to these defaults when I log in.

    But the table is filled and I am not using the variables, how do I use the variables such as dvpetdefault? I have used them successfully by just declaring globals outside of the DVDefaultConfig table but I want to save them to the DejaViewDBPC table:

    dvbdefault = {0, 0}, 
    dvdbdefault = {0, -60},
    ...
    ...


    Here is what I have:

    My toc:

    ## SavedVariables: DejaViewDB
    ## SavedVariablesPerCharacter: DejaViewDBPC
    
    DejaView.lua
    DejaUnitFrames.lua
    DejaBars.lua
    


    My Lua:

    DejaViewDB = {};
    DejaViewDBPC = {};
    DVDefaultConfig = {
    	dvbdefault = {0, 0}, 
    	dvdbdefault = {0, -60},
    	Minimapdefault = {0, 0},
    	dvpetdefault = {0, 6},
    	dvstancedefault = {0, 6},
    	dvrsbdefault = {0, 0},
    	dvmmdefault = {0, 6},
    	statdefault = {0, 0},
    	dvbagdefault = {0, 0},
    	dvgttdefault = {0, 0},
    	DebuffButton1default = {0, -6},
    };
    
    local function CopyDefaults(DVDefaultConfig, DejaViewDBPC)
    	if type(DVDefaultConfig) ~= "table" then return {} end
    	if type(DejaViewDBPC) ~= "table" then DejaViewDBPC = {} end
    	for k, v in pairs(DVDefaultConfig) do
    	if type(v) == "table" then
    		DejaViewDBPC[k] = CopyDefaults(v, DejaViewDBPC[k])
    	elseif type(v) ~= type(DejaViewDBPC[k]) then
    		DejaViewDBPC[k] = v
    	end
    	end
    	return DejaViewDBPC
    end
    
    local dejaview = CreateFrame("Frame", "DejaView")
    	dejaview:RegisterEvent("ADDON_LOADED")
    	dejaview:SetScript("OnEvent", function(self, event, arg1)
    	if event == "ADDON_LOADED" and arg1 == "DejaView" then
    		DejaViewDBPC = CopyDefaults(DVDefaultConfig, DejaViewDBPC)
    		self:UnregisterEvent("ADDON_LOADED")
    	end
    end)


    I am wanting to use the variables this way, in a different lua file which is why I made it global, for instance with DejaBars.lua use dvpetdefault for the x, y position of dvpetframe:

    DVDefaultConfig = {
    	...
    	dvpetdefault = {0, 6},
    	...
    };
    
    -- DVPetFrame
    local dvpetframe=CreateFrame("Frame", "dvpetframe", UIParent)
    	dvpetframe:SetFrameStrata("HIGH")
    	dvpetframe:SetClampedToScreen(true)
    	dvpetframe:SetPoint("BOTTOMLEFT", MultiBarBottomRightButton1, "TOPLEFT, dvpetdefault)
    	dvpetframe:SetMovable(true)
    	dvpetframe:EnableMouse(true)
    	dvpetframe:RegisterForDrag("RightButton")
    	dvpetframe:SetWidth(318)
    	dvpetframe:SetHeight(38)
    	dvpetframe:Hide()


    Thank you for your time and assistance.
    Posted in: Need Help?
  • 0

    posted a message on GBank Repair Function Issue
    Yes, I need to follow trails more. I was looking at it and almost looked up the guild repair button... Once again I need to think more broadly and less specific and reuse what is there. A little more patience on my part would help a lot too.

    I will work to not be back unless I have exhausted all means and have given it a few days to knock around in my head.

    Thanks again for your help and lessons. :)
    Posted in: Need Help?
  • 0

    posted a message on GBank Repair Function Issue
    Fair enough man . I thought I did figure it out which is why I added:

    [HTML]local cost = GetRepairAllCost()[/HTML]

    I tried changing cost to GetRepairAllCost() before I posted a reply to your original response and it did not work. Perhaps I had some other mistakes in there but it gave the exact same error.

    I asked if there was a logic reasons, which apparently there is because the code is almost exactly like the original arena junkies code. I will now sift through the original posted code of mine and your fixed code once I verify it actually works and then I will figure out the logic differences and learn something.

    I have been kinda worried you would feel this way and I apologize for overstaying my welcome.

    I appreciate your help and thank you for your time.
    Posted in: Need Help?
  • 0

    posted a message on GBank Repair Function Issue
    I added this and I think it will work:

    [HTML]local cost = GetRepairAllCost()[/HTML]

    Dont have any broken gear to check tho, lol.
    Posted in: Need Help?
  • 0

    posted a message on GBank Repair Function Issue
    Is it just the logic that has to be worked out, compared to the original posted code?
    Posted in: Need Help?
  • 0

    posted a message on GBank Repair Function Issue
    Getting an error I cant figure out. Looks like [HTML]if amount > cost then[/HTML]

    Eroor:

    [HTML]Message: Interface\AddOns\DejaUI\DejaTest.lua:18: attempt to compare nil with number
    Time: 09/17/12 20:32:46
    Count: 1
    Stack: Interface\AddOns\DejaUI\DejaTest.lua:18: in function <Interface\AddOns\DejaUI\DejaTest.lua:5>

    Locals: repairAllCost = 1310
    canRepair = 1
    amount = 250000000
    guildBankMoney = 865476636
    (*temporary) = nil
    (*temporary) = 250000000
    (*temporary) = 865476636
    (*temporary) = "attempt to compare nil with number"[/HTML]

    Code:

    [HTML]--Repair
    local r = CreateFrame("Frame")
    r:RegisterEvent("MERCHANT_SHOW")

    r:SetScript("OnEvent", function()

    if CanMerchantRepair() then
    local repairAllCost, canRepair = GetRepairAllCost()
    if canRepair and repairAllCost > 0 then
    if CanGuildBankRepair() then
    local amount = GetGuildBankWithdrawMoney()
    local guildBankMoney = GetGuildBankMoney()
    if amount == -1 then
    amount = guildBankMoney
    else
    amount = min(amount, guildBankMoney)
    end
    if amount > cost then
    RepairAllItems(1)
    print("Repaired all items from guild bank funds.")
    return
    else
    print("Insufficient guild bank funds to repair.")
    end
    end
    if GetMoney() > repairAllCost then
    RepairAllItems()
    print("Repaired all items from personal funds.")
    return
    else
    print("Insufficient personal funds to repair.")
    end
    end
    end
    end)[/HTML]
    Posted in: Need Help?
  • 0

    posted a message on GBank Repair Function Issue
    I have this code I got from Arena Junkies. It works fine if you have gold withdrawal from the bank. it does not work if you have REPAIR withdrawal from the bank.

    Is there a function like GetGuildBankWithdrawMoney() for repairs?

    Thanks for your help.

    [HTML]--Sell Junk
    local g = CreateFrame("Frame")
    g:RegisterEvent("MERCHANT_SHOW")

    g:SetScript("OnEvent", function()
    local bag, slot
    for bag = 0, 4 do
    for slot = 0, GetContainerNumSlots(bag) do
    local link = GetContainerItemLink(bag, slot)
    if link and (select(3, GetItemInfo(link)) == 0) then
    UseContainerItem(bag, slot)
    end
    end
    end

    if(CanMerchantRepair()) then
    local cost = GetRepairAllCost()
    if cost > 0 then
    local money = GetMoney()
    if IsInGuild() then
    local guildMoney = GetGuildBankWithdrawMoney()
    if guildMoney > GetGuildBankMoney() then
    guildMoney = GetGuildBankMoney()
    end
    if guildMoney > cost and CanGuildBankRepair() then
    RepairAllItems(1)
    print(format("|cfff07100Repair cost covered by G-Bank: %.1fg|r", cost * 0.0001))
    return
    end
    end
    if money > cost then
    RepairAllItems()
    print(format("|cffead000Repair cost: %.1fg|r", cost * 0.0001))
    else
    print("Not enough gold to cover the repair cost.")
    end
    end
    end
    end)[/HTML]
    Posted in: Need Help?
  • 0

    posted a message on World Marker Drop-Down Blocking
    Ok ok so I feel like an idiot now, if I have the frame shown and set up when I enter combat everything works fine and dandy I am marking away etc. It is the actual showing hiding of the frame in combat that I am looking at. Gah so stupid.

    Ok so hopefully that bell ringing will help, lol.
    Posted in: Need Help?
  • 0

    posted a message on Whisper Tabs, Chat Frames 11+ Revert To Default
    Switching over now, thanks :)
    Posted in: Need Help?
  • 0

    posted a message on Hiding Micro Buttons Via Mouseover Problems
    Thanks
    :)
    Posted in: Need Help?
  • 0

    posted a message on World Marker Drop-Down Blocking
    I completely forgot about the pre and psot clicks. I will research them, thank you .

    As for the type, is there a type for only right click? I looked at the charts and didn't see one.
    Posted in: Need Help?
  • 0

    posted a message on World Marker Drop-Down Blocking
    What if I set up an onclick function:

    [HTML]function DejaMarkButton_OnClick(self)
    PlaySound("UChatScrollButton")
    end[/HTML]

    Get rid of the OnClick script and isntead send each button to the function:

    [HTML]Button:SetScript("OnClick", DejaMarkButton_OnClick)[/HTML]

    and then hooksecure?
    [HTML]
    hooksecurefunction("ButtonClicks", DejaMarkButton_OnClick)[/HTML]
    Posted in: Need Help?
  • 0

    posted a message on Hiding Micro Buttons Via Mouseover Problems
    I get this error man:

    [HTML]
    Message: Interface\AddOns\DejaUI\DejaBars.lua:26: attempt to call global 'hooksecurefunction' (a nil value)
    Time: 09/11/12 14:34:46
    Count: 1
    Stack: Interface\AddOns\DejaUI\DejaBars.lua:26: in main chunk

    Locals: MICRO_BUTTONS = {
    1 = "CharacterMicroButton"
    2 = "SpellbookMicroButton"
    3 = "TalentMicroButton"
    4 = "AchievementMicroButton"
    5 = "QuestLogMicroButton"
    6 = "GuildMicroButton"
    7 = "PVPMicroButton"
    8 = "LFDMicroButton"
    9 = "EJMicroButton"
    10 = "CompanionsMicroButton"
    11 = "MainMenuMicroButton"
    12 = "HelpMicroButton"
    }
    f = MicroButtonHolder {
    0 = <userdata>
    }
    ReparentMicroButtons = <function> defined @Interface\AddOns\DejaUI\DejaBars.lua:13
    (*temporary) = nil
    (*temporary) = "UpdateMicroButtonsParent"
    (*temporary) = <function> defined @Interface\AddOns\DejaUI\DejaBars.lua:13
    (*temporary) = "attempt to call global 'hooksecurefunction' (a nil value)"
    [/HTML]
    Posted in: Need Help?
  • 0

    posted a message on Whisper Tabs, Chat Frames 11+ Revert To Default
    I am using Word Pad. I have corrected a few things in the edit box which is probably my issue. HMm I will pay close attention and see what the culprit is. Thanks for your patience with me.
    Posted in: Need Help?
  • 0

    posted a message on World Marker Drop-Down Blocking
    So I revamped some and now have this.

    How do I "create buttons out of combat"?

    The "SecureActionsButtonTemplate" seems to inherently block the use of the button or perhaps the response to button clicks in combat.

    I have tried a couple of other methods to use the dropdown menu such as RunMacro and the first example I have psoted here. Setting attributes is the only method that works. Doesn't that require "SecureActionsButtonTemplate" as per its template, as in you have to define attributes?

    here is my code change. I set attributes outside of the OnClick and that solved the issue where I had to click twice, heh, once to set and once to use.

    Also, if I do not try to use the world markers, IE make it for the target markers only, then it works in and out of combat. If I get rid of the "SecureActionsButtonTemplate" then I do not have anything to define. Should I use a different template?

    Thanks in advance.

    [HTML]BINDING_HEADER_DejaMark = "Deja Mark";
    BINDING_NAME_DejaMark = "Show Markers(Hold)";

    local DejaMarkFrame = CreateFrame("Frame","DejaMarkFrame",UIParent)
    DejaMarkFrame:SetSize(100,100)

    local t = DejaMarkFrame:CreateTexture(nil,"BACKGROUND")
    t:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Background")
    t:SetAllPoints(DejaMarkFrame)
    DejaMarkFrame.texture = t

    DejaMarkFrame:SetPoint("CENTER",0,0)
    DejaMarkFrame:Hide()

    --Diamond Marks Raid Marker 3 World Marker 3
    local WMDiamond = CreateFrame("BUTTON", "WorldMarker3Diamond",DejaMarkFrame, "SecureActionButtonTemplate")
    WMDiamond:SetSize(33,33)
    WMDiamond:SetPoint("TOPRIGHT",0,0)
    WMDiamond:RegisterForClicks("AnyUp")
    WMDiamond:SetNormalTexture("Interface\\TargetingFrame\\UI-RaidTargetingIcon_3.png")
    WMDiamond:SetAlpha(0.5)
    WMDiamond:SetScript("OnEnter", function(self)
    self:SetAlpha(1)
    end)
    WMDiamond:SetScript("OnLeave", function(self)
    self:SetAlpha(0.5)
    end)
    WMDiamond:SetAttribute("type", "macro")
    WMDiamond:SetAttribute("macrotext1", "/wm 3")

    WMDiamond:HookScript("OnClick", function(self, button)
    if(button=="LeftButton") then
    PlaySound("UChatScrollButton")
    else
    PlaySound("UChatScrollButton")
    SetRaidTargetIcon("target", 3)
    end
    end)

    function DejaMark_HotkeyPressed(keystate)
    KeyHeld = (keystate=="down")
    if KeyHeld then
    DejaMarkShowIcons()
    else
    DejaMarkFrame:Hide()
    end
    end

    function DejaMarkShowIcons()
    local X, Y = GetCursorPosition()
    local Scale = UIParent:GetEffectiveScale()
    DejaMarkFrame:SetPoint("CENTER", UIParent, "BOTTOMLEFT", X / Scale, Y / Scale)
    DejaMarkFrame:Show()
    end[/HTML]
    Posted in: Need Help?
  • To post a comment, please or register a new account.