4 posts
Posted 29 October 2012 - 05:19 PM
I am making a code to retrieve items from storage… I am trying to get a user to input a number (the amount of items they want) … It isn't working with input = read() because that returns a string. How would I change it to get back to a number and not a string?
2088 posts
Location
South Africa
Posted 29 October 2012 - 05:21 PM
4 posts
Posted 29 October 2012 - 05:57 PM
Thanks… Now how would I get the program to restart after it finishes its rounds?
2088 posts
Location
South Africa
Posted 29 October 2012 - 06:14 PM
Use a while true do loop:
while true do
term.clear() term.setCursorPos(1,1)
print("Input a number")
n = tonumber(read())
if type(n) == "number" then
print("You entered a number as a string and converted it into a number!")
else
print("You entered a number and it is still a string :/")
end
sleep(3) -- this is so you are able to view the message that is displayed
end