Ordush 185 Posted August 26, 2017 Share Posted August 26, 2017 Didn't know what to call the topic honestly. Hope people understand. :) Been trying to wrap my brain around this function for ages now. Anyone who can help me? function CombatSpellsToggleButton(ability, position) local frameButton = "SettingsFrame."..ability.."btn" local frameDisabled = ability.."Disabled" frameButton = CreateFrame("BUTTON", nil, SettingsFrame, "UIPanelCloseButton") frameButton:SetWidth(16) frameButton:SetHeight(16) if frameDisabled then frameButton:SetNormalTexture("Interface/Buttons/UI-PlusButton-Up") frameButton:SetPushedTexture("Interface/Buttons/UI-PlusButton-Down") else frameButton:SetNormalTexture("Interface/Buttons/UI-MinusButton-Up") frameButton:SetPushedTexture("Interface/Buttons/UI-MinusButton-Down") end frameButton:SetPoint("TOPRIGHT",SettingsFrame, -2,position) frameButton:SetScript("OnClick", function() if frameDisabled then frameDisabled = false frameButton:SetNormalTexture("Interface/Buttons/UI-MinusButton-Up") frameButton:SetPushedTexture("Interface/Buttons/UI-MinusButton-Down") else frameDisabled = true frameButton:SetNormalTexture("Interface/Buttons/UI-PlusButton-Up") frameButton:SetPushedTexture("Interface/Buttons/UI-PlusButton-Down") end end) frameButton:SetAlpha(1) frameButton:Show() end -- Settings Frame (Combat Spells) Hunter's Mark Toggle Button CombatSpellsToggleButton("HuntersMark", -86) It does make the button, but the variable generated by frameDisabled does not work So if i do if HuntersMarkDisabled then do something end that something doesn't happen Link to comment Share on other sites More sharing options...
reapler 154 Posted August 26, 2017 Share Posted August 26, 2017 Hello, i think you would like to also connect to C#? So you can use this: Lua.LuaDoString(@" if (GetCVar(""frameDisabled"") == nil) then RegisterCVar(""frameDisabled"", ""default"") end if (GetCVarBool(""frameDisabled"")) then SetCVar(""frameDisabled"", 0 ); DEFAULT_CHAT_FRAME:AddMessage(""enabled frame""); else SetCVar( ""frameDisabled"", 1 ); DEFAULT_CHAT_FRAME:AddMessage(""disabled frame""); end "); After each call it will be changed. And the returned values can be used by a fightclass. In lua just replace the double quote to one quote and add your code. Link to comment Share on other sites More sharing options...
reapler 154 Posted August 26, 2017 Share Posted August 26, 2017 (edited) I've altered your second snippet, because it threw some errors: if (GetCVar("HuntersMarkDisabled") == nil) then RegisterCVar("HuntersMarkDisabled", "default") end if (GetCVarBool("HuntersMarkDisabled")) then SetCVar("HuntersMarkDisabled", 0 ); DEFAULT_CHAT_FRAME:AddMessage("enabled frame: HuntersMark"); else SetCVar( "HuntersMarkDisabled", 1 ); DEFAULT_CHAT_FRAME:AddMessage("disabled frame: HuntersMark"); end But since you are using only lua, i think there's a better solution but lua is not my favorite language ;) Maybe someone else can other offer a better answer. Edited August 26, 2017 by reapler Link to comment Share on other sites More sharing options...
Ordush 185 Posted August 26, 2017 Author Share Posted August 26, 2017 14 minutes ago, reapler said: I've altered your second snippet, because it threw some errors: if (GetCVar("HuntersMarkDisabled") == nil) then RegisterCVar("HuntersMarkDisabled", "default") end if (GetCVarBool("HuntersMarkDisabled")) then SetCVar("HuntersMarkDisabled", 0 ); DEFAULT_CHAT_FRAME:AddMessage("enabled frame: HuntersMark"); else SetCVar( "HuntersMarkDisabled", 1 ); DEFAULT_CHAT_FRAME:AddMessage("disabled frame: HuntersMark"); end But since you are using only lua, i think there's a better solution but lua is not my favorite language ;) Maybe someone else can other offer a better answer. Yeah i had an end too many. =P I removed my reply because i realized what you meant, however. what you did there was what i already did, i just didn't do it c#. So unfortunately it doesn't work. :( Link to comment Share on other sites More sharing options...
Ordush 185 Posted August 27, 2017 Author Share Posted August 27, 2017 I still haven't figured this out, so if anyone could be of assistance. It would be lovely! :) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now