Page 2 of 2

Re: Weird error for a function that is correct.

Posted: Thu Apr 11, 2024 12:02 pm
by Bobble68
I also want to add (I can't tell if you understand this or not, but there's a strong chance you do so if so I apologize) that the way if statements work is that it checks that the value between 'if' and 'then' evaluates as true or false so

Code: Select all

if true then
    something = 1
end
is the same as

Code: Select all

something = 1
It's also the same as this

Code: Select all

if false then
  something = 0
else
  something = 1
end
It can be useful to do this if you're debugging (which if that's what you're doing, I again apologize), since it essentially locks open/closed an if statement.

Lua also uses a concept known as truthiness, which for Lua means that nil values will act as false in an if statement and numbers and strings act as true, so this is also the same:

Code: Select all

aValue = nil

if aValue then
  something = 0
else
  something = 1
end