Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --
- --Signal Repeater deploy by WillisS
- --Using thw code from GPS Deploy by neonerZ v1.1
- --(http://youtube.com/neonerz)
- --
- --
- --
- --
- -- In order to use this script you need to setup
- -- either a mining turtle, or a standard turtle
- -- Slot 1 - Fuel
- -- Slot 2 - At least 1 computers
- -- Slot 3 - At least 1 modems
- -- Slot 4 - At lease 1 disk drive
- -- Slot 5 - 1 Disk
- --
- --
- -- How heigh up should the satellite be deployed?
- local height = 254
- local function printUsage()
- print("")
- print( "Usages:" )
- print( "deploySignalRepeater [current y] [height]" )
- end
- -- confirm default height isn't set above 254
- -- Check to see if a minimum of 3 values were
- -- passed to the script
- local args = { ... }
- if args[1] == "-u" then
- printUsage()
- elseif args[1] == nil then
- -- use gps
- rednet.open("right")
- local x, y, z = gps.locate()
- height = height - tonumber(y)
- else
- if args[2] ~= nil then
- height = tonumber(args[2])
- else
- height = height - tonumber(args[1])
- end
- end
- if height > 254 then
- height = 254
- end
- -- check if the script is running on a turtle
- -- (original code)
- if not turtle then
- print("")
- print("Error: not a turtle")
- return
- end
- -- move functions
- -- (original code)
- local mov = {}
- mov.forward = function ()
- while not turtle.forward() do
- sleep(1)
- end
- return true
- end
- mov.back = function ()
- while not turtle.back() do
- sleep(1)
- end
- return true
- end
- mov.up = function ()
- while not turtle.up() do
- sleep(1)
- end
- return true
- end
- mov.down = function ()
- while not turtle.down() do
- sleep(1)
- end
- return true
- end
- mov.place = function ()
- while not turtle.place() do
- sleep(1)
- end
- end
- mov.placeUp = function ()
- while not turtle.placeUp() do
- sleep(1)
- end
- end
- local base = nil
- -- Check if we have enough fuel
- -- we estimate the fuel usage ((height*2)+70) needed to
- -- complete the deoployment and then see if we have enough
- -- fuel loaded. If we don't, it checks the first slot for
- -- available fuel and tries to fill up on it. If it doesn't
- -- have enough fuel in there, it prompts the user for more
- -- fuel. It allows 30 seconds for the user to add fuel
- -- (trying to refuel and verify fuel level every second)
- -- and if it doesn't get it's fill within 30 seconds
- -- it exits with a message to the user
- -- neonerZ
- if type(turtle.getFuelLevel()) == "string" then
- print("No-fuel mode")
- else
- if turtle.getFuelLevel() < (tonumber(height)*2)+70 then
- while turtle.getFuelLevel() < (tonumber(height)*2)+70 do
- turtle.select(1)
- realcoal=(((tonumber(height)*2)+70)-turtle.getFuelLevel())/80
- if realcoal>=64 then
- coal=64
- else
- coal=math.ceil(realcoal)
- end
- if turtle.refuel(tonumber(coal)) == false then
- fuel=((tonumber(height)*2)+70)-turtle.getFuelLevel()
- print("")
- print("You ran out of fuel in slot 1")
- print("Please insert "..fuel.." fuel or "..realcoal.." coal to continue")
- print("Waiting 30 seconds for fuel or exiting")
- i=0
- while i<=30 do
- sleep(1)
- realcoal=(((tonumber(height)*2)+70)-turtle.getFuelLevel())/80
- if realcoal>=64 then
- coal=64
- else
- coal=math.ceil(realcoal)
- end
- turtle.refuel(tonumber(coal))
- if turtle.getFuelLevel() >= (tonumber(height)*2)+70 then
- print("")
- print("Turtle Fueled")
- i=31
- end
- if i==30 then
- fuel=((tonumber(height)*2)+70)-turtle.getFuelLevel()
- print("")
- print("Not enough fuel provided")
- print("Please provide "..fuel.." fuel or "..realcoal.." coal and try again")
- return
- end
- i=i+1
- end
- end
- end
- end
- end
- -- check if the required quantity of items
- -- are in the appropriate spots. I'm sure
- -- there's a more elegant way of doing this.
- -- I don't believe there's a way to check if
- -- the items are correct without using compare
- monitor=0
- modem=0
- diskdrive=0
- disk=0
- print("")
- turtle.select(2)
- if turtle.getItemCount(2) < 1 then
- print("Please place at least 4 computers into slot two")
- monitor=1
- end
- turtle.select(3)
- if turtle.getItemCount(2) < 1 then
- print("Please place at least 4 modems into slot three")
- modem=1
- end
- turtle.select(4)
- if turtle.getItemCount(2) < 1 then
- print("Please place 1 disk drive into slot four")
- diskdrive=1
- end
- turtle.select(5)
- if turtle.getItemCount(2) < 1 then
- print("Please place 1 disk into slot five")
- disk=1
- end
- if monitor == 1 or modem == 1 or diskdrive == 1 or disk == 1 then
- print("Please fix above issues to continue")
- return
- end
- -- start the climb up to the correct ycord
- while not turtle.up() do
- term.clear()
- term.setCursorPos(1,1)
- term.write("Please get off me")
- end
- for i = 3,tonumber(height) do
- turtle.up()
- end
- -- once at the correct height, deploy
- turtle.select(2)
- mov.placeUp()
- mov.down()
- turtle.select(3)
- mov.placeUp()
- mov.back()
- mov.up()
- turtle.select(4)
- mov.placeUp()
- turtle.select(5)
- turtle.dropUp()
- -- make a custom disk that starts up the gps host application
- -- with the correct coordinates and copy it over. also makes
- -- makes it a startup script so the computers will
- -- start back up properly after chunk unloading
- fs.delete("disk/startup")
- file = fs.open("disk/startup","w")
- file.write([[
- fs.copy("disk/install","startup")
- fs.delete("disk/startup")
- print("sleep in 10")
- sleep(10)
- os.reboot()
- ]])
- file.close()
- file = fs.open("disk/install","w")
- file.write([[
- shell.run("repeat")
- ]])
- file.close()
- turtle.turnLeft()
- mov.forward()
- mov.up()
- turtle.turnRight()
- mov.forward()
- turtle.turnRight()
- peripheral.call("front","turnOn")
- turtle.turnRight()
- mov.forward()
- turtle.turnLeft()
- turtle.suck()
- turtle.select(3)
- turtle.dig()
- -- goes back down. this is the original code
- mov.down()
- mov.down()
- mov.forward()
- turtle.turnLeft()
- mov.forward()
- while turtle.down() do
- end
- turtle = tMove
- print("")
- print("Finished")
Advertisement
Add Comment
Please, Sign In to add comment