function SetAlpha()
if (PLAYER_REGEN_DISABLED = true ) then
SetAlpha(1)
end
end
if this is not right plz help as i am new to lua but some one told me that lua was the way i should try and do what i wanted to
and thx again for any and all help
yourframe:RegisterEvent("PLAYER_REGEN_ENABLED")
yourframe:RegisterEvent("PLAYER_REGEN_DISABLED")
yourframe:SetScript("OnEvent", function(self, event)
if event == "PLAYER_REGEN_DISABLED" then
self:SetAlpha(0)
else
self:SetAlpha(1)
end
end)
TCHOO:RegisterEvent("PLAYER_REGEN_ENABLED")
TCHOO:RegisterEvent("PLAYER_REGEN_DISABLED")
TCHOO:SetScript("OnEvent", function(self, event)
if event == "PLAYER_REGEN_DISABLED" then
self:SetAlpha(0)
else
self:SetAlpha(1)
end
end)
You can have a space, but you have to use _G["UI WIP"] or getglobal("UI WIP") to access it.
According to latest PTR builds, getglobal seems in its way to the trash, so prefer _G["UI WIP"].
And instead of :SetAlpha, you can simply :Show() and :Hide(), provided you do not need mouse interaction when the frame is hidden.
Moreover, nitchiale, all UI object shares the same namespace. You have defined both a texture and a frame named "UI WIP". You are running into troubles here.
And finally, avoid spaces in filenames too. Though it should be supported, I think you are going to experience some issues with this.
To figure out where the problem lies you should do the following in the chat box:
/script TCatsUI:PLAYER_REGEN_DISABLED()
That should call the function and play the sound file directly. If the sound doesn't play then you know the error is in the PlaySoundFile call (not sure but might need escaped slashes in the path, or path is wrong, etc). If the sound plays fine then either the event registration isn't setting correctly (double check to make sure you are using the api correctly) or the event isn't firing when you think it should (make sure you are using the correct event for what you want to do).
Note: Chances are I or someone else could have told you exactly what to do to fix the issue, but "teach a man to fish" and you'll figure out these things much faster than posting and waiting for a reply.
in order to hash the "\"s? And I'm sure someone will correct me, but the ".wav" extension is not strictly necessary, but sometimes nice. Especially if somebody else takes over the addon development at a later date.
YOU GUYS ROCk!!!!!!!!!!!!!!!! thank you soooo much that helps me in just more ways then this little peace of code but with a lot of probles i ve been having with making an addon here this is soo cool thx again
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
eg... when i enter combat the frame shows up and when i leave combat it turns invisable again??
an example would be soooo helpfull thx
frame:SetAlpha(1) -- Peek-a-boo!
function SetAlpha()
if (PLAYER_REGEN_DISABLED = true ) then
SetAlpha(1)
end
end
if this is not right plz help as i am new to lua but some one told me that lua was the way i should try and do what i wanted to
and thx again for any and all help
Interface\AddOns\BloodWings\new 2.lua:1:
attempt to call method 'RegisterEvent' (a nil value)
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/ ..\..\FrameXML\UI.xsd">
<Frame name="UI WIP" frameStrata="BACKGROUND" parent="UIParent" movable="false">
<Script file="new 2.lua"/
<Size>
<AbsDimension x="2048" y="512"/>
</Size>
<Anchors>
<Anchor point="BOTTOMLEFT" relativeTo="UIParent" relativePoint="BOTTOMLEFT">
<Offset><AbsDimension x="0" y="0" /></Offset>
</Anchor>
</Anchors>
<Layers>
<Layer level="BACKGROUND">
<Texture name="UI WIP" file="Interface\AddOns\BloodWings\Art\UI WIP" alphaMode="BLEND">
<Size>
<AbsDimension x="1920" y="1200"/>
</Size>
<Anchors>
<Anchor point="BOTTOMLEFT" relativeTo="UI WIP" relativePoint="BOTTOMLEFT">
<Offset><AbsDimension x="0" y="0"/></Offset>
</Anchor>
</Anchors>
</Texture>
<Texture name="TCHOO" file="Interface\AddOns\BloodWings\Art\TCHOO" alphaMode="BLEND">
<Size>
<AbsDimension x="1920" y="1200"/>
</Size>
<Anchors>
<Anchor point="TOPCENTER" relativeTo="UI WIP" relativePoint="TOPCENTER">
<Offset><AbsDimension x="0" y="0"/></Offset>
</Anchor>
</Anchors>
</Texture>
</Layer>
</Layers>
</Scripts>
</Frame>
</Ui>
and here is the LUA
TCHOO:RegisterEvent("PLAYER_REGEN_ENABLED")
TCHOO:RegisterEvent("PLAYER_REGEN_DISABLED")
TCHOO:SetScript("OnEvent", function(self, event)
if event == "PLAYER_REGEN_DISABLED" then
self:SetAlpha(0)
else
self:SetAlpha(1)
end
end)
And I don't think you can have a space in there.
You can have a space, but you have to use _G["UI WIP"] or getglobal("UI WIP") to access it.
According to latest PTR builds, getglobal seems in its way to the trash, so prefer _G["UI WIP"].
And instead of :SetAlpha, you can simply :Show() and :Hide(), provided you do not need mouse interaction when the frame is hidden.
Moreover, nitchiale, all UI object shares the same namespace. You have defined both a texture and a frame named "UI WIP". You are running into troubles here.
And finally, avoid spaces in filenames too. Though it should be supported, I think you are going to experience some issues with this.
im trying to add sound to this addon but i cant get the sound to trigger what am i doing thats not right?
TCatsUI = LibStub("AceAddon-3.0"):NewAddon("TCatsUI", "AceConsole-3.0", "AceEvent-3.0")
function TCatsUI:OnInitialize()
-- Called when the addon is loaded
end
function TCatsUI:OnEnable()
-- Called when the addon is enabled
self:RegisterEvent("PLAYER_REGEN_DISABLED")
end
function TCatsUI:PLAYER_REGEN_DISABLED()
PlaySoundFile("Interface\AddOns\TCatsUI\Sounds\HOO.wav")
end
function TCatsUI:OnDisable()
-- Called when the addon is disabled
end
p.s. its im using ace3.0 framework
/script TCatsUI:PLAYER_REGEN_DISABLED()
That should call the function and play the sound file directly. If the sound doesn't play then you know the error is in the PlaySoundFile call (not sure but might need escaped slashes in the path, or path is wrong, etc). If the sound plays fine then either the event registration isn't setting correctly (double check to make sure you are using the api correctly) or the event isn't firing when you think it should (make sure you are using the correct event for what you want to do).
Note: Chances are I or someone else could have told you exactly what to do to fix the issue, but "teach a man to fish" and you'll figure out these things much faster than posting and waiting for a reply.
Shouldn't
be
in order to hash the "\"s? And I'm sure someone will correct me, but the ".wav" extension is not strictly necessary, but sometimes nice. Especially if somebody else takes over the addon development at a later date.
PlaySoundFile([[Interface\AddOns\......]])