mardi 23 mai 2023

Error "attemped to compare number to string" lua, starter and probably easy to answer

What is wrong with my code? this is a really easy fix i bet but i am pretty new to lua so I cannot figure it out. The code is a random number generator that you are supposed to guess the number (its obviously not done) but it says "lua: main.lua:8: attempt to compare string with number" here is the code

local number2 = math.random(1,100)
local hi=2
repeat
print("pick a number, 1-100")
local number = io.read ()
if number == number2 then print("you got it!! congrats")
  end
if number <= number2 then print("too high!")
  end
if number >= number2 then print ("too low!")
  end
until (hi)==2

please help, thanks!




Aucun commentaire:

Enregistrer un commentaire