Re: Weird error for a function that is correct.
Posted: Thu Apr 11, 2024 12:02 pm
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
is the same as
It's also the same as this
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
if true then
something = 1
end
Code: Select all
something = 1
Code: Select all
if false then
something = 0
else
something = 1
end
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