1. #1
    Deleted

    [lua] Minimap move "OnEvent"

    hi all,

    i'm working on my minimap and i wonder if it's possible to move it with an "OnEvent" sript or something else.
    so what it should do is, move say 50px down when i have a target and 50px up when i have no target.

    what i've got looks somehow totally wrong

    Code:
    Minimap:ClearAllPoints()
    Minimap:RegisterEvent("PLAYER_TARGET_CHANGED")
    Minimap:SetSize(UIParent:GetWidth()*0.12, UIParent:GetWidth()*0.12)
    
    Minimap:SetScript("OnEvent", function(frame, event)
    if event == "PLAYER_TARGET_CHANGED" and (UnitExists("target"))
        then
            Minimap:SetPoint("TOPRIGHT",-UIParent:GetWidth()*0.01,-UIParent:GetHeight()*0.08)
    elseif event == "PLAYER_TARGET_CHANGED" and (UnitExists(nil))
        then
            Minimap:SetPoint("TOPRIGHT",-UIParent:GetWidth()*0.01,-UIParent:GetHeight()*0.02)
        end
    end)
    cant somebody please help or give any direction

  2. #2
    Code:
    (UnitExists(nil))
    this will always be false, as the nil unit never exists. you're probably looking for
    Code:
    not UnitExists("target")
    (this is redundant anyways as the previous if statement already checked this)

    also, realize that by setting the actual Minimap's OnEvent handler, you're overriding its original one, so you've probably broken much of the Minimap's functionality. You probably want to create your own frame for the OnEvent handler.

    and finally, you haven't explained what exactly is "totally wrong"

  3. #3
    Deleted
    :HookScript("OnEvent",...) if you don't want to break existing functionality.

    However, you probably want a separate frame that is only registered for PLAYER_TARGET_CHANGED, yes.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •