It's been a while since this post has been updated,
for some reason the if statement on line 51 gets ignored but still uses the code within the statement, not sure if I worded that correctly so what I mean is,
if 5<2 then
term.write("boom shakalaka")
end
That's just an example, I know for a 100% pure fact my code shouldn't be running through the if statement because it doesn't have the right conditions, yet it acts as if it does so it runs the code anyway. Here's the actual code, my problem is on line 51
os.unloadAPI("apple")
os.loadAPI("apple")
apple.reset()
print("Thanks for playing guess that number!")
local file = fs.open("best", "r")
best = file.readLine()
file.close()
print("Would you like to use a custom range?")
print("(If you say no it will be 1-100)")
print("The current best is: ")
print(best)
local answer = read()
local tries = 0
if not best then
local best = 100
local file = fs.open("best", "w")
file.write(best)
print(best)
file.close()
end
while true do
if answer == "yes" then
print("Sorry this feature is a work in progress,")
print("Please enter minimum then maximum")
local min = read()
local max = read()
break
elseif answer == "no" then
print("Okay.")
local min = 1
local max = 100
break
else
print("Pease say 'yes' or 'no'")
end
end
local correct = math.random(1, 100)
while true do
local guess = read()
guess = tonumber(guess)
tries = tries+1
local best = 100
if guess > correct then
print("Too high!")
elseif guess < correct then
print("Too low!")
elseif guess == correct then
print("juuussst riiight")
if tries < best then
best = tries
print(best)
local file = fs.open("best", "w")
file.write(best)
file.close()
end
break
else
print("Sorry, there was a problem.")
break
end
end
EDIT: I looked over my code and found my problem. When I was without internet I was testing and stuff to see what was wrong and I forgot to delete
local best = 100
so I'm gonna do some testing to see if it's fixed now.
EDIT#2: Attempt to compare string with number expected, got string when I do
if tries < best then="" --code="" end="" [="" code]<="" code="">
</best>
Note: I hit edit and the quotation marks and <>'s popped up randomly, I thought hitting save changes would fix it. Didn't.