Posted 02 June 2013 - 04:49 PM
OK so what i'm trying to do with this program is to make a maze that has a changeable configuration.
First off here is the code i have so far:
now what i cannot figure out is how to change these lines:
to be able to select the tables at random but still be able to output all of the numbers in the table. I have been at this for a few hours and cannot seem to find the information i am looking for.
First off here is the code i have so far:
w = peripheral.wrap("right") -- initializes the retherupgrade
m = 5 -- number of available mazes (have to set manually)
--list of available mazes
maze0 = {}
maze1 = {1,2,3,4}
maze2 = {3,4,5,6}
maze3 = {3,4,5,6}
maze4 = {4,5,6,7,8}
maze5 = {5,6,7,8,9}
function random() -- function to choose a random maze
nr = math.random(1,m) -- chooses a maze between 1 and m
print("loading maze")
print(nr)
end
function reset()
for i = 1,#maze1 do
signal = maze1[i]
w.setFreq(signal)
w.set(true)
sleep(0,1)
w.set(false)
end
end
function set()
for i = 1,#maze1 do
signal = maze1[i]
w.setFreq(signal)
w.set(true)
sleep(0,1)
w.set(false)
print(signal)
end
end
function alarm() -- makes an alarm go off before the walls change
rs.setOutput("front", true)
sleep(4,5)
rs.setOutput("front", false)
end
function main()
random()
set()
sleep(20)
alarm()
reset()
os.reboot()
end
--start the main function
while true do
main()
end
now what i cannot figure out is how to change these lines:
for i = 1,#maze1 do
signal = maze1[i]
to be able to select the tables at random but still be able to output all of the numbers in the table. I have been at this for a few hours and cannot seem to find the information i am looking for.