Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --GPS Tower Builder Version-1.3 , Made By bigbaddevil7.
- local tArgs = {...}
- hasTower = tArgs[1]
- Ypos = tonumber(tArgs[2])
- Zpos = tonumber(tArgs[3])
- face = tonumber(tArgs[4])
- direction = ""
- function faceNorth()
- if face == 1 then
- turtle.turnRight()
- elseif face == 3 then
- turtle.turnLeft()
- elseif face == 0 then
- turtle.turnRight()
- turtle.turnRight()
- end
- end
- function placeComputer(num)
- turtle.select(1)
- turtle.place()
- turtle.up()
- turtle.select(2)
- turtle.place()
- turtle.down()
- turtle.down()
- turtle.select(3)
- turtle.place()
- turtle.select(4)
- turtle.drop()
- print("Uploading Cords to Comp: "..num)
- transfer(num)
- turtle.up()
- sleep(0.5)
- comp = peripheral.wrap("front")
- comp.turnOn()
- turtle.down()
- turtle.suck()
- turtle.select(3)
- turtle.dig()
- turtle.up()
- sleep(3)
- comp.reboot()
- end
- function transfer(Cnum)
- handler = fs.open("disk/startup", "w")
- handler.writeLine("fs.move(\"disk/GPS\", \"startup\")")
- handler.close()
- file = fs.open("disk/GPS", "w")
- if Cnum == 1 then
- file.writeLine("shell.run(\"gps\",\"host\","..C1x..","..C1y..","..C1z..")")
- elseif Cnum == 2 then
- file.writeLine("shell.run(\"gps\",\"host\","..C2x..","..C2y..","..C2z..")")
- elseif Cnum == 3 then
- file.writeLine("shell.run(\"gps\",\"host\","..C3x..","..C3y..","..C3z..")")
- elseif Cnum == 4 then
- file.writeLine("shell.run(\"gps\",\"host\","..C4x..","..C4y..","..C4z..")")
- end
- file.close()
- end
- function writeScreen()
- term.clear()
- term.setCursorPos(1,2)
- if face == 0 then
- direction = "South"
- elseif face == 1 then
- direction = "West"
- elseif face == 2 then
- direction = "North"
- elseif face == 3 then
- direction = "East"
- end
- print("X="..Xpos.." : Y="..Ypos..": Z="..Zpos.." : Facing = "..direction)
- color(colors.orange)
- moveUp = 246 - Ypos -- change to 246
- --print("Blocks to move up: "..moveUp + 1)
- print("Placement Grid Cords:")
- color(colors.cyan)
- print("==================================")
- C1x = Xpos + 5
- C1y = 249 --change 249
- C1z = Zpos
- color(colors.orange)
- print("Computer 1: "..C1x.." : 250 : "..C1z)
- C2x = Xpos - 5
- C2y = 249 --change 249
- C2z = Zpos
- print("Computer 2: "..C2x.." : 250 : "..C2z)
- C3x = Xpos
- C3y = 246 -- change 246
- C3z = Zpos + 5
- print("Computer 3: "..C3x.." : 247 : "..C3z)
- C4x = Xpos
- C4y = 246 -- change 246
- C4z = Zpos - 5
- print("Computer 4: "..C4x.." : 247 : "..C4z)
- color(colors.cyan)
- print("==================================")
- color(colors.orange)
- print("Press \"ENTER\" to start building")
- end
- function prepScreen()
- term.clear()
- term.setCursorPos(1, 2)
- color(colors.orange)
- print("The Program Requires")
- color(colors.cyan)
- print("==================================")
- color(colors.orange)
- print("Slot 1: 4 Computers")
- print("Slot 2: 4 Wireless Modems")
- print("Slot 3: 1 Disk Drive")
- print("Slot 4: 1 Floppy Disk")
- if turtle.getFuelLevel() < 1000 or turtle.getFuelLevel() ~= "unllimited" then
- print("Slot 5: Fuel")
- else
- print("")
- end
- color(colors.cyan)
- print("==================================")
- color(colors.orange)
- print("Press \"ENTER\" to start building")
- end
- function fillFuel()
- if turtle.getFuelLevel() < 1000 or turtle.getFuelLevel ~= "unlimited" then
- turtle.select(5)
- turtle.refuel()
- end
- end
- function work()
- for i = 10, 0, -1 do
- term.clear()
- term.setCursorPos(1,2)
- print("Please Stand Clear Of Turtle")
- print("Starting in: "..i)
- sleep(1)
- end
- print("Turning to face North...")
- faceNorth()
- print("Climbing to height of tower...")
- for i = 1, moveUp do
- while not turtle.up() do
- if turtle.digUp() then
- print("Mined a block in my way.")
- elseif turtle.attackUp() then
- print("Attacked a mob in my way")
- end
- end
- end
- for i = 1, 6 do
- turtle.back()
- end
- --sleep(2)
- print("Placing Computer 3")
- placeComputer(3)
- turtle.up()
- turtle.up()
- for i = 1, 12 do
- turtle.forward()
- end
- turtle.turnRight()
- turtle.turnRight()
- turtle.down()
- turtle.down()
- --sleep(2)
- print("Placing computer 4")
- placeComputer(4)
- turtle.up()
- turtle.up()
- turtle.up()
- for i = 1, 5 do
- turtle.forward()
- end
- turtle.turnLeft()
- for i = 1, 5 do
- turtle.forward()
- end
- turtle.turnRight()
- --sleep(2)
- print("Placing Computer 1")
- placeComputer(1)
- turtle.turnRight()
- for i = 1, 10 do
- turtle.forward()
- end
- turtle.turnLeft()
- --sleep(2)
- print("Placing computer 2")
- placeComputer(2)
- turtle.turnLeft()
- for i = 1, 5 do
- turtle.forward()
- end
- turtle.turnRight()
- turtle.forward()
- turtle.turnRight()
- turtle.turnRight()
- print("Heading back to start postion")
- for i = 0, moveUp + 2 do
- turtle.down()
- end
- end
- function getFace()
- for i = 10, 0, -1 do
- term.clear()
- term.setCursorPos(1,1)
- print("Stand Away From The Turtle So It Can Get It's Face.")
- print("It Will Attack Mobs/Players!")
- print("==================================")
- print("Time Until it moves: "..i)
- sleep(1)
- end
- while not turtle.forward() do
- if turtle.dig() then
- print("Mined a block in my way.")
- sleep(1)
- elseif turtle.attack() then
- print("Attacked a mob in my way")
- end
- end
- local xpos2, ypos2, zpos2 = gps.locate()
- while not turtle.back() do
- print("There is something in my way behind me")
- sleep(1)
- end
- if xpos2 > Xpos then
- face = 3
- elseif zpos2 < Zpos then
- face = 2
- elseif zpos2 > Zpos then
- face = 0
- elseif xpos2 < Xpos then
- face = 1
- end
- return face
- end
- function color(color)
- term.setTextColor(color)
- end
- function getCords()
- Xpos, Ypos, Zpos = gps.locate()
- if not Xpos then
- print("Could Not Get Location")
- return false
- end
- return Xpos, Ypos, Zpos
- end
- function cleanup()
- print("==================================")
- print("Running Final Cordinate Check")
- local x, y, z = gps.locate()
- if x ~= Xpos or y ~= Ypos or z ~= Zpos then
- print("Chack Failed")
- print("Make sure you entered your cords correctly")
- print("Check the towers, Check for any obstruction")
- print("If that all is in check then I messed up =(")
- else
- print("Check Succeded, your tower is running")
- end
- end
- if #tArgs == 4 then
- Xpos = tonumber(tArgs[1])
- prepScreen()
- while true do
- even, param1 = os.pullEvent()
- if param1 == 28 then
- break
- end
- end
- fillFuel()
- writeScreen()
- while true do
- even, param1 = os.pullEvent()
- if param1 == 28 then
- break
- end
- end
- work()
- cleanup()
- elseif #tArgs == 1 then
- if tArgs[1] == "locate" then
- if getCords() then
- prepScreen()
- while true do
- even, param1 = os.pullEvent()
- if param1 == 28 then
- break
- end
- end
- end
- fillFuel()
- getFace()
- writeScreen()
- while true do
- even, param1 = os.pullEvent()
- if param1 == 28 then
- break
- end
- end
- work()
- cleanup()
- elseif tArgs[1] == "help" then
- term.clear()
- term.setCursorPos(1,1)
- color(colors.cyan)
- print("Usage for maunally inputing cords are: tower <Xpos>, <Ypos>, <Zpos>, <Face>")
- term.setTextColor(colors.orange)
- print("The Face is the direction you are facing. It is the number under you Zpos in F3")
- color(colors.cyan)
- print("It is best to stand on the turtle and give it the cords that are in the () ")
- color(colors.orange)
- print("Usage for locating using another tower is: tower locate")
- color(colors.cyan)
- print("It will use an existing tower to get its cordinates")
- color(colors.white)
- else
- print("Invalid Parameters")
- print("Enter: tower <Xpos>, <Ypos>, <Zpos>, <Face>")
- print("Enter: tower locate (if you already have a hosting GPS tower)")
- print("Enter: tower help for more information")
- end
- else
- print("Please Enter: tower <X>, <Y>, <Z>, <F>")
- print("Or Enter: tower locate (if you already have a hosting GPS tower)")
- print("Example : tower 100 -100 200 1")
- print("F is the face under the Z cord in F3")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement