This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
john_smith's profile picture

how do i take a program that needs arguments to be given on exec to ask after exec.

Started by john_smith, 05 April 2015 - 07:39 AM
john_smith #1
Posted 05 April 2015 - 09:39 AM
Hello I'm new to programing I've bin playing around a bit with mining turtles and also found program online to mine out a quarry. It works quit well when its installed on the turtle you simply run "quarry <row length> <number of rows> <current y>" where you fill the 3 spaces with # of block for each. now I wanted to set it up so a turtle with this program installed could be told to make a quarry remotely. I know part of the red.net commands and I know if I make a floppy with startup file saying to open wireless modem right and copy quarry to /. that covers the first part so then I was trying to figure out how to get it to start the program. I made a another program called "RUN" with this code

<write("type [run] to start:")

answer =read()
if answer == "run" then
print("Running…")
sleep(5)
shell.run("quarry")
end>
and that works, but I want to take the code from this and instead of putting the x z y when program runs I want to have it the ask for the values once its starts. quarry code arguments part
<local args = { . . . }

if #args ~= 3 then
print("Usage: quarry <row length> <number of rows> <current y>")
error()
end

rowLength = args[1]
rows = args[2]
startingY = args[3]
curRow = 1

y = startingY>

so how do I change this from making me do "quarry x z y" to
>quarry
>please enter x z y: x z y
Lyqyd #2
Posted 05 April 2015 - 04:40 PM
Moved to Ask a Pro.

You'd be better off using rednet to get the options before running the program, then starting it with those options via shell.run. It'd be much easier to set up.
john_smith #3
Posted 05 April 2015 - 07:12 PM
Moved to Ask a Pro.

You'd be better off using rednet to get the options before running the program, then starting it with those options via shell.run. It'd be much easier to set up.
Thanks ill try that now.
Square789 #4
Posted 05 April 2015 - 07:12 PM
You could use this code:

write("How wide? ")
xLen = tonumber(read())
term.clear()
write("How high? ")
yLen = tonumber(read())
term.clear()
write("How deep? ")
zLen = tonumber(read())
term.clear()
And as long the user doesn't input strings
you have the Variables
xLen, yLen and zLen