WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Graphics Help (https://www.wowinterface.com/forums/forumdisplay.php?f=14)
-   -   lua problem (https://www.wowinterface.com/forums/showthread.php?t=36303)

Quokka 10-27-10 07:25 AM

lua problem
 
Why does this not work.
anyone know how to fix it

Code:

A1 = CreateFrame("Frame", nil, self)
A1:SetParent(UIParent)
A1:SetFrameStrata(BACKGROUND)
A1:SetBackdrop({bgFile = "Interface\\AddOns\\AI-Suite\\Textures\\A1.tga"})
A1:SetHeight(80)
A1:SetWidth(512)
A1:SetPoint("BOTTOM",-0,-1);
A1:SetFrameLevel(0)

A2 = CreateFrame("Frame", nil, self)
A2:SetParent(A1)
A2:SetFrameStrata(BACKGROUND)
A2:SetBackdrop({bgFile = "Interface\\AddOns\\AI-Suite\\Textures\\A1L.tga"})
A2:SetHeight(80)
A2:SetWidth(128)
A2:SetPoint("LEFT",0,-1);
A2:SetFrameLevel(0)

A3 = CreateFrame("Frame", nil, self)
A3:SetParent(A1)
A3:SetFrameStrata(BACKGROUND)
A3:SetBackdrop({bgFile = "Interface\\AddOns\\AI-Suite\\Textures\\A1R.tga"})
A3:SetHeight(80)
A3:SetWidth(128)
A3:SetPoint("RIGHT",0,-1);
A3:SetFrameLevel(0)

any sugestions

Rilgamon 10-27-10 07:51 AM

Code:

A1 = CreateFrame("Frame", nil, self)
A1:SetParent(UIParent)

The third arg to createframe is the parentframe.

Replace your two lines with

Code:

A1 = CreateFrame("Frame", nil, UIParent)

Quokka 10-27-10 01:31 PM

Got the normal state working.
But I must be missing something.

anyone knows what to do with the events

Code:

AI1 = CreateFrame("Frame", nil, UIParent)
AI1:SetFrameStrata(BACKGROUND)
if UnitInVehicle("player") then
        AI1:SetBackdrop({bgFile = "Interface\\AddOns\\AI-Suite\\Art\\V1.tga"})
else
        AI1:SetBackdrop({bgFile = "Interface\\AddOns\\AI-Suite\\Art\\A1.tga"})
end
AI1:SetHeight(80)
AI1:SetWidth(512)
AI1:SetPoint("BOTTOM",-0,-1)
AI1:SetFrameLevel(0)

if not UnitInVehicle("player") then
        AI2 = CreateFrame("Frame", nil, UIParent)
        AI2:SetFrameStrata(BACKGROUND)
        AI2:SetBackdrop({bgFile = "Interface\\AddOns\\AI-Suite\\Art\\A1L.tga"})
        AI2:SetHeight(80)
        AI2:SetWidth(128)
        AI2:SetPoint("RIGHT", AI1, "LEFT", 0, 0)
        AI2:SetFrameLevel(0)

        AI3 = CreateFrame("Frame", nil, UIParent)
        AI3:SetFrameStrata(BACKGROUND)
        AI3:SetBackdrop({bgFile = "Interface\\AddOns\\AI-Suite\\Art\\A1R.tga"})
        AI3:SetHeight(80)
        AI3:SetWidth(128)
        AI3:SetPoint("LEFT", AI1, "RIGHT", 0, 0)
        AI3:SetFrameLevel(0)
end

AI1:RegisterEvent('UNIT_ENTERED_VEHICLE')
AI1:RegisterEvent('UNIT_EXITED_VEHICLE')


Xubera 10-27-10 01:49 PM

Code:

AI1:SetScript("OnEvent", function(self, event, ...)
    if event == "UNIT_VEHICLE_ENTERED" then
        --show Vehicle UF
    elseif event == "UNIT_VEHCILE_EXITED" then
        --show normal UF
    end
end)


Quokka 10-28-10 02:22 AM

Quote:

Originally Posted by Xubera (Post 214658)
Code:

AI1:SetScript("OnEvent", function(self, event, ...)
    if event == "UNIT_VEHICLE_ENTERED" then
        --show Vehicle UF
    elseif event == "UNIT_VEHCILE_EXITED" then
        --show normal UF
    end
end)


this did not work out. for some reason
the
Code:

-------------------------- AI-Panels by Quokka (T.C) ------------------------

AI1 = CreateFrame("Frame", nil, UIParent)
AI1:SetFrameStrata(BACKGROUND)
AI1:SetHeight(80)
AI1:SetWidth(512)
AI1:SetPoint("BOTTOM",-0,-1)
AI1:SetFrameLevel(0)

AI1:SetScript("OnEvent", function(self, event, ...)
    if event == "UNIT_VEHICLE_ENTERED" then
        AI1:SetBackdrop({bgFile = "Interface\\AddOns\\AI-Suite\\Art\\V1.tga"})
    elseif event == "UNIT_VEHCILE_EXITED" then
        AI1:SetBackdrop({bgFile = "Interface\\AddOns\\AI-Suite\\Art\\A1.tga"})
        else
                AI1:SetBackdrop({bgFile = "Interface\\AddOns\\AI-Suite\\Art\\A1.tga"}) -- backup
        end
end)

if not UnitInVehicle("player") then
        AI2 = CreateFrame("Frame", nil, UIParent)
        AI2:SetFrameStrata(BACKGROUND)
        AI2:SetBackdrop({bgFile = "Interface\\AddOns\\AI-Suite\\Art\\A1L.tga"})
        AI2:SetHeight(80)
        AI2:SetWidth(128)
        AI2:SetPoint("RIGHT", AI1, "LEFT", 0, 0)
        AI2:SetFrameLevel(0)

        AI3 = CreateFrame("Frame", nil, UIParent)
        AI3:SetFrameStrata(BACKGROUND)
        AI3:SetBackdrop({bgFile = "Interface\\AddOns\\AI-Suite\\Art\\A1R.tga"})
        AI3:SetHeight(80)
        AI3:SetWidth(128)
        AI3:SetPoint("LEFT", AI1, "RIGHT", 0, 0)
        AI3:SetFrameLevel(0)
end

AI1:RegisterEvent('UNIT_ENTERED_VEHICLE')
AI1:RegisterEvent('UNIT_EXITED_VEHICLE')


Mischback 10-28-10 10:58 AM

You Don't register your Frame to listen to any events... Use calls like

Frame:RegisterEvent('EVENTNAME')

To actually listen to events before the SetScript-call.

Posted via phone, so fix typos yourself ;)

Quokka 10-28-10 12:29 PM

Quote:

Originally Posted by Mischback (Post 214836)
You Don't register your Frame to listen to any events... Use calls like

Frame:RegisterEvent('EVENTNAME')

To actually listen to events before the SetScript-call.

Posted via phone, so fix typos yourself ;)

m8 you might need a bigger phone screen.
at the bottom I register the frames

Code:

AI1:RegisterEvent('UNIT_ENTERED_VEHICLE')
AI1:RegisterEvent('UNIT_EXITED_VEHICLE')


Dainton 10-28-10 01:03 PM

You're registering the right events, but your onevent is mixed up.
Code:

AI1:SetScript("OnEvent", function(self, event, ...)
    if event == "UNIT_VEHICLE_ENTERED" then
        AI1:SetBackdrop({bgFile = "Interface\\AddOns\\AI-Suite\\Art\\V1.tga"})
    elseif event == "UNIT_VEHCILE_EXITED" then
        AI1:SetBackdrop({bgFile = "Interface\\AddOns\\AI-Suite\\Art\\A1.tga"})
        else
                AI1:SetBackdrop({bgFile = "Interface\\AddOns\\AI-Suite\\Art\\A1.tga"}) -- backup
        end
end)

Change them to UNIT_ENTERED_VEHICLE and UNIT_EXITED_VEHICLE.

Mischback 10-28-10 10:32 PM

Quote:

Originally Posted by Quokka (Post 214848)
m8 you might need a bigger phone screen.
at the bottom I register the frames

Doh! ;)

Overlooked that bit...

Quokka 10-29-10 04:51 AM

Quote:

Originally Posted by Dainton (Post 214858)
You're registering the right events, but your onevent is mixed up.
Code:

AI1:SetScript("OnEvent", function(self, event, ...)
    if event == "UNIT_VEHICLE_ENTERED" then
        AI1:SetBackdrop({bgFile = "Interface\\AddOns\\AI-Suite\\Art\\V1.tga"})
    elseif event == "UNIT_VEHCILE_EXITED" then
        AI1:SetBackdrop({bgFile = "Interface\\AddOns\\AI-Suite\\Art\\A1.tga"})
        else
                AI1:SetBackdrop({bgFile = "Interface\\AddOns\\AI-Suite\\Art\\A1.tga"}) -- backup
        end
end)

Change them to UNIT_ENTERED_VEHICLE and UNIT_EXITED_VEHICLE.

thanks.. how can I mix that up :o

Quokka 10-29-10 05:25 AM

okay got it working.

but I need some sort off check, to make sure the textures show when I log in.
since my backup function fails.


Code:

AI1 = CreateFrame("Frame", nil, UIParent)
AI1:SetFrameStrata(BACKGROUND)
AI1:SetHeight(80)
AI1:SetWidth(512)
AI1:SetPoint("BOTTOM",-0,-1)
AI1:SetFrameLevel(0)

AI2 = CreateFrame("Frame", nil, UIParent)
AI2:SetFrameStrata(BACKGROUND)
AI2:SetHeight(80)
AI2:SetWidth(128)
AI2:SetPoint("RIGHT", AI1, "LEFT", 0, 0)
AI2:SetFrameLevel(0)

AI3 = CreateFrame("Frame", nil, UIParent)
AI3:SetFrameStrata(BACKGROUND)
AI3:SetHeight(80)
AI3:SetWidth(128)
AI3:SetPoint("LEFT", AI1, "RIGHT", 0, 0)
AI3:SetFrameLevel(0)

AI1:SetScript("OnEvent", function(self, event, ...)
    if event == "UNIT_ENTERED_VEHICLE" then
        AI1:SetBackdrop({bgFile = "Interface\\AddOns\\AI-Suite\\Art\\V1.tga"})
                AI2:SetBackdrop({bgFile = "Interface\\AddOns\\AI-Suite\\Art\\V1L.tga"})
                AI3:SetBackdrop({bgFile = "Interface\\AddOns\\AI-Suite\\Art\\V1R.tga"})
--        elseif event == "UNIT_EXITED_VEHICLE" then
--                AI1:SetBackdrop({bgFile = "Interface\\AddOns\\AI-Suite\\Art\\A1.tga"})
--                AI2:SetBackdrop({bgFile = "Interface\\AddOns\\AI-Suite\\Art\\A1L.tga"})
--                AI3:SetBackdrop({bgFile = "Interface\\AddOns\\AI-Suite\\Art\\A1R.tga"})
        else
                AI1:SetBackdrop({bgFile = "Interface\\AddOns\\AI-Suite\\Art\\A1.tga"})
                AI2:SetBackdrop({bgFile = "Interface\\AddOns\\AI-Suite\\Art\\A1L.tga"})
                AI3:SetBackdrop({bgFile = "Interface\\AddOns\\AI-Suite\\Art\\A1R.tga"})
        end
end)

AI1:RegisterEvent('UNIT_ENTERED_VEHICLE')
AI1:RegisterEvent('UNIT_EXITED_VEHICLE')

Not sure If I should use
Code:

AI1:RegisterEvent("PLAYER_ENTERING_WORLD")
and use

Code:

AI1:SetScript("OnEvent", function(self, event, ...)
        if event == "PLAYER_ENTERING_WORLD" then
                AI1:SetBackdrop({bgFile = "Interface\\AddOns\\AI-Suite\\Art\\A1.tga"})
                AI2:SetBackdrop({bgFile = "Interface\\AddOns\\AI-Suite\\Art\\A1L.tga"})
                AI3:SetBackdrop({bgFile = "Interface\\AddOns\\AI-Suite\\Art\\A1R.tga"})
        elseif event == "UNIT_ENTERED_VEHICLE" then
        AI1:SetBackdrop({bgFile = "Interface\\AddOns\\AI-Suite\\Art\\V1.tga"})
                AI2:SetBackdrop({bgFile = "Interface\\AddOns\\AI-Suite\\Art\\V1L.tga"})
                AI3:SetBackdrop({bgFile = "Interface\\AddOns\\AI-Suite\\Art\\V1R.tga"})
        else
                AI1:SetBackdrop({bgFile = "Interface\\AddOns\\AI-Suite\\Art\\A1.tga"})
                AI2:SetBackdrop({bgFile = "Interface\\AddOns\\AI-Suite\\Art\\A1L.tga"})
                AI3:SetBackdrop({bgFile = "Interface\\AddOns\\AI-Suite\\Art\\A1R.tga"})
        end
end)

AI1:RegisterEvent("PLAYER_ENTERING_WORLD")
AI1:RegisterEvent('UNIT_ENTERED_VEHICLE')
AI1:RegisterEvent('UNIT_EXITED_VEHICLE')

this works, but i'm not sure if i would run into problems on other ocations.
could somebody give me some advice to use it this way or how to do this the best way

Xubera 10-29-10 05:58 AM

*note: I didnt read your code, just your question.

if your concerned about the code being called more than once

PLAYER_ENTERING_WORLD is called pretty much anytime you hit a loading screen... going into an instance, leaving an instance, and what not

PLAYER_LOGIN is called at login or a reloading of the ui :)


All times are GMT -6. The time now is 02:34 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI