Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

GUI Click sequence?

Asked by 9 years ago

I'm not really sure where to start but the idea is. XYZ are Frames lets say.

You click once "x" shows up. Click again, "y" shows up. Then click a final time and "z" shows up.

1 answer

Log in to vote
1
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
9 years ago

Each time we click the button, something has to happen. You want to make X visible the first time, Y the second, Z the third.

That means you could just count which click we're on, and act accordingly:

local clickCount = 1
function click()
    if clickCount == 1 then
        X.Visible = true
    elseif clickCount == 2 then
        Y.Visible = true
    elseif clickCount == 3 then
        Z.Visible = true
    end
    clickCount = clickCount + 1
end

We could also interpret this as,

  • if X is not visible,
    • make X visible
  • otherwise
    • if Y is not visible
      • make Y visible
    • otherwise
      • if Z is not visible
        • make Z visible

This would eliminate the clickCount and also make it react to something hiding the frames / make this easier to "reuse"

function click()
    if not x.Visible then
        x.Visible = true
    else
        if not y.Visible then
            y.Visible = true
        else
            if not z.Visible then
                z.Visible = true
            end
        end
    end
end

We can shorten this using elseif of course:

function click()
    if not x.Visible then
        x.Visible = true
    elseif not y.Visible then
        y.Visible = true
    elseif not z.Visible then
        z.Visible = true
    end
end
Ad

Answer this question