Ledger Nano X - The secure hardware wallet
SHARE
TWEET

computercannon

kssr3951 Jul 25th, 2014 258 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- under construction !!
  2. os.loadAPI("Items") -- pastebin get 0geLX5MP Items
  3.  
  4. local ARMSG_SETUP_WAS_COMPLETED = 13
  5. local SETUP_SOURCE =
  6. [[
  7. os.setComputerLabel(PCID)
  8.  
  9. local hFile = fs.open("tntc.config", "w")
  10. hFile.writeLine(SETUP_CONFIG)
  11. hFile.close()
  12.  
  13. local hFile = fs.open("startup", "w")
  14. hFile.writeLine(STARTUP_SOURCE)
  15. hFile.close()
  16.  
  17. rs.setAnalogOutput(WAKEUP_SIGNAL_DIR, ARMSG_SETUP_WAS_COMPLETED)
  18. ]]
  19.  
  20. local COMPUTER_STARTUP_SOURCE =
  21. [[
  22. local hFile = fs.open("tntc.config", "r")
  23. local config = textutils.unserialize(hFile.readAll())
  24. hFile.close()
  25.  
  26. while true do
  27.   print(config.pcidBody)
  28.   os.sleep(1)
  29. end
  30. ]]
  31.  
  32.  
  33. local tntCannonId = "TNTC1_"
  34.  
  35. local reverseLog = ""
  36. local function createMoveWithReturnLogFunc(func, reverseCmd)
  37.   return
  38.     function()
  39.       func()
  40.       reverseLog = reverseCmd .. reverseLog
  41.     end
  42. end
  43.  
  44. local constructionMaterials =
  45. {
  46.   [Items.Wired_Modem.id          ] = { slot = {  1 }, count = {  2, 0, 2, 0, 0, 4, 0, 2 }, },
  47.   [Items.Networking_Cable.id     ] = { slot = {  2 }, count = {  2, 2, 2, 2, 2, 6, 4, 5 }, },
  48.   [Items.Computer.id             ] = { slot = {  3 }, count = {  2, 0, 4, 0, 0, 4, 2, 0 }, },
  49.   [Items.Dispenser.id            ] = { slot = {  4 }, count = {  2, 4, 2, 0, 6, 4, 1, 0 }, },
  50.   [Items.Wooden_Pressure_Plate.id] = { slot = {  5 }, count = {  0, 5, 0, 0, 0, 0, 0, 0 }, },
  51.   [Items.Red_Wool.id             ] = { slot = {  6 }, count = { 25, 0, 0, 0, 0, 0, 0, 0 }, },
  52.   [Items.Blue_Wool.id            ] = { slot = {  7 }, count = {  0, 0, 0, 0, 0, 0, 0, 0 }, },
  53.   [Items.Obsidian.id             ] = { slot = {  8 }, count = {  4, 0, 1, 3, 0, 0, 0, 0 }, },
  54.   [Items.Disk_Drive.id           ] = { slot = {  9 }, count = {  1, 0, 0, 0, 0, 0, 0, 0 }, },
  55.   [Items.Floppy_Disk.id          ] = { slot = { 10 }, count = {  1, 0, 0, 0, 0, 0, 0, 0 }, },
  56.   [Items.Turtle.id               ] = { slot = { 11 }, count = {  0, 0, 0, 0, 0, 0, 0, 1 }, },
  57.   [Items.Chest.id                ] = { slot = { 12 }, count = {  0, 0, 0, 0, 0, 0, 0, 1 }, },
  58.   [Items.Cobblestone_Slab.id     ] = { slot = { 13 }, count = {  0, 3, 0, 0, 0, 0, 0, 0 }, },
  59.   [Items.Water_Bucket.id         ] = { slot = { 14, 15 }, count = {  0, 2, 0, 0, 0, 0, 0, 0 }, },
  60.   [Items.Bucket.id               ] = { slot = { 16 }, count = {  0, 0, 0, 0, 0, 0, 0, 0 }, },
  61.  
  62. }
  63.  
  64. local selectedItemId
  65.  
  66. local function selectItem(itemId)
  67.   --print("selectItem =[" .. itemId .. "]")
  68.   selectedItemId = itemId
  69. end
  70.  
  71. local function getSelectedItemId()
  72.   return selectedItemId
  73. end
  74.  
  75. local function createSelectAndDoFunc(func)
  76.   return
  77.     function()
  78.       local selItemId = selectedItemId
  79.       --print("selItemId =[" .. selItemId .. "]")
  80.       if nil ~= constructionMaterials[selItemId] then
  81.         local slotAry = constructionMaterials[selItemId].slot
  82.         for i, val in pairs(slotAry) do
  83.           turtle.select(val)
  84.           if 0 < turtle.getItemCount(val) then
  85.             break
  86.           end
  87.         end
  88.       end
  89.       func()
  90.     end
  91. end
  92.  
  93. local function createRepeatUntilTrueFunc(func, msg)
  94.   return
  95.     function()
  96.       local rslt
  97.       repeat
  98.         rslt = func()
  99.         if not rslt then
  100.           print(msg)
  101.           os.sleep(1)
  102.         end
  103.       until rslt
  104.     end
  105. end
  106.  
  107. local cmds =
  108. {
  109.   p0 = createSelectAndDoFunc(turtle.placeUp),
  110.   p1 = createSelectAndDoFunc(turtle.place),
  111.   p2 = createSelectAndDoFunc(turtle.placeDown),
  112.   e0 = createSelectAndDoFunc(turtle.digUp), -- [e]xcavate
  113.   e1 = createSelectAndDoFunc(turtle.dig),
  114.   e2 = createSelectAndDoFunc(turtle.digDown),
  115.   f = createMoveWithReturnLogFunc(createRepeatUntilTrueFunc(turtle.forward  , "cannot move forward."), "b"),
  116.   b = createMoveWithReturnLogFunc(createRepeatUntilTrueFunc(turtle.back     , "cannot move back."   ), "f"),
  117.   u = createMoveWithReturnLogFunc(createRepeatUntilTrueFunc(turtle.up       , "cannot move up."     ), "d"),
  118.   d = createMoveWithReturnLogFunc(createRepeatUntilTrueFunc(turtle.down     , "cannot move down."   ), "u"),
  119.   l = createMoveWithReturnLogFunc(turtle.turnLeft , "r"),
  120.   r = createMoveWithReturnLogFunc(turtle.turnRight, "l"),
  121.   t0 = createSelectAndDoFunc(turtle.dropUp), -- [t]hrow
  122.   t1 = createSelectAndDoFunc(turtle.drop),
  123.   t2 = createSelectAndDoFunc(turtle.dropDown),
  124.   k0 = createSelectAndDoFunc(turtle.suckUp), -- suc[k]
  125.   k1 = createSelectAndDoFunc(turtle.suck),
  126.   k2 = createSelectAndDoFunc(turtle.suckDown),
  127. }
  128.  
  129. local cmdsMoveOnly =
  130. {
  131.   f = createRepeatUntilTrueFunc(turtle.forward, "cannot move forward."),
  132.   b = createRepeatUntilTrueFunc(turtle.back   , "cannot move back."   ),
  133.   u = createRepeatUntilTrueFunc(turtle.up     , "cannot move up."     ),
  134.   d = createRepeatUntilTrueFunc(turtle.down   , "cannot move down."   ),
  135.   l = turtle.turnLeft,
  136.   r = turtle.turnRight,
  137. }
  138.  
  139. local function addNote(itemId)
  140.   local note = Items[itemId].note
  141.   if "" ~= note then
  142.     return "(" .. note .. ")"
  143.   else
  144.     return ""
  145.   end
  146. end
  147.  
  148. local function getRequiredCnt(cntAry, lvAry)
  149.   if nil == lvAry then
  150.     lvAry = { }
  151.     for i, val in ipairs(cntAry) do
  152.       table.insert(lvAry, i)
  153.     end
  154.   end
  155.   ret = 0
  156.   for key, val in pairs(lvAry) do
  157.     if nil ~= cntAry[val] then
  158.       ret = ret + cntAry[val]
  159.     end
  160.   end
  161.   return ret
  162. end
  163.  
  164. local function doShowRequiredItems(lvAry)
  165.  
  166.   local remainTbl = { }
  167.   print("=== required items ===")
  168.   local slotFin
  169.   for i = 1, 16 do
  170.     if i == 9 then
  171.       print("Hit any key to continue.")
  172.       read()
  173.     end
  174.     slotFin = false
  175.     for key_j, val_j in pairs(constructionMaterials) do
  176.       for key_k, val_k in pairs(val_j.slot) do
  177.         if i == val_k then
  178.           local reqCnt = getRequiredCnt(val_j.count, lvAry)
  179.           print(string.format("slot%2d : %2d ", i, reqCnt) .. key_j .. addNote(key_j))
  180.           slotFin = true
  181.           break
  182.         end
  183.       end
  184.       if slotFin then
  185.         break
  186.       end
  187.     end
  188.   end
  189. end
  190.  
  191. local function burnCustomSetupDisk(floppyDir, pcidBody, wakeupSignalDir)
  192.   local config = { ["tntCannonId"] = tntCannonId, ["pcidBody"] = pcidBody, data = "hoehoe" }
  193.   local fullSetupSource
  194.     =  "local SETUP_CONFIG              = [[" .. textutils.serialize(config) .. "]]\n"
  195.     .. "local STARTUP_SOURCE            = [[" .. COMPUTER_STARTUP_SOURCE     .. "]]\n"
  196.     .. "local PCID                      = [[" .. tntCannonId .. pcidBody     .. "]]\n"
  197.     .. "local WAKEUP_SIGNAL_DIR         = [[" .. wakeupSignalDir             .. "]]\n"
  198.     .. "local ARMSG_SETUP_WAS_COMPLETED = " .. tostring(ARMSG_SETUP_WAS_COMPLETED) .. "\n"
  199.     .. SETUP_SOURCE
  200.  
  201.   local floppyPath = disk.getMountPath(floppyDir)
  202.   local hFile = fs.open(floppyPath .. "/startup", "w")
  203.   hFile.writeLine(fullSetupSource)
  204.   hFile.close()
  205. end
  206.  
  207. local function showRequiredItemsLv(level)
  208.   doShowRequiredItems({level})
  209. end
  210.  
  211. local function showRequiredItems()
  212.   doShowRequiredItems(nil)
  213. end
  214.  
  215. local function doCommand(cmdTable, script)
  216.   local cmd = string.gsub(script, " ", "") .. " "
  217.   local rslt
  218.   local startIdx = 1
  219.   while startIdx < #cmd do
  220.     local errorFlg = true
  221.     for key, func in pairs(cmdTable) do
  222.       rslt = string.find(cmd, key, startIdx, true)
  223.       if nil ~= rslt and 0 == rslt - startIdx then
  224.         func()
  225.         startIdx = startIdx + #key
  226.         errorFlg = false
  227.         break
  228.       end
  229.     end
  230.     if errorFlg then
  231.       error("bad script.")
  232.     end
  233.   end
  234. end
  235.  
  236. --[[
  237. local dict =
  238. {
  239.   ["."] = "blank",
  240.   ["W"] = "Wired modem and wire",
  241.   ["w"] = "wire",
  242.   ["c"] = "computer",
  243.   ["d"] = "dispenser",
  244.   ["p"] = "pressure plate",
  245.   ["r"] = "red wool",
  246. }
  247. --]]
  248.  
  249. -- =============================================================
  250. -- ==
  251. -- ==  LV 1
  252. -- ==
  253. -- =============================================================
  254. local function buildLv1()
  255.   --[[
  256.   local lv1 = [ [
  257.   rrrrrrr
  258.   rWrrrWr
  259.   rcdodcr
  260.   rrooorr
  261.   rrrrrrr
  262.   ] ]
  263.  
  264.   local lv1Ex = [ [
  265.   .......
  266.   .1...1.
  267.   .23.34.
  268.   .......
  269.   .......
  270.   ] ]
  271.   -- 1 : modem South direction
  272.   -- 2 : computer West direction (pcL1LW)
  273.   -- 3 : dispenser Top direction
  274.   -- 4 : computer East direction (pcL1RE)
  275.   --]]
  276.  
  277.   doCommand(cmds, "f")
  278.  
  279.   -- -----------------------
  280.   -- computer 1
  281.   -- -----------------------
  282.   doCommand(cmds, "uffrf")
  283.  
  284.   doCommand(cmds, "f")
  285.   selectItem(Items.Disk_Drive.id)
  286.   doCommand(cmds, "p2")
  287.   selectItem(Items.Floppy_Disk.id)
  288.   doCommand(cmds, "t2")
  289.   burnCustomSetupDisk("bottom", "pcL1RW", "top")
  290.   doCommand(cmds, "b")
  291.  
  292.   selectItem(Items.Computer.id)
  293.   doCommand(cmds, "p2")
  294.   peripheral.call("bottom", "turnOn")
  295.   os.sleep(6)
  296.   peripheral.call("bottom", "reboot")
  297.  
  298.   while true do
  299.     os.pullEvent("redstone")
  300.     if ARMSG_SETUP_WAS_COMPLETED == rs.getAnalogInput("bottom") then
  301.       break
  302.     end
  303.   end
  304.   doCommand(cmds, "f")
  305.  
  306.   selectItem(Items.Floppy_Disk.id)
  307.   doCommand(cmds, "k2")
  308.   selectItem(Items.Disk_Drive.id)
  309.   doCommand(cmds, "e2b")
  310.  
  311.   peripheral.call("bottom", "turnOn")
  312.   os.sleep(6)
  313.   peripheral.call("bottom", "reboot")
  314.  
  315.   doCommand(cmds, "lffdll")
  316.   selectItem(Items.Wired_Modem.id)
  317.   doCommand(cmds, "p1")
  318.   selectItem(Items.Networking_Cable.id)
  319.   doCommand(cmds, "p1")
  320.  
  321.   -- -----------------------
  322.   -- computer 2
  323.   -- -----------------------
  324.   doCommand(cmds, "lffffruf")
  325.   selectItem(Items.Disk_Drive.id)
  326.   doCommand(cmds, "p2")
  327.   selectItem(Items.Floppy_Disk.id)
  328.   doCommand(cmds, "t2")
  329.   burnCustomSetupDisk("bottom", "pcL1LE", "top")
  330.   doCommand(cmds, "fr")
  331.   selectItem(Items.Computer.id)
  332.   doCommand(cmds, "p2l")
  333.   peripheral.call("bottom", "turnOn")
  334.   os.sleep(6)
  335.   peripheral.call("bottom", "reboot")
  336.  
  337.   while true do
  338.     os.pullEvent("redstone")
  339.     if ARMSG_SETUP_WAS_COMPLETED == rs.getAnalogInput("bottom") then
  340.       break
  341.     end
  342.   end
  343.   doCommand(cmds, "b")
  344.  
  345.   selectItem(Items.Floppy_Disk.id)
  346.   doCommand(cmds, "k2")
  347.   selectItem(Items.Disk_Drive.id)
  348.   doCommand(cmds, "e2f")
  349.  
  350.   peripheral.call("bottom", "turnOn")
  351.   os.sleep(6)
  352.   peripheral.call("bottom", "reboot")
  353.  
  354.   doCommand(cmds, "bbd")
  355.   selectItem(Items.Wired_Modem.id)
  356.   doCommand(cmds, "p1")
  357.   selectItem(Items.Networking_Cable.id)
  358.   doCommand(cmds, "p1")
  359.  
  360.   -- -----------------------
  361.   -- dispenser x 2
  362.   -- -----------------------
  363.   doCommand(cmds, "uffrf")
  364.  
  365.   selectItem(Items.Dispenser.id)
  366.   doCommand(cmds, "p2") -- TODO direction TOP
  367.  
  368.   doCommand(cmds, "ff")
  369.  
  370.   selectItem(Items.Dispenser.id)
  371.   doCommand(cmds, "p2") -- TODO direction TOP
  372.  
  373.   doCommand(cmds, "ffrffr")
  374.  
  375.   -- -----------------------
  376.   -- other
  377.   -- -----------------------
  378.   selectItem(Items.Red_Wool.id)
  379.   doCommand(cmds, "p2fp2fp2fp2fp2fp2fp2")
  380.   doCommand(cmds, "rfr")
  381.   doCommand(cmds, "p2f f p2fp2fp2f f p2")
  382.   doCommand(cmds, "lfl")
  383.   doCommand(cmds, "p2fff")
  384.  
  385.   selectItem(Items.Obsidian.id)
  386.   doCommand(cmds, "p2fff")
  387.  
  388.   selectItem(Items.Red_Wool.id)
  389.   doCommand(cmds, "p2rfr")
  390.  
  391.   doCommand(cmds, "p2fp2f")
  392.  
  393.   selectItem(Items.Obsidian.id)
  394.   doCommand(cmds, "p2fp2fp2f")
  395.  
  396.   selectItem(Items.Red_Wool.id)
  397.   doCommand(cmds, "p2fp2")
  398.   doCommand(cmds, "lfl")
  399.  
  400.   doCommand(cmds, "p2fp2fp2fp2fp2fp2fp2")
  401.   doCommand(cmds, "bbbbbblu")
  402. end
  403.  
  404. -- =============================================================
  405. -- ==
  406. -- ==  LV 2
  407. -- ==
  408. -- =============================================================
  409. local function buildLv2()
  410.   --[[
  411.   local lv2 = [ [
  412.   .......
  413.   .wdodw.
  414.   .dqqqd.
  415.   .phhhp.
  416.   ..ppp..
  417.   ] ]
  418.  
  419.   local lv2Ex = [ [
  420.   .......
  421.   ..1.1..
  422.   .2...3.
  423.   .......
  424.   .......
  425.   ] ]
  426.   -- 1 : dispenser South direction
  427.   -- 2 : dispenser East direction
  428.   -- 3 : dispenser West direction
  429.   --]]
  430.   doCommand(cmds, "fffrf")
  431.   selectItem(Items.Networking_Cable.id)
  432.   doCommand(cmds, "p2")
  433.  
  434.   doCommand(cmds, "fl")
  435.   selectItem(Items.Dispenser.id)
  436.   doCommand(cmds, "p2 rf")
  437.  
  438.   selectItem(Items.Obsidian.id)
  439.   doCommand(cmds, "p2 fl")
  440.  
  441.   selectItem(Items.Dispenser.id)
  442.   doCommand(cmds, "p2 rf")
  443.  
  444.   selectItem(Items.Networking_Cable.id)
  445.   doCommand(cmds, "p2 rfl")
  446.  
  447.   selectItem(Items.Dispenser.id)
  448.   doCommand(cmds, "p2 llf")
  449.   doCommand(cmds, "fff")
  450.  
  451.   selectItem(Items.Dispenser.id)
  452.   doCommand(cmds, "p2 lfl")
  453.  
  454.   selectItem(Items.Wooden_Pressure_Plate.id)
  455.   doCommand(cmds, "p2 f")
  456.  
  457.   selectItem(Items.Cobblestone_Slab.id)
  458.   doCommand(cmds, "p2fp2fp2f")
  459.  
  460.   selectItem(Items.Wooden_Pressure_Plate.id)
  461.   doCommand(cmds, "p2 rfrf")
  462.  
  463.   doCommand(cmds, "p2fp2fp2")
  464.  
  465.   -- --> water
  466.   doCommand(cmds, "bbrffl")
  467.  
  468.   selectItem(Items.Water_Bucket.id)
  469.   doCommand(cmds, "p2")
  470.   turtle.transferTo(constructionMaterials[Items.Bucket.id].slot[1])
  471.  
  472.   selectItem(Items.Water_Bucket.id)
  473.   doCommand(cmds, "ffp2")
  474.   turtle.transferTo(constructionMaterials[Items.Bucket.id].slot[1])
  475.  
  476.   doCommand(cmds, "ffrbbu")
  477.   -- water <--
  478. end
  479.  
  480. -- =============================================================
  481. -- ==
  482. -- ==  LV 3
  483. -- ==
  484. -- =============================================================
  485. local function buildLv3()
  486.   --[[
  487.   local lv3 = [ [
  488.   .......
  489.   .WcocW.
  490.   .ododo.
  491.   .......
  492.   .......
  493.   ] ]
  494.  
  495.   local lv3Ex = [ [
  496.   .......
  497.   .12.23.
  498.   .54.46.
  499.   .......
  500.   .......
  501.   ] ]
  502.   -- 1 : modem East direction
  503.   -- 2 : computer North direction
  504.   -- 3 : modem West direction
  505.   -- 4 : dispenser Bottom direction
  506.   -- 5 : computer West direction
  507.   -- 6 : computer East direction
  508.   --]]
  509.   doCommand(cmds, "ffrf")
  510.   selectItem(Items.Obsidian.id)
  511.   doCommand(cmds, "p2lfr")
  512.  
  513.   -- -----------------------
  514.   -- computer 3
  515.   -- -----------------------
  516.   selectItem(Items.Disk_Drive.id)
  517.   doCommand(cmds, "p2")
  518.   selectItem(Items.Floppy_Disk.id)
  519.   doCommand(cmds, "t2")
  520.   burnCustomSetupDisk("bottom", "pcL3RBN", "top")
  521.   doCommand(cmds, "fr")
  522.   selectItem(Items.Computer.id)
  523.   doCommand(cmds, "p2l")
  524.   peripheral.call("bottom", "turnOn")
  525.   os.sleep(6)
  526.   peripheral.call("bottom", "reboot")
  527.  
  528.   while true do
  529.     os.pullEvent("redstone")
  530.     if ARMSG_SETUP_WAS_COMPLETED == rs.getAnalogInput("bottom") then
  531.       break
  532.     end
  533.   end
  534.   doCommand(cmds, "b")
  535.  
  536.   selectItem(Items.Floppy_Disk.id)
  537.   doCommand(cmds, "k2")
  538.   selectItem(Items.Disk_Drive.id)
  539.   doCommand(cmds, "e2f")
  540.  
  541.   peripheral.call("bottom", "turnOn")
  542.   os.sleep(6)
  543.   peripheral.call("bottom", "reboot")
  544.  
  545.   doCommand(cmds, "bbd")
  546.  
  547.   selectItem(Items.Wired_Modem.id)
  548.   doCommand(cmds, "p1")
  549.   selectItem(Items.Networking_Cable.id)
  550.   doCommand(cmds, "p1")
  551.  
  552.   -- -----------------------
  553.   -- computer 4
  554.   -- -----------------------
  555.   doCommand(cmds, "ufff")
  556.  
  557.   selectItem(Items.Disk_Drive.id)
  558.   doCommand(cmds, "p2")
  559.   selectItem(Items.Floppy_Disk.id)
  560.   doCommand(cmds, "t2")
  561.   burnCustomSetupDisk("bottom", "pcL3LBN", "top")
  562.   doCommand(cmds, "fr")
  563.  
  564.   selectItem(Items.Computer.id)
  565.   doCommand(cmds, "p2l")
  566.   peripheral.call("bottom", "turnOn")
  567.   os.sleep(6)
  568.   peripheral.call("bottom", "reboot")
  569.  
  570.   while true do
  571.     os.pullEvent("redstone")
  572.     if ARMSG_SETUP_WAS_COMPLETED == rs.getAnalogInput("bottom") then
  573.       break
  574.     end
  575.   end
  576.   doCommand(cmds, "b")
  577.  
  578.   selectItem(Items.Floppy_Disk.id)
  579.   doCommand(cmds, "k2")
  580.   selectItem(Items.Disk_Drive.id)
  581.   doCommand(cmds, "e2")
  582.  
  583.   -- --> obsidian
  584.   selectItem(Items.Obsidian.id)
  585.   doCommand(cmds, "p2")
  586.   -- <-- obsidian
  587.  
  588.   doCommand(cmds, "f")
  589.  
  590.   peripheral.call("bottom", "turnOn")
  591.   os.sleep(6)
  592.   peripheral.call("bottom", "reboot")
  593.  
  594.   doCommand(cmds, "fflld")
  595.  
  596.   selectItem(Items.Wired_Modem.id)
  597.   doCommand(cmds, "p1")
  598.   selectItem(Items.Networking_Cable.id)
  599.   doCommand(cmds, "p1 u")
  600.  
  601.   doCommand(cmds, "lfrf")
  602.  
  603.   -- --> obsidian
  604.   selectItem(Items.Obsidian.id)
  605.   doCommand(cmds, "p2")
  606.   -- <-- obsidian
  607.  
  608.   doCommand(cmds, "f")
  609.  
  610.   -- -----------------------
  611.   -- dispenser bottom
  612.   -- -----------------------
  613.   doCommand(cmds, "dd")
  614.   selectItem(Items.Dispenser.id)
  615.   doCommand(cmds, "p0") -- TODO bottom direction
  616.  
  617.   doCommand(cmds, "ff")
  618.  
  619.   selectItem(Items.Dispenser.id)
  620.   doCommand(cmds, "p0") -- TODO bottom direction
  621.   doCommand(cmds, "buu")
  622.  
  623.   -- obsidian
  624.   selectItem(Items.Obsidian.id)
  625.   doCommand(cmds, "p2 fff")
  626.  
  627.   doCommand(cmds, "rbbu")
  628. end
  629.  
  630. -- =============================================================
  631. -- ==
  632. -- ==  LV 4
  633. -- ==
  634. -- =============================================================
  635. local function buildLv4()
  636.   --[[
  637.   local lv4 = [ [
  638.   .......
  639.   .w...w.
  640.   .wooow.
  641.   .o...o.
  642.   .o...o.
  643.   ] ]
  644.   local lv4Ex = [ [
  645.   .......
  646.   .......
  647.   .1...1.
  648.   .......
  649.   .......
  650.   ] ]
  651.   -- 1 : modem bottom direction
  652.   --]]
  653.   doCommand(cmds, "rfl")
  654.   selectItem(Items.Obsidian.id)
  655.   doCommand(cmds, "p2fp2f")
  656.  
  657.   selectItem(Items.Networking_Cable.id)
  658.   doCommand(cmds, "p2fp2fp2 r")
  659.   doCommand(cmds, "fp2fp2fp2fp2 r")
  660.   doCommand(cmds, "fp2fp2")
  661.  
  662.   selectItem(Items.Obsidian.id)
  663.   doCommand(cmds, "fp2fp2 bbr fp2fp2fp2")
  664.  
  665.   doCommand(cmds, "ffrbbu")
  666. end
  667.  
  668. -- =============================================================
  669. -- ==
  670. -- ==  LV 5
  671. -- ==
  672. -- =============================================================
  673. local function buildLv5()
  674.   --[[
  675.   local lv5 = [ [
  676.   .......
  677.   .......
  678.   .wdodw.
  679.   .b...b.
  680.   ..d.d..
  681.  
  682.   .......
  683.   .......
  684.   .wdodw.
  685.   .d...d.
  686.   .cd.dc.
  687.   ] ]
  688.  
  689.   local lv5Ex = [ [
  690.   .......
  691.   .......
  692.   ..1.1..
  693.   .......
  694.   ..2.2..
  695.   ] ]
  696.   -- 1 : dispenser South direction
  697.   -- 2 : dispenser North direction
  698.   --]]
  699.   doCommand(cmds, "ffrf")
  700.   selectItem(Items.Networking_Cable.id)
  701.   doCommand(cmds, "p2 f")
  702.  
  703.   selectItem(Items.Dispenser.id)
  704.   doCommand(cmds, "lp2 rf")
  705.  
  706.   selectItem(Items.Obsidian.id)
  707.   doCommand(cmds, "p2 f")
  708.  
  709.   selectItem(Items.Dispenser.id)
  710.   doCommand(cmds, "lp2 rf")
  711.  
  712.   selectItem(Items.Networking_Cable.id)
  713.   doCommand(cmds, "p2 rfl")
  714.  
  715.   selectItem(Items.Dispenser.id)
  716.   doCommand(cmds, "p2ll ffff p2")
  717.  
  718.   doCommand(cmds, "lflf")
  719.   selectItem(Items.Dispenser.id)
  720.   doCommand(cmds, "rp2l f")
  721.  
  722.   selectItem(Items.Obsidian.id)
  723.   doCommand(cmds, "p2 f")
  724.  
  725.   selectItem(Items.Dispenser.id)
  726.   doCommand(cmds, "rp2l")
  727.  
  728.   -- -----------------------
  729.   -- computer z
  730.   -- -----------------------
  731.   doCommand(cmds, "ffll")
  732.   selectItem(Items.Disk_Drive.id)
  733.   doCommand(cmds, "p2")
  734.   selectItem(Items.Floppy_Disk.id)
  735.   doCommand(cmds, "t2")
  736.   burnCustomSetupDisk("bottom", "pcL5LE", "top")
  737.   doCommand(cmds, "f")
  738.   selectItem(Items.Computer.id)
  739.   doCommand(cmds, "rp2l")
  740.   peripheral.call("bottom", "turnOn")
  741.   os.sleep(6)
  742.   peripheral.call("bottom", "reboot")
  743.  
  744.   while true do
  745.     os.pullEvent("redstone")
  746.     if ARMSG_SETUP_WAS_COMPLETED == rs.getAnalogInput("bottom") then
  747.       break
  748.     end
  749.   end
  750.   doCommand(cmds, "b")
  751.  
  752.   selectItem(Items.Floppy_Disk.id)
  753.   doCommand(cmds, "k2")
  754.   selectItem(Items.Disk_Drive.id)
  755.   doCommand(cmds, "e2f")
  756.  
  757.   peripheral.call("bottom", "turnOn")
  758.   os.sleep(6)
  759.   peripheral.call("bottom", "reboot")
  760.  
  761.   -- -----------------------
  762.   -- computer z
  763.   -- -----------------------
  764.   doCommand(cmds, "fffffll")
  765.   selectItem(Items.Disk_Drive.id)
  766.   doCommand(cmds, "p2")
  767.   selectItem(Items.Floppy_Disk.id)
  768.   doCommand(cmds, "t2")
  769.   burnCustomSetupDisk("bottom", "pcL5RE", "top")
  770.   doCommand(cmds, "f")
  771.   selectItem(Items.Computer.id)
  772.   doCommand(cmds, "lp2r")
  773.   peripheral.call("bottom", "turnOn")
  774.   os.sleep(6)
  775.   peripheral.call("bottom", "reboot")
  776.  
  777.   while true do
  778.     os.pullEvent("redstone")
  779.     if ARMSG_SETUP_WAS_COMPLETED == rs.getAnalogInput("bottom") then
  780.       break
  781.     end
  782.   end
  783.   doCommand(cmds, "b")
  784.  
  785.   selectItem(Items.Floppy_Disk.id)
  786.   doCommand(cmds, "k2")
  787.   selectItem(Items.Disk_Drive.id)
  788.   doCommand(cmds, "e2f")
  789.  
  790.   peripheral.call("bottom", "turnOn")
  791.   os.sleep(6)
  792.   peripheral.call("bottom", "reboot")
  793.  
  794.   doCommand(cmds, "blu")
  795. end
  796.  
  797. -- =============================================================
  798. -- ==
  799. -- ==  LV 6
  800. -- ==
  801. -- =============================================================
  802. local function buildLv6()
  803.   --[[
  804.   local lv6 = [ [
  805.   .......
  806.   .......
  807.   .WcdcW.
  808.   .wd.dw.
  809.   .WcdcW.
  810.  
  811.   .......
  812.   .......
  813.   .WcdcW.
  814.   .wd.dw.
  815.   .W.d.W.
  816.   ] ]
  817.  
  818.   local lv6Ex = [ [
  819.   .......
  820.   .......
  821.   .12324.
  822.   ..5.5..
  823.   .8.7.8.
  824.   ] ]
  825.   -- 1 : Wired modem East Direction
  826.   -- 2 : Computer North direction
  827.   -- 3 : dispenser South direction
  828.   -- 4 : Wired modem West Direction
  829.   -- 5 : dispenser Bottom Direction
  830.   -- 6 : Computer South direction
  831.   -- 7 : dispenser North Direction
  832.   -- 8 : Wired modem bottom Direction
  833.   --]]
  834.   -- -----------------------
  835.   -- computer 7
  836.   -- -----------------------
  837.   doCommand(cmds, "ffrf")
  838.   selectItem(Items.Disk_Drive.id)
  839.   doCommand(cmds, "p2")
  840.   selectItem(Items.Floppy_Disk.id)
  841.   doCommand(cmds, "t2")
  842.   burnCustomSetupDisk("bottom", "pcL6RB", "top")
  843.   doCommand(cmds, "f")
  844.  
  845.   selectItem(Items.Computer.id)
  846.   doCommand(cmds, "r p2 l")
  847.   peripheral.call("bottom", "turnOn")
  848.   os.sleep(6)
  849.   peripheral.call("bottom", "reboot")
  850.  
  851.   while true do
  852.     os.pullEvent("redstone")
  853.     if ARMSG_SETUP_WAS_COMPLETED == rs.getAnalogInput("bottom") then
  854.       break
  855.     end
  856.   end
  857.   doCommand(cmds, "b")
  858.  
  859.   selectItem(Items.Floppy_Disk.id)
  860.   doCommand(cmds, "k2")
  861.   selectItem(Items.Disk_Drive.id)
  862.   doCommand(cmds, "e2f")
  863.  
  864.   peripheral.call("bottom", "turnOn")
  865.   os.sleep(6)
  866.   peripheral.call("bottom", "reboot")
  867.  
  868.   doCommand(cmds, "bbd")
  869.   selectItem(Items.Wired_Modem.id)
  870.   doCommand(cmds, "p1")
  871.   selectItem(Items.Networking_Cable.id)
  872.   doCommand(cmds, "p1")
  873.   doCommand(cmds, "u")
  874.  
  875.   -- dispanser
  876.   doCommand(cmds, "fff")
  877.   selectItem(Items.Dispenser.id)
  878.   doCommand(cmds, "l p2 r")
  879.  
  880.   -- -----------------------
  881.   -- computer 8
  882.   -- -----------------------
  883.   doCommand(cmds, "ffll")
  884.   selectItem(Items.Disk_Drive.id)
  885.   doCommand(cmds, "p2")
  886.   selectItem(Items.Floppy_Disk.id)
  887.   doCommand(cmds, "t2")
  888.   burnCustomSetupDisk("bottom", "pcL6RB", "top")
  889.   doCommand(cmds, "f")
  890.  
  891.   selectItem(Items.Computer.id)
  892.   doCommand(cmds, "l p2 r")
  893.   peripheral.call("bottom", "turnOn")
  894.   os.sleep(6)
  895.   peripheral.call("bottom", "reboot")
  896.   while true do
  897.     os.pullEvent("redstone")
  898.     if ARMSG_SETUP_WAS_COMPLETED == rs.getAnalogInput("bottom") then
  899.       break
  900.     end
  901.   end
  902.   doCommand(cmds, "b")
  903.  
  904.   selectItem(Items.Floppy_Disk.id)
  905.   doCommand(cmds, "k2")
  906.   selectItem(Items.Disk_Drive.id)
  907.   doCommand(cmds, "e2f")
  908.  
  909.   peripheral.call("bottom", "turnOn")
  910.   os.sleep(6)
  911.   peripheral.call("bottom", "reboot")
  912.  
  913.   doCommand(cmds, "bbd")
  914.   selectItem(Items.Wired_Modem.id)
  915.   doCommand(cmds, "p1")
  916.   selectItem(Items.Networking_Cable.id)
  917.   doCommand(cmds, "p1 u")
  918.  
  919.  
  920.   doCommand(cmds, "flfr")
  921.  
  922.   selectItem(Items.Networking_Cable.id)
  923.   doCommand(cmds, "p2")
  924.  
  925.   -- -----------------------
  926.   -- dispenser bottom
  927.   -- -----------------------
  928.   doCommand(cmds, "f")
  929.   doCommand(cmds, "dd")
  930.   selectItem(Items.Dispenser.id)
  931. --  doCommand(cmds, "p0") -- TODO bottom direction
  932.   doCommand(cmds, "llp0ll")
  933.  
  934.   doCommand(cmds, "ff")
  935.  
  936.   selectItem(Items.Dispenser.id)
  937.   doCommand(cmds, "p0") -- TODO bottom direction
  938.   doCommand(cmds, "buu")
  939.  
  940.  
  941.   doCommand(cmds, "ff")
  942.   selectItem(Items.Networking_Cable.id)
  943.   doCommand(cmds, "p2")
  944.  
  945.   doCommand(cmds, "lfl")
  946.  
  947.   selectItem(Items.Wired_Modem.id)
  948.   doCommand(cmds, "p2")
  949.   selectItem(Items.Networking_Cable.id)
  950.   doCommand(cmds, "p2")
  951.  
  952.   doCommand(cmds, "ffff")
  953.  
  954.   selectItem(Items.Wired_Modem.id)
  955.   doCommand(cmds, "p2")
  956.   selectItem(Items.Networking_Cable.id)
  957.   doCommand(cmds, "p2")
  958.  
  959.   selectItem(Items.Obsidian.id)
  960.   doCommand(cmds, "bp2bp2bp2")
  961.  
  962.   doCommand(cmds, "bblu")
  963. end
  964.  
  965. -- =============================================================
  966. -- ==
  967. -- ==  LV 7
  968. -- ==
  969. -- =============================================================
  970. local function buildLv7()
  971.   --[[
  972.   local lv7 = [ [
  973.   .......
  974.   .......
  975.   .wwcww.
  976.   ...d...
  977.   .......
  978.   ] ]
  979.  
  980.   local lv7Ex = [ [
  981.   .......
  982.   .......
  983.   ...1...
  984.   ...2...
  985.   ...3...
  986.   ] ]
  987.   -- 1 : computer North direction
  988.   -- 2 : dispenser Bottom direction
  989.   -- 3 : computer South direction
  990.   --]]
  991.  
  992.   doCommand(cmds, "frf")
  993.   selectItem(Items.Obsidian.id)
  994.   doCommand(cmds, "p2 ffff p2 brfr p2fp2fp2 rfl")
  995.  
  996.   -- -----------------------
  997.   -- computer 3
  998.   -- -----------------------
  999.   selectItem(Items.Disk_Drive.id)
  1000.   doCommand(cmds, "p2")
  1001.   selectItem(Items.Floppy_Disk.id)
  1002.   doCommand(cmds, "t2")
  1003.   burnCustomSetupDisk("bottom", "pcL7E", "top")
  1004.   doCommand(cmds, "rfl")
  1005.   selectItem(Items.Computer.id)
  1006.   doCommand(cmds, "p2")
  1007.   peripheral.call("bottom", "turnOn")
  1008.   os.sleep(6)
  1009.   peripheral.call("bottom", "reboot")
  1010.  
  1011.   while true do
  1012.     os.pullEvent("redstone")
  1013.     if ARMSG_SETUP_WAS_COMPLETED == rs.getAnalogInput("bottom") then
  1014.       break
  1015.     end
  1016.   end
  1017.   doCommand(cmds, "fflld")
  1018.  
  1019.   selectItem(Items.Wired_Modem.id)
  1020.   doCommand(cmds, "p1")
  1021.   selectItem(Items.Networking_Cable.id)
  1022.   doCommand(cmds, "p1")
  1023.  
  1024.   doCommand(cmds, "ufffdr")
  1025.  
  1026.   selectItem(Items.Turtle.id)
  1027.   doCommand(cmds, "p1")
  1028.  
  1029.   doCommand(cmds, "lfr")
  1030.   selectItem(Items.Chest.id)
  1031.   doCommand(cmds, "p1")
  1032.  
  1033.   --
  1034.   doCommand(cmds, "urffff lffll")
  1035.   doCommand(cmds, "b ddddddd")
  1036.  
  1037. end
  1038.  
  1039. -- -------------------------------------
  1040. -- main
  1041. -- -------------------------------------
  1042. --showRequiredItemsLv(1)
  1043. showRequiredItems()
  1044. print("Hit any key when ready.")
  1045. read()
  1046.  
  1047. --[[
  1048. --]]
  1049. buildLv1()
  1050. buildLv2()
  1051. buildLv3()
  1052. buildLv4()
  1053. buildLv5()
  1054. buildLv6()
  1055. buildLv7()
  1056. --[[
  1057. --]]
  1058.  
  1059. print("Finished.")
  1060. --print("Hit any key, to go back to the start position.")
  1061. --read()
  1062. --doCommand(cmdsMoveOnly, reverseLog)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top