String comparison having unexpected behaviour

Hey everyone,
I’ve run into a problem with the behavior of the == operator and comparing strings, and i’m not certain how to solve it.

I’m trying to compare the input of a function to a string literal so that i can decide what to return, which in the case of no matches found should be nil. Simple enough, but no matter what i try it never returns nil when i should. Here’s the code:

function IngredientsLib.EnergyLookup(input)
		local returnTable = {0,0,0,0,0,0}
		if input == "Sugma" then
			print("THE SUGMA")
			print(returnTable)
		end
		if input == "Fireleaf" or "fireleaf" or "FL" then
			print("Fireleaf Triggered")
			returnTable = {0,0,5,0,0,0}
		else	
			returnTable = nil
		end
		return returnTable
	end

Sugma is the name of the test item that should return nil when it goes through this function. It was 3am, what do you want from me.

eitherway as you can see its super simple, so clearly im not understanding something about how the == operator works since the rest of the function responds how youd expect to getting the input “Sugma”.

I looked everywhere to try and work out what functionality im completely missing, but i just cant find it anywhere. hopefully you can help me because i’m stumped.

thank you for your time and i hope you can help!! :green_heart:

1 Like
if input == "Fireleaf" or input == "fireleaf" or input == "FL" then

end

Yeah, lua doesn’t do multiple conditional statement that way

2 Likes

embarrassing. thanks friend! idk how or when idve figured that out otherwise lmao

1 Like