0 Members and 1 Guest are viewing this topic.
Number: 2Running through loop : 0Running through loop : 1
print ("Enter number: ")max_value = io.read()
get_num = function();print("Enter number: ");max_value = io.read("*number");endif type(max_value) == number;for i=1,max_value,1 do print(i) end else;print("Not a Number!");break;end
lua: helloworld.lua:1: unexpected symbol near ';'
get_num = function() print("Enter number: ") max_value = io.read("*number")endif type(max_value) == number for i=1,max_value,1 do print(i) end else print("Not a Number!") breakend
lua: helloworld.lua:6: 'then' expected near 'for'
get_num = function() print("Enter number: ") max_value = io.read("*number")endif type(max_value) == number then for i=1,max_value,1 do print(i) end else print("Not a Number!") breakend
get_num = function() print("Enter number: ") max_value = io.read("*number")endif type(max_value) == number then for i=1,max_value,1 do print(i) end else print("Not a Number!")end
I'm more fluent in Lua syntax than most other languages, it's easy when you memorize it.
Quote from: BrownyTCat on May 31, 2011, 04:59:39 pmI'm more fluent in Lua syntax than most other languages, it's easy when you memorize it.Then perhaps you can help me please?
Quote from: Scout on May 31, 2011, 04:59:59 pmQuote from: BrownyTCat on May 31, 2011, 04:59:39 pmI'm more fluent in Lua syntax than most other languages, it's easy when you memorize it.Then perhaps you can help me please?The problem I have is the nSpire platform, I can't even make a loop to draw a screen.
print("Enter number: ") max_value = io.read("*number") if type(max_value) == "number" then for i=1,max_value,1 do print(i) end else print("Not a Number!") end
Code: [Select] print("Enter number: ") max_value = io.read("*number") if type(max_value) == "number" then for i=1,max_value,1 do print(i) end else print("Not a Number!") endThis seems to work.
print("Enter number: ")max_value = io.read("*number") --Get maximum random numberif type(max_value) == "number" then --If the user enters a number math.randomseed( os.time() ) random_number = math.random(max_value) --Define a number while true do print ("Guess a number: ") tried_number = io.read("*number") if type(tried_number) == "number" then if tried_number == random_number then print ("You Won") break end end endelse print("Not a Number!") end
print("Enter number: ")max_value = io.read("*number") --Get maximum random numberif type(max_value) == "number" then --If the user enters a number math.randomseed( os.time() ) random_number = math.random(max_value) --Define a number while true do print ("Guess a number: ") tried_number = io.read("*number") if type(tried_number) == "number" then if tried_number == random_number then print ("You Won") break elseif tried_number > random_number then print ("Try a lower number") else print ("Try a higher number") end else print ("Not a number!") end endelse print("Not a number!") end