why is this not working?

I’ve been trying to make a 3 star ranking system for my game but I’ve ran into a little trouble with reading a file and stuff. No matter what the score is only one star appears for some reason. here is my code. I’m just wandering why its not working this time. it worked last time but sadly the usb broke therefor i lost the 3 star system i had. 

local loadValue = function( strFilename ) local theFile = strFilename local path = system.pathForFile( theFile, system.DocumentsDirectory ) local file = io.open( path, "r" ) if file then local contents = file:read( "\*n" ) io.close( file ) return contents else file = io.open( path, "w" ) file:write( "0" ) io.close( file ) return "0" end end function scene:enterScene( event ) local group = self.view local highScoreFilename1 = "score1.txt" local loadedHighScore1 = loadValue( highScoreFilename1 ) highScore1 = tonumber(loadedHighScore1) if highScore1 == 0 then nostar1 = display.newImage("nostar.png", 35, 100) elseif highScore1 == 1 or 2 then onestar1 = display.newImage("onestar.png", 35, 100) elseif highScore1 == 4 or 5 then twostar1 = display.newImage("twostar.png", 35, 100) elseif highScore1 == 6 or 7 or 8 or 9 or 10 or 11 or 12 or 13 then threestar1 = display.newImage("threestar.png", 35, 100) end end

You can’t write IF statements like this:

[lua]elseif highScore1 == 1 or 2 then[/lua]

It is not comparing highScore to 2. 2 will just always be true. Needs to be:

[lua]elseif highScore1 == 1 or highScore1 == 2 then[/lua]

I recommend also using less than or more than operators. Example last if

[lua]elseif highScore1 > 5 then[/lua]

You are missing check for 3 as well, maybe on purpose…

You can’t write IF statements like this:

[lua]elseif highScore1 == 1 or 2 then[/lua]

It is not comparing highScore to 2. 2 will just always be true. Needs to be:

[lua]elseif highScore1 == 1 or highScore1 == 2 then[/lua]

I recommend also using less than or more than operators. Example last if

[lua]elseif highScore1 > 5 then[/lua]

You are missing check for 3 as well, maybe on purpose…