I am just learning and have been banging my head against this for a bit and was hoping for some more experienced eyes. Im very inexperienced and i need a explain it like im 5...
what im trying to do is sort circles into pegs for a mini game. I have compiled all the combinations that are possible (120) into a text file and now im trying to put those numbers into a table so that it trys it, then loops back and trys the next line in the file. So far i have this...
file = io.open("file.txt", "r")
for line in file:lines() do
print(line)
--This works and prints the output:
-- 1,2,3,4,5
-- 5,4,3,2,1
end
table = {1,2,3,4,5}
for key , value in pairs(table) do
--print ("cog",key,"peg",value)
Send("put ","cog",key," ","peg",value)
end
--This works and sends
put cog1 peg1
put cog2 peg2
put cog3 peg3
put cog4 peg4
put cog5 peg5
Now im having a hard time instead of explicitly telling it to set the table like this
" table = {1,2,3,4,5}"
i want it to do something like this
" table = {line data from the file read above}"
and then loop it back through each possibility from a file of 120 lines which has data that looks like this
1,2,3,4,5
1,2,3,5,4
1,2,4,3,5
1,2,4,5,3
1,2,5,3,4
1,2,5,4,3
1,3,2,4,5
1,3,2,5,4...
all the way through all the combinations.
Each time i try to do that im not getting the output im expecting. I am banging my head against the wall the right way to do it.
I really appreciate all you advanced level guys helping out the newbs like me |