Advertisement
guitarplayer616

Nonstop Schematic Turtle Setup Backup

Dec 12th, 2015
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.08 KB | None | 0 0
  1. --if not fs.exists("schemAPI") then
  2.         fs.delete("schemAPI")
  3.         shell.run("pastebin get YT3QUqq7 schemAPI")    
  4. --end
  5.  
  6.  
  7. function copySetupVars()
  8.         local h = fs.open("reference",'w')
  9.         h.writeLine("slots = {}")
  10.         h.writeLine("filename = ".."\""..tostring(filename).."\"")
  11.         for i,v in pairs(slots) do
  12.                 h.writeLine("slots\["..i.."\] = {}")
  13.                 for i2,v2 in pairs(v) do
  14.                         h.writeLine("slots\["..i.."\]\["..i2.."\] = {}")
  15.                         for i3,v3 in pairs(v2) do
  16.                                 h.writeLine("slots\["..i.."\]\["..i2.."\]\["..i3.."\] = "..tostring(v3))
  17.                         end
  18.                 end
  19.         end
  20.         h.writeLine("invList = {}")
  21.         for i,v in pairs(invList) do
  22.                 h.writeLine("invList\["..i.."\] = {}")
  23.                 for i2,v2 in pairs(v) do
  24.                         h.writeLine("invList\["..i.."\]\[".."\""..i2.."\"".."\] = "..tostring(v2))
  25.                 end
  26.         end
  27.         h.writeLine("blocks = {}")
  28.         for i,v in pairs(blocks) do
  29.                 h.writeLine("blocks\["..i.."\] = "..tostring(v))
  30.         end
  31.  
  32.         h.writeLine("data = {}")
  33.         for i,v in pairs(data) do
  34.                 h.writeLine("data\["..i.."\] = "..tostring(v))
  35.         end
  36.         h.writeLine("height = "..tostring(height))
  37.         h.writeLine("width = "..tostring(width))
  38.         h.writeLine("length = "..tostring(length))
  39.         h.writeLine("chestOrder = "..tostring(chestOrder))
  40.         h.writeLine("enderchest1 = "..tostring(enderchest1))
  41.         h.writeLine("enderchest2 = "..tostring(enderchest2))
  42.         h.close()
  43. end
  44.  
  45. if not fs.exists("reference") then
  46.         shell.run("schemAPI")
  47.         heightPos = -1
  48.         widthPos = 0
  49.         lengthPos = 0
  50.         face = "south"
  51.         x = 0
  52.         y = 0
  53.         z = 0
  54.         enderchest1 = 15
  55.         enderchest2 = 16
  56.         chestOrder = 1
  57.         blocks = {}
  58.         data = {}
  59.         tArgs = {...}
  60.         if #tArgs ~= 1 then
  61.                 print("Usage: schemSetup <gunzipped schematic file>")
  62.                 return
  63.         end
  64.  
  65.         filename = tArgs[1]
  66.  
  67.         if not fs.exists(filename) then
  68.                 print("File does not exist.")
  69.                 return
  70.         end
  71.  
  72.         handle = fs.open(filename, "rb")
  73.  
  74.         setup()
  75.         copySetupVars()
  76. end
  77.  
  78.  
  79.  
  80. if turtle.getFuelLevel() == 0 then
  81.         print("No Fuel")
  82.         error()
  83. elseif turtle.getFuelLevel() < 300 then
  84.         print("Low Fuel")
  85.         error()
  86. end
  87.  
  88. function recordPos(heightPos,widthPos,lengthPos,face)
  89.         local h = fs.open("position","w")
  90.         h.writeLine("heightPos = "..tostring(heightPos))
  91.         h.writeLine("widthPos = "..tostring(widthPos))
  92.         h.writeLine("lengthPos = "..tostring(lengthPos))
  93.         h.writeLine("face = ".."\""..tostring(face).."\"")
  94.         h.close()
  95. end
  96.  
  97. recordPos(-1,0,0,"south")
  98. recordObj(x,y,z)
  99.  
  100.  
  101. local h = fs.open("start","w")
  102. h.write([[
  103. shell.run("reference")
  104. shell.run("schemAPI")
  105. autorun()
  106. ]])
  107. h.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement