2 posts
Posted 12 October 2014 - 05:36 AM
I want my program ask me how long my door should stay open for. I thought i might be able to use a variable but it doesn't work
8543 posts
Posted 12 October 2014 - 05:38 AM
Please post your code.
2 posts
Posted 12 October 2014 - 05:40 AM
Kinda of a noob how do i do that?
How do i do that?
How do i do that?
How do i do that?
How do i do that?
How do i do that?
Im a noob but how do i do that?
How?
Im a noob but how do i do that?
How?
808 posts
Posted 12 October 2014 - 06:15 AM
So obviously we'd like to see your code. But I can make a guess at what you might be trying to do.
time = read()
sleep(time)
The issue here is that
time is the
string for what they typed. The sleep function takes a number. Is this your issue? If so you just need to wrap read in a tonumber call.
time = tonumber(read())
sleep(time)
tonumber will return nil if what they typed isn't a valid number, so check for that.
1852 posts
Location
Sweden
Posted 12 October 2014 - 05:21 PM
…
That kinda looks like spam o.o
Anyway, this is an example on how you can do ( probably ) what you want
write( "Sleep for how long? " )
local input = tonumer( read() ) -- convert input into a number
sleep( input ) -- sleep for the time inputted
Edited on 12 October 2014 - 03:21 PM
8543 posts
Posted 12 October 2014 - 07:46 PM
…
That kinda looks like spam o.o
That's what happens when New Members post essentially the same thing ten times in a row because they haven't read the Forum Guidelines or the notice that helpfully displays when you post that your posts have to be approved before they become visible and I come by and squish all ten of them into one post before approving it.
7083 posts
Location
Tasmania (AU)
Posted 13 October 2014 - 12:14 AM
Ah. I thought he was quoting a musical number.