Ok, so I’m trying to understand someone else’s code. I tried to look it up on google and dev but couldn’t find anything on the topic. So I understand how booleans and condition statements work. but I ran into someones code that defies that.
if gradualTextInProgress then
return
end
There’s no conditional. So what is it asking? If gradualTextInProgress is true? is it false?
Can someone please explain how this condition statement works? Below is the more code if that helps. Thanks!
local gradualTextInProgress = false
local function gradualText(text)
if gradualTextInProgress then
return
end
local length = string.len(text)
for i = 1, length, 1 do
gradualTextInProgress = true
DialogFrame.DialogText.Text = string.sub(text, 1, i)
wait()
end
gradualTextInProgress = false
end
No. In programming, there are things called true, truthy, false and falsey. In Lua’s case, anything that is nil or false is considered falsey, and anything that is either true or has a value is truthy. In your case, if gradualTextInProgess is not false or nil, it will be truthy, therefore the return statement will prevent any other code from running