Hello all, I have a question involving variables(I think). I'm trying to write a frame airship control program, so far, i can make it travel in one direction 10 blocks by running my program out to a wireless transmitter. I would like to set it up to travel any distance, without having to write a program for every distance. I would like to be able to type East 10 or East 100, and have it travel that far. Here is my program;
for i=1, 20, 1 do
output= "left"
redstone.setOutput(output, true)
sleep(.5)
redstone.setOutput(output, false)
sleep(.5)
end
Any help on this would be greatly appreciated!
Using program arguments to set variables
Started by metal249, May 05 2013 03:24 AM
2 replies to this topic
#1
Posted 05 May 2013 - 03:24 AM
#2
Posted 05 May 2013 - 11:19 AM
Split into new topic. A title was provided for you.
#3
Posted 05 May 2013 - 12:01 PM
local tArgs = {...}
local distance = tArgs[1] or 1
local output = "left"
for i = 1, distance do
redstone.setOutput(output, true)
sleep(.5)
redstone.setOutput(output, false)
sleep(.5)
end
That will take the first argument passed to your program as the distance to travel. If no argument is passed, then it is defaulted to 1.
2 user(s) are reading this topic
0 members, 2 guests, 0 anonymous users











