How to turn a run cmd into a function

I have a run command via a macro that I want to turn into a function.

The run command is

/run toggle_single = not toggle_single

The purpose of this is when I clicked the macro, it toggles a set of WeakAuras.

I have these two functions set in my WAs

Custom Trigger:

function()
    if toggle_single == true then
        return true
    else
        return false
    end
end

Custom Untrigger

function()
    if toggle_single == false then
        return true
    else
        return false
    end
end

I tried this, but it doesn’t work.

aura_env.region:SetScript("OnMouseDown", function() toggle_single = not toggle_single() end)
aura_env.region:SetScript("OnEnter", function(self) self:SetAlpha(1) end)
aura_env.region:SetScript("OnLeave", function(self) self:SetAlpha(0) end)

I’m not good with LUA tbh, just piecing things together from Google searches and asking around. But I’m willing to learn!

aura_env.region:SetScript("OnMouseDown", function() toggle_single = not toggle_single() end)

Is toggle_single supposed to be a variable toggle_single or a function toggle_single()?

My best guess is you are looking to toggle a variable which would be:

aura_env.region:SetScript("OnMouseDown", function() toggle_single = not toggle_single end)

Which is to say, set the variable toggle_single to be what it currently isn’t.

That was it! Yea, it’s a toggle. I wonder why that last () made the difference (again, pretty new to LUA)

I suppose variables is a thing, and they are different to functions, correct? I should read up on that.

Thank you!