Posted 06 January 2013 - 04:58 AM
I didn't wanna have to ask questions this soon into the program, but I learned on qBasic so switching to LUA has been rough.
My issue is that my while just keeps repeating. Here is what I think should be happening:
YES = y
while Correct does not = YES do
filler questions
"is this correct?"
local Correct = read()
end
move on
It doesn't move on tho, it just keeps repeating the questions. I assume I'm somehow comparing the YES and Correct incorrectly
There's some extra stuff in here for my learning purposes that you can ignore. I think it is also an issue of me not understanding while loops or the tonumber function. I saw someone say it would be easier to have it just be a number in the first place (maybe the wiki) but I haven't seen how you read() as a number, only to convert with tonumber.
Please look at the code, the example above is the k.i.s.s. version obviously.
My issue is that my while just keeps repeating. Here is what I think should be happening:
YES = y
while Correct does not = YES do
filler questions
"is this correct?"
local Correct = read()
end
move on
It doesn't move on tho, it just keeps repeating the questions. I assume I'm somehow comparing the YES and Correct incorrectly
There's some extra stuff in here for my learning purposes that you can ignore. I think it is also an issue of me not understanding while loops or the tonumber function. I saw someone say it would be easier to have it just be a number in the first place (maybe the wiki) but I haven't seen how you read() as a number, only to convert with tonumber.
Please look at the code, the example above is the k.i.s.s. version obviously.
Spoiler
YES = ("y")
print ("I'll need the measurements of your hallway.")
while Correct~=YES do
write ("How TALL? ")
local Height = read()
Height = tonumber (Height)
-- while H < 1 do
-- write ("Must be a number! How TALL? ")
-- local Height = read()
-- Height = tonumber (Height)
-- end
write ("How WIDE? ")
local Width = read()
Width = tonumber (Width)
write ("How LONG? ")
local Depth = read()
Depth = tonumber (Depth)
write ("Ok. I'll make it ") write (Height) write (" tall and ") write (Width) write (" wide and ") write (Depth) print (" long.")
write ("Is this correct? [y/n] ")
local Correct = read() print() print(Correct)
end
print ("I'll get started then. Check back later")
sleep (2)