jille_Jr icon

CC: Disposal

jille_Jr | PRO | 12/17/12 02:26:25 PM UTC | 0 ⭐ | 346 👁️ | Never ⏰ | []
Lua |

1.89 KB

|

None

|

0 👍

/

0 👎

--[[
    This script is used at the server
    Geevancraft 2.
    It is a secret way of storing
    my valuables.
]]--
 
local dif = 25
local rec = 0 -- rednet receiver id
 
for i = 1, 16 do
  if turtle.getItemCount(i)>0 then
    break
  end
  if i == 16 then
    print("You need at least 1 item to preform this program!")
    return
  end
end
 
 
rednet.open("right")
rednet.send(rec,"Disposaling items!")
rednet.send(rec,"Heading up... ")
write("Heading up... ")
 
function down()
  write("Heading down... ")
  rednet.send(rec, "Heading down...")
  local count = 0
  while not turtle.detectDown() do
    count = count + 1
    if count % dif == 0 then
      rednet.send(rec,"Progress: "..count.." blocks!")
    end
    count2 = 0
    while not turtle.down() do
      if not turtle.digDown() then
        if not turtle.attackDown() then
          count2 = count2 + 1
          if count2 % dif == 0 then
            print("Failed!")
            rednet.send(rec,"Failed!")
            return
          end
          sleep(1)
        end
      end
    end
  end
  print("Success!")
  rednet.send(rec,"Success!")
end
 
local count = 0
repeat
  status = turtle.up()
  count = count + 1
  if count % dif == 0 then
    rednet.send(rec,"Progress: "..count.." blocks!")
  end
  if not status then
    if count % dif == 0 then
      rednet.send(rec,"Failed!")
      print("Failed!")
      down()
      rednet.close("right")
      return
    end
  end
until turtle.detectUp()
 
print("Success!")
rednet.send(rec,"Success!")
rednet.send(rec,"Dropping off items...")
write("Dropping off items... ")
 
for i = 1, 16 do
  if turtle.getItemCount(i) > 0 then
    turtle.select(i)
    if not turtle.dropUp() then
      rednet.send("Failed!")
      print("Failed!")
      break
    end
  end
end
rednet.send(rec,"Success!")
print("Success!")
turtle.select(1)
down()
rednet.close("right")

Comments