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

Is "local db" another way to Define Debounce?

Asked by
KenzaXI 166
8 years ago

As the title sais, I'm asking this because I've seen many people post a script like this, and some my answers have had Debounce defined like that. Thanks for the Help.

2 answers

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

Debounce is a design pattern. The name debounce doesn't mean anything special to Lua, and really, you should be using a better name than that.

I prefer the name enabled. Before proceeding, you always check that you are enabled. You can choose to disable yourself by setting enabled to false.

Code looks like this:

local enabled = true -- start on

function doThing()
    if enabled then
        -- I'm allowed to work
        enabled = false -- but I'm temporarily disabled while I work
        -- (do stuff)
        wait(5)
        enabled = true -- I'm available to work again
    end
end
Ad
Log in to vote
0
Answered by 8 years ago

Debounce is a variable, meaning that, it can be named whatever you want. I guess a person that at least understands a bit a variables would know this.

Answer this question