Skip to content
View in the app

A better way to browse. Learn more.

WRobot

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

(LUA) Function to frame help please :)

Featured Replies

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

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.

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 by reapler

  • Author
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. :(

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.