Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local file = 'turtles.lua'
- local lines
- function ReadFile(file)
- if not FileExists(file) then
- return {}
- end
- lines = {}
- for line in io.lines(file) do
- lines[#lines + 1] = line
- end
- return lines
- end
- function FileExists(file)
- local f = io.open(file, "rb")
- if f then
- f:close()
- end
- return f ~= nil
- end
- function SendMessage(message)
- for n in lines do
- rednet.send(n, message)
- end
- end
- function Forward()
- redstone.setOutput("left", true)
- sleep(2)
- redstone.setOutput("left", false)
- redstone.setOutput("back", true)
- sleep(2)
- redstone.setOutput("back", false)
- end
- function Main()
- if #args > 1 or #args < 1 then
- print("Invalid number of arguments.")
- else
- count = args[1]
- end
- lines = ReadFile(file)
- Rednet.open()
- for i = 0, count do
- SendMessage("place")
- Rednet.close()
- sleep(20)
- Rednet.open()
- SendMessage("drop")
- SendMessage("break")
- Forward()
- end
- Rednet.close()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement