Weird error for a function that is correct.

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
User avatar
Bobble68
Party member
Posts: 162
Joined: Wed Nov 30, 2022 9:16 pm
Contact:

Re: Weird error for a function that is correct.

Post 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
Post Reply

Who is online

Users browsing this forum: Amazon [Bot], Bing [Bot] and 3 guests