17 posts
Location
South Africa
Posted 11 January 2013 - 11:58 PM
I have been stumped with this problem.
Have made a turtle that builds a circular tower, it all works fine and it is now a function, but I want it to loop a set amount of times, not infinitely. The amount however, I want to be input by a user. So say what the user types is 10 , x = 10
So it would be
for I = 1,x
Function circleLoop()
End
Please help, also, I feel rut has something to do with arguments
7508 posts
Location
Australia
Posted 12 January 2013 - 12:01 AM
input in-program:
local timesLoop = tonumber( read() )
input from command line arguments
local args = { ... }
local timesLoop = tonumber( args[1] )
17 posts
Location
South Africa
Posted 12 January 2013 - 12:15 AM
input in-program:
local timesLoop = tonumber( read() )
input from command line arguments
local args = { ... }
local timesLoop = tonumber( args[1] )
Could you please explain more, if I post the code could you sow me where to put it?
7508 posts
Location
Australia
Posted 12 January 2013 - 12:24 AM
tonumber() converts the input string into a number
read() takes input from the user and won't continue until they press enter
local args = { … } is creating a table of the runtime arguments and storing it in the args variable
args[1] is accessing the first element in the table.
which one would you prefer to use?
17 posts
Location
South Africa
Posted 12 January 2013 - 01:32 AM
tonumber() converts the input string into a number
read() takes input from the user and won't continue until they press enter
local args = { … } is creating a table of the runtime arguments and storing it in the args variable
args[1] is accessing the first element in the table.
which one would you prefer to use?
Tonumber, thank you so much