Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local turtleId
- local isWirelessTurtle
- local messageOutputFileName
- local tArgs = {...}
- local length = tonumber(tArgs[1])
- local width = tonumber(tArgs[2])
- local turnRight = true
- local slot = 1
- isWirelessTurtle = peripheral.isPresent("right")
- if (isWirelessTurtle == true) then
- turtleId = os.getComputerLabel()
- rednet.open("right")
- end
- function writeMessage(message)
- print(message)
- -- If this turtle has a modem, then write the message to red net
- if (isWirelessTurtle == true) then
- if (turtleId == nil) then
- rednet.broadcast(message)
- else
- -- Broadcast the message (prefixed with the turtle's id)
- rednet.broadcast("[".. turtleId.."] "..message)
- end
- end
- if (messageOutputFileName ~= nil) then
- -- Open file, write message and close file (flush doesn't seem to work!)
- local outputFile = io.open(messageOutputFileName, "a")
- outputFile:write(message)
- outputFile:write("\n")
- outputFile:close()
- end
- end
- if width == nil then
- print("1. Place turtle facing direction of said platform on left side.")
- print("2. Load turtle with materials for the platform.")
- print("3. Type 'platform <length> <width>'")
- end
- writeMessage("Beginning to build Platform")
- turtle.select(slot)
- turtle.dig()
- turtle.forward()
- for j = 1, width, 1 do
- for i = 1, length, 1 do
- if turtle.getItemCount(slot) == 0 then
- slot = slot + 1
- turtle.select(slot)
- turtle.digDown()
- turtle.placeDown()
- else
- turtle.digDown()
- turtle.placeDown()
- end
- if i < length then
- turtle.dig()
- turtle.forward()
- end
- end
- if j < width then
- if turnRight == true then
- turtle.turnRight()
- turtle.dig()
- turtle.forward()
- turtle.turnRight()
- turnRight = false
- else
- turtle.turnLeft()
- turtle.dig()
- turtle.forward()
- turtle.turnLeft()
- turnRight = true
- end
- end
- end
- writeMessage("Finished Building Platform")
Advertisement
Add Comment
Please, Sign In to add comment