Advertisement
Guest User

LIB

a guest
May 22nd, 2015
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 27.82 KB | None | 0 0
  1. -- Local Varables
  2. --rednet.open("right")
  3. local intro = "INTRODUCTION INDEX: " -- 22
  4. local t = 0.1
  5. local red = 0
  6. local a = 0.25 -- Animate Speed
  7. local n = 1
  8. local bRunning = true
  9. local sid = 0 -- 0 = loop 1 = not loop
  10. --local success, data = turtle.inspect()
  11. local testitem = 0
  12. local tdetectOut = false
  13. local readt = 0.75
  14. ptrue = "true"
  15. pfalse = "false"
  16. -- Crafter Varables
  17. local loc = 1
  18. local sid = 1
  19. local sidD = 1
  20. local bRunning = true
  21. local curX = 2
  22. local curY = 11
  23. local clrX = 3
  24. local clrY = 11
  25. local t = 0.3
  26. local i = 1
  27. local x = 1
  28. local a = 64
  29. --sel
  30. local b2 = 1 -- a1 for
  31. local n2 = 5 -- a2 for
  32. local m2 = 9 -- a3 for
  33. local b = 1 -- 1 for
  34. local n = 5 -- 2 for
  35. local m = 9 -- 3 for
  36. local work = colors.blue
  37. local work2 = colors.cyan
  38. local draw = {"1","2","3","4","5","6","7","8","9"}
  39. local targs = command
  40.  
  41. -- Lower Tier Functions
  42.  
  43. function waitT(ptime)
  44.  os.sleep(ptime)
  45.   end
  46.  
  47. function stime(sleeptime)
  48.  sleep(sleeptime)
  49.   end
  50.  
  51. function setCur(x1, y1)
  52. term.setCursorPos(x1, y1)
  53. end
  54.  
  55. function clr()
  56. term.clear()
  57. setCur(1, 1)
  58. end
  59.  
  60. function clrl(xclr, yclr)
  61. setCur(xclr, yclr)
  62. term.clearLine(xclr, yclr)
  63. end
  64.  
  65. function text(textU,textT)
  66. textutils.slowPrint(textU)
  67. sleep(textT)
  68. end
  69.  
  70. function LockOut()
  71. os.pullEvent = os.pullEventRaw
  72. end
  73. -- Slighty Adv functions
  74. -- Other Functions Below This one
  75. function setColor(txtColor,bgColor)
  76.  if term.isColor then
  77.  if term.isColor() then
  78.  if txtColor then
  79. term.setTextColor(txtColor)
  80. end
  81.  if bgColor then
  82.  term.setBackgroundColor(bgColor)
  83. end
  84.    end
  85.       end
  86.          end
  87.  
  88.  function setTC(textPrint,txtColor,bgColor)
  89.  if term.isColor then
  90.  if term.isColor() then
  91.  if txtColor then
  92.  term.setTextColor(txtColor)
  93.  print(textPrint)
  94.  end
  95.     if bgColor then
  96.     term.setBackgroundColor(bgColor)
  97. end
  98.    end
  99.       end
  100.          end
  101.          
  102.  
  103. --
  104.  
  105. function invP(pass,sym,xPo,yPo) -- Inside LIB
  106.    LockOut()
  107.    if pass == nil then
  108.    setColor(colors.cyan)
  109.    print("Needs a Password!")
  110.    elseif sym == nil then
  111.    setColor(colors.cyan)
  112.    print("Needs a Symbol!")
  113.    elseif xPo == nil then
  114.    setColor(colors.cyan)
  115.    print("Needs a X set!")
  116.    elseif yPo == nil then
  117.    setColor(colors.cyan)
  118.    print("Needs a Y set!")
  119.    else
  120.    code = ""
  121.    setColor(colors.black)
  122.    setCur(xPo,yPo)
  123.    code = read(sym)
  124.    if code == pass then
  125.    setColor(colors.lime)
  126.    setCur(1,5)
  127.    print("|====UNLOCKED!====|")
  128.    sleep(0.10)
  129.    setCur(xPo,yPo)
  130.    else
  131.    setColor(colors.red)
  132.    setCur(xPo,yPo)
  133.    print ','
  134.    sleep(0.10)
  135.    LockScreen()
  136.   end
  137.      end
  138.         end
  139.  
  140. function checkrun(xpo,ypo)
  141. if xpo == nil then
  142. setColor(colors.lime)
  143. print("Function setup!")
  144. setColor(colors.green)
  145. print("Function Error Please Read...")
  146. error("checkrun Needs a Xpos Set.")
  147. elseif xpo == 0 then
  148. xpo = 1
  149. elseif ypo == nil then
  150. setColor(colors.green)
  151. print("Function Error Please Read...")
  152. error("checkrun Needs Set To 1")
  153. elseif xpo == 0 then
  154. xpo = 1
  155. else
  156. if turtle then
  157.  term.clear()
  158.  term.setCursorPos(xpo,ypo)
  159.  setColor(colors.lime)
  160.  print("Local Tech: "..tostring("Turtle"))
  161. else
  162.  term.clear()
  163.  term.setCursorPos(xpo,ypo)
  164.  setColor(colors.lime)
  165. print("Local Tech: "..tostring("Computer"))
  166. end
  167.    end
  168.       end
  169.  
  170. function keydraw()
  171. print("------------")
  172. setCur(1, 2)
  173. print("| KEY READ |")
  174. setCur(1,3)
  175. print("------------")
  176. end
  177.  
  178. function keyread()
  179. clr()
  180. keydraw()
  181. while true do
  182.   event, key = os.pullEvent("key")
  183.   clr()
  184.   keydraw()
  185.   print("Your Key: "..key)
  186.   if event == "key" then
  187.   if key == keys.backspace then
  188.   sleep(0.50)
  189.   clr()
  190.   return false
  191. end  
  192.    end
  193.       end
  194.          end
  195.  
  196.  function Init(inNum)
  197.  setTC("["..intro.."] ".." ["..inNum.."]",colors.lime)
  198.  end
  199.  
  200.  function setnext(txtX,txtY)
  201.  setCur(txtX,txtY)
  202.  setTC("[PRESS ANY KEY TO NEXT!]",colors.green)
  203.  end
  204.  
  205.  function setend(txtX,txtY)
  206.  setCur(txtX,txtY)
  207.  setTC("[PRESS ANY KEY TO END!]",colors.lime)
  208.  end
  209.  
  210. function LockScreen(pass,sym,xPo,yPo)
  211.    clr()
  212.    setTC("|-----------------|",colors.green)
  213.    setTC("|% LOCKED SCREEN %|",colors.lime)
  214.    setTC("|% CONTACT ADMIN %|",colors.lime)  
  215.    setTC("                  ",colors.green)
  216.    setTC("|====< ADMIN >====|",colors.lime)
  217.    invP("4321","*",3,4)
  218.    end
  219.      
  220.      
  221. function showProgram(colorT) -- NextPrg/ExitPrg = 12,19
  222.    clr()
  223.    Init(1)
  224.    setTC("[ WELCOME THIS IS  ]",colorT)
  225.    setTC("[ USELESS SCREEN   ]",colorT)  
  226.    setTC("[ FOR NOW.....     ]",colorT)
  227.    setTC("[ ---------------  ]",colorT)
  228.    setnext(12,19)
  229.    os.pullEvent("key")
  230.    clr()
  231.    Init(2)
  232.    setTC("[Welcome To The ShowProgram]",colorT)
  233.    setTC("[There Are 63+ Functions!  ]",colors.colorT)
  234.    setTC("[--------------------------]",colorT)
  235.    setTC("[]",colorT)
  236.    setnext(12,19)
  237.    os.pullEvent("key")
  238.    clr()
  239.    Init(3)
  240.    setTC("[Hello This Is The Exit Page!]")
  241.    setTC("[----------------------------]")
  242.    setTC("[]")
  243.    setTC("[]")
  244.    setTC("[]")
  245.    setTC("[]")
  246.    setend(12,19)
  247.    os.pullEvent("key")
  248.    clr()
  249.    print("Do you Want To reboot?")
  250.    if InA == "yes" then
  251.      os.reboot()
  252.      elseif InA == "no" then
  253.        clr()
  254.        print(": ")
  255.        return
  256.     end
  257.        end
  258.    
  259. -- Lock Functions
  260.    function lock(pass,sym,colSet,ySet,statlock,xpo,ypo) -- statlock is if you want clr for LIB "on" or "off"
  261.    if pass == nil then
  262.    setColor(colors.lime)
  263.    print("SETUP FOR PASSWORD API!")
  264.    setColor(colors.green)
  265.    print("Function Error Please Read...")
  266.    error("Needs a ".."('".."password".."')")      
  267.    elseif sym == nil then
  268.    setColor(colors.green)
  269.    print("Function Error Please Read...")
  270.    error("Needs a Symbol, In Function: lock")
  271.    elseif colSet == nil then
  272.    setColor(colors.green)
  273.    print("Function Error Please Read...")
  274.    error("Needs a Color,  In Function: lock")
  275.    elseif ySet == nil then
  276.    setColor(colors.green)
  277.    print("Function Error Please Read...")
  278.    error("Ypos Needs Set To 2 In Function: lock ")
  279.    elseif statlock == nil then
  280.    setColor(colors.green)
  281.    print("Function Error Please Read...")
  282.    error("Section 5 Need To Be Set: 0 = Clr On 1 = Clr Off")
  283. else
  284.    if statlock == 1 then
  285.    clr()
  286.    elseif statlock ~= 1 then
  287.    setColor(colSet)
  288.    checkrun(xpo,ypo)
  289.    print("[Enter Code]: ")
  290.    setColor(colors.lime)
  291.    setCur(14,ySet)
  292.    code = read(sym)
  293.    if code == pass then
  294.    setColor(colors.lime)
  295.    print 'Password Accepted!'
  296.    else
  297.    setColor(colors.red)
  298.    print 'Password Denied!'
  299.    sleep(0.25)
  300.    LockScreen()
  301.    end
  302.       end
  303.          end
  304.             end
  305. -- Run Lib Shit Here
  306. -- clr()
  307. -- lock("1234","*",colors.yellow,2,0,1,1)
  308.  
  309.            
  310.   -- Other Locks That I Dont Really Use.    
  311.    function masterLock()
  312.        clr()
  313.        setColor(colors.yellow)
  314.        print("-----------------")
  315.        setColor(colors.cyan)
  316.        textutils.slowPrint("% Computer Lock %")
  317.        setColor(colors.yellow)
  318.        print("-----------------")
  319.        setColor(colors.green)
  320.        print("")
  321.        if fs.exists("/.password") then
  322.        setColor(colors.green)
  323.        write("Password: ")
  324.        file = fs.open("/.password","r")
  325.        correctpassword = file.readAll()
  326.        file.close()
  327.        setColor(colors.lime)
  328.        password = read("*")
  329.        if password == correctpassword then
  330.          clr()
  331.          setColor(colors.green)
  332.          print("Password Accumalated Correctly!...")
  333.          sleep(0.25)
  334.          clr()
  335.           -- .test
  336.          else
  337.          print("")
  338.          setColor(colors.red)
  339.          write("Password Accumalated Incorrectly!...")
  340.          sleep(0.25)
  341.          clr()
  342.          masterLock()
  343.          end
  344.             else
  345.                 clr()
  346.                 setColor(colors.yellow)
  347.                 textutils.slowPrint("No Password Has Been Generated")
  348.                 sleep(0.25)
  349.                 textutils.slowPrint("How About You Genarated One Now -->")
  350.                 sleep(0.25)
  351.                 setColor(colors.green)
  352.                 write("New Password: ")
  353.                             setColor(colors.lime)
  354.                 newPassword = read("*")
  355.                 file = fs.open("/.password","w")
  356.                 file.write(newPassword)
  357.                 file.close()
  358.                 clr()
  359.                 setColor(colors.green)
  360.                 textutils.slowPrint("New Password Has Been Genarated Sucessfuly!...")
  361.                 sleep(0.25)
  362.                 clr()
  363.                 setColor(colors.cyan)
  364.                 print("Resetting...")
  365.                 sleep(0.15)
  366.                 return
  367.                 end
  368.                                   end
  369.          
  370.  function getPass(checkPass)
  371.  pass = ""
  372.  clr()
  373.  setColor(colors.yellow)
  374.  term.write("Plase Enter Password: ")
  375.  pass = read("*")
  376.  if pass ~= checkPass then
  377.  setColor(colors.red)
  378.  print("Password Incorrect!!")
  379.  sleep(0.25)
  380.  getPass(checkPass)
  381. else
  382.  clr()
  383.  setColor(colors.green)
  384.  print("Password Correct!!")
  385.  sleep(0.25)
  386.  clr()
  387.  setColor(colors.yellow)
  388.  print(">")
  389.  setCur(2, 1)
  390.  end
  391.     end  
  392. -- End Of locks    
  393. function Pgui()
  394. clr()
  395. print("Welcome to pulser")
  396. print("Please type in direction")
  397. print("-----------------------------")
  398. print("back")
  399. print("left")
  400. print("right")
  401. print("front")
  402. print("bottom")
  403. print("top")
  404. print("-----------------------------")
  405. end
  406.    
  407. function pulse()
  408. Pgui()
  409. direct = "top"
  410. interval = 0
  411. count = 0
  412. direction = read()
  413. if direction == "back" or direction == "left" or direction == "right" or direction == "front" or direction == "bottom" or direction == "top" then
  414.     direct = direction
  415.      
  416.     term.clear()
  417.     term.setCursorPos(1,1)
  418.     print("-----------------------------")
  419.     print("Please choose the interval (seconds)")
  420.     print("-----------------------------")
  421.     inter = read()
  422.         if tonumber(inter) > 0 then
  423.             interval = tonumber(inter)
  424.            
  425.             term.clear()
  426.         term.setCursorPos(1,1)
  427.     print("-----------------------------")
  428.     print("How many pulses")
  429.     print("-----------------------------")  
  430.     coun = read()
  431.     count = coun
  432.     term.clear()
  433.     term.setCursorPos(1,1)
  434.      
  435.     for i = 0, count-1, 1 do
  436.         redstone.setOutput(direction, true)
  437.         sleep(interval)
  438.         redstone.setOutput(direction, false)
  439.         sleep(interval)
  440.         i = i + 1
  441.         term.clear()
  442.         term.setCursorPos(1,1)
  443.         j = (count) - i
  444.         print("Pulses Done: " .. i)
  445.         print("Pulses Remaining: " ..j)
  446.          
  447.         end
  448.         if i == count then
  449.         os.shutdown()
  450.     end    
  451.         else
  452.             os.shutdown()
  453.          end
  454.              end   
  455.                     end
  456.  
  457. -- function Menu(...)-- Put the menu text in. User chooses one. The function returns the selection he choose.
  458. -- --You now need to type in the number the menu starts, and the number it ends
  459.   -- local Parameters = {...}
  460.   -- local MenuStuff = nil
  461.   -- local first = Parameters[1]
  462.   -- local second = Parameters[2]
  463.   -- if type(Parameters[3]) == string or type(Parameters[3]) == "string" then
  464.     -- local temptable = Parameters
  465.     -- table.remove(temptable, 1)
  466.     -- table.remove(temptable, 1)
  467.     -- MenuStuff = temptable
  468.   -- else
  469.     -- MenuStuff = Parameters[3]
  470.   -- end
  471.   -- local Mouse = first
  472.   -- local function rewrite()
  473.         -- local i = 0
  474.         -- for n=first, second do
  475.           -- i = i+1
  476.           -- if MenuStuff[i+DownDown] then
  477.                 -- term.setCursorPos(4, n)
  478.                 -- term.write(string.rep(" ", string.len(MenuStuff[i+DownDown])))
  479.           -- end
  480.         -- end
  481.   -- end
  482.   -- local function Draw()
  483.         -- local i = 0
  484.         -- for n=first,second do
  485.           -- i = i+1
  486.           -- term.setCursorPos(4, n)
  487.           -- term.write(MenuStuff[i+DownDown])
  488.         -- end
  489.         -- term.setCursorPos(1, Mouse)
  490.         -- term.write(">>")
  491.   -- end
  492.   -- Draw()
  493.   -- while true do
  494.         -- event,param1 = os.pullEvent()
  495.         -- if event == "key" then
  496.           -- term.setCursorPos(1, Mouse)
  497.           -- term.write("  ")
  498.           -- rewrite()
  499.           -- if param1 == 200 then -- Up
  500.                 -- if Scrolled > 1 then
  501.                   -- if Mouse == first and MenuStuff[Scrolled-1] then
  502.                         -- DownDown = DownDown-1
  503.                   -- else
  504.                         -- Mouse = Mouse-1
  505.                   -- end
  506.                   -- Scrolled = Scrolled-1
  507.                 -- end
  508.           -- elseif param1 == 208 then -- Down
  509.                 -- if Scrolled < #MenuStuff then
  510.                   -- if Mouse == second then
  511.                         -- DownDown = DownDown+1
  512.                   -- else
  513.                         -- Mouse = Mouse+1
  514.                   -- end
  515.                   -- Scrolled = Scrolled+1
  516.                 -- end
  517.           -- elseif param1 == 28 then -- Enter
  518.                 -- rewrite()
  519.                 -- return MenuStuff[Scrolled]
  520.            -- -- break
  521.           -- end  
  522.           -- Draw()
  523.         -- end
  524.   -- end
  525. -- end
  526.                    
  527. -- function helpUi()
  528. -- clr()
  529. -- setColor(colors.yellow)
  530. -- term.write("Command> ")
  531. -- setCur(9,1)
  532. -- end
  533.  
  534. -- function helpDraw()
  535. -- print("[ -------------------- ]")
  536. -- setColor(colors.green)
  537. -- print("   Known Functions    ")
  538. -- setColor(colors.green)
  539. -- print("| In This Api There Is ")
  540. -- setColor(colors.green)
  541. -- print("| 65 Functions Total.  ")
  542. -- setColor(colors.yellow)
  543. -- print("[ --------------------   ")
  544. -- setColor(colors.green)
  545. -- print("|    [Type help 1-9]    ")        
  546. -- setColor(colors.green)
  547. -- print("|                               ")
  548. -- setColor(colors.yellow)
  549. -- print("[ --------------------   ")
  550. -- end
  551.  
  552.  
  553. -- local targs = {...}
  554. -- function help()
  555. -- helpUi()
  556. -- if targs then
  557. -- command = targs[1]
  558. -- if command == "help1" then
  559. -- clr()
  560. -- setColor(colors.yellow)
  561. -- helpDraw()
  562. -- elseif command == "help2" then
  563. -- clr()
  564. -- print("num"..draw[1])
  565. -- elseif command == "help3" then
  566. -- clr()
  567. -- print("num"..draw[2])
  568. -- elseif command == "help4" then
  569. -- clr()
  570. -- print("num"..draw[3])
  571. -- elseif command == "help5" then
  572. -- clr()
  573. -- print("num"..draw[4])
  574. -- elseif command == "help6" then
  575. -- clr()
  576. -- print("num"..draw[5])
  577. -- elseif command == "help7" then
  578. -- clr()
  579. -- print("num"..draw[6])
  580. -- elseif command == "help8" then
  581. -- clr()
  582. -- print("num"..draw[7])
  583. -- elseif command == "help9" then
  584. -- clr()
  585. -- setColor(colors.yellow)
  586. -- print("num"..draw[8])
  587. -- elseif command == "clr" then
  588. -- clr()
  589. -- print("cleared!")
  590. -- end
  591.    -- end
  592.       -- end
  593.                  
  594. -- ADV Turtle Functions
  595.  
  596. -- Antimate
  597.  
  598. function ani1(Atext,testX, testY)
  599. clrl(testX, testY)
  600. print(Atext)
  601. sleep(t)
  602. end
  603.  
  604. function ani2(Atext2,testX, testY)
  605. clrl(testX, testY)
  606. print(Atext2)
  607. sleep(t)
  608. end
  609.  
  610. function ani3(Atext3,testX, testY) -- Text ,, x,y
  611. clrl(testX, testY)
  612. print(Atext3)
  613. sleep(t)
  614. end
  615.  
  616. function runA(Atext,Atext2,Atext3,testX, testY,t,LOOP,L1,L2) -- Text1 Text2 Text3 X,Y Time
  617. for LOOP = L1,L2 do -- It Works
  618. ani1(Atext,testX, testY)
  619. ani2(Atext2,testX, testY)
  620. ani3(Atext3,testX, testY)
  621. ani1(Atext,testX, testY)
  622. end
  623.    end
  624.      
  625. -- Cobble
  626.    
  627. function count()
  628. testcobble = 1
  629. function theck()
  630. if turtle.getItemSpace(x) then
  631. turtle.dropDown(c)
  632. print(c)
  633. end
  634.  end
  635. for testcobble = 1,16 do
  636. turtle.select(x)
  637. c = turtle.getItemCount()
  638. theck()
  639. if testcobble == 16 then
  640. turtle.select(1)
  641. os.reboot()
  642. end
  643.    end
  644.      end
  645.  
  646. function runcobble2()
  647.   turtle.select(cobble)
  648.    while sRunning do
  649.     while turtle.getItemSpace(cobble) < 1 do
  650.      for i = 1,16 do
  651.      turtle.select(i)
  652.      if turtle.getItemSpace(i) > 0 then
  653.      x = i
  654.      turtle.select(i)
  655.      break end
  656.      if turtle.getItemSpace(i) == 16 then
  657.      turtle.dropDown(64)
  658.      for i = 1,16 do
  659.      turtle.select(i)
  660.      turtle.dropDown(64)
  661.      end
  662.      turtle.select(1)
  663.      end
  664.         end
  665.            end
  666. if turtle.detect() then
  667.      Acheck()
  668.      turtle.dig()  
  669.         end
  670.      end
  671. end
  672.  
  673. function runCobble()
  674. local sRunning = true
  675. local cobble = 1
  676. clr()
  677. print("If It Stops, Barrel Is Full..")
  678. term.setCursorPos(1, 2)
  679. print("Waiting To Mine Press Any Key!")
  680. term.setCursorPos(1, 3)
  681. print("|Press Down To Drop|")
  682. term.setCursorPos(1, 4)
  683. print("Current Function [           ]")
  684. turtle.select(cobble)
  685. event, key = os.pullEvent("key")
  686. if event == "key" then
  687. if key == keys.enter then
  688. masterLock()
  689. sRunning = false
  690. elseif key == 208 then
  691. count()
  692. elseif not key == 208 then
  693. if not key == keys.enter then
  694. sRunning = true
  695. while sRunning do
  696. term.clear()
  697. term.setCursorPos(1, 1)
  698.  while turtle.getItemSpace(cobble) < 1 do
  699.   for i = 1,16 do
  700.   term.clearLine(1, 2)
  701.   term.setCursorPos(1, 2)
  702.   print("Recalculating..")
  703.   turtle.select(i)
  704.   if turtle.getItemSpace(i) > 0 then
  705.   x = i
  706.   turtle.select(i)
  707.   term.setCursorPos(1, 2)
  708.   print(i)
  709.   break end
  710.   if turtle.getItemSpace(i) > 1 and i == 16 then
  711.   turtle.dropDown(64)
  712.   for i = 1,16 do
  713.   sleep(0.15)
  714.   turtle.select(i)
  715.   turtle.dropDown(64)
  716.   end
  717.      turtle.select(1)
  718.      if turtle.detect() then
  719.    Acheck()
  720.    turtle.dig()
  721.     runCobble2()
  722.       end
  723.    end
  724.      end
  725.         end
  726.            end
  727.               end--
  728.                  end--
  729.                     end--
  730.                       end
  731.                      
  732. -- Obsid
  733.  
  734. function finish()
  735. if sidD == 1 then
  736. texthelp()
  737. term.setTextColor(work)
  738. turtle.drop()
  739. elseif sidD == 0 then
  740. sleep(0.15)
  741. turtle.select(1)
  742. end
  743.    end
  744.  
  745. local function checkF()
  746.  if turtle.getFuelLevel() < 5 then
  747.  turtle.select(16)
  748.  turtle.refuel(1)
  749.  turtle.select(1)
  750.  else
  751.  if turtle.getFuelLevel() < 5 then
  752.  print("Need Fuel in Slot 16")
  753.  turtle.select(16)
  754.  turtle.refuel(1)
  755.  turtle.select(1)
  756.  if turtle.getFuelLevel() > 5 then
  757.  clr()
  758.  print("Ready to Go")
  759.  turtle.select(1)
  760. end
  761.    end
  762.       end
  763.          end
  764.  
  765. function tSel(selnum)
  766.  turtle.select(selnum)
  767. end
  768.  
  769. function cred()
  770. if red == 1 then
  771. setCur(1, 3)
  772. print("Testing Block/Dust..")
  773. stime(0.15)
  774. elseif red == 0 then
  775. setCur(1, 3)
  776. print("Testing Block/Dust..")
  777. stime(0.15)
  778. setCur(1, 4)
  779. if turtle.detect() == true then
  780. os.reboot()
  781. if turtle.detect() == false then
  782. bRunning = false
  783. return
  784. end
  785.    end
  786.       end
  787.          end
  788.            
  789. function wait1()
  790. clr()
  791. setCur(1, 1)
  792. print("Waiting.")
  793. stime(a)
  794. end
  795.  
  796. function wait2()
  797. clr()
  798. setCur(1, 1)
  799. print("Waiting..")
  800. stime(a)
  801. end
  802.  
  803. function wait3()
  804. clr()
  805. setCur(1, 1)
  806. print("Waiting...")
  807. stime(a)
  808. end
  809.  
  810. function WaitA()
  811. testINS()
  812. wait1()
  813. wait2()
  814. wait3()
  815. wait1()
  816. end
  817.  
  818. function testI()
  819.  n = 1
  820.  tSel(n)
  821.  itemslot = turtle.getItemCount(n)
  822.  setCur(1, 1)
  823.  print("Number Of Redstone: "..itemslot)
  824.  stime(0.56)
  825.  if itemslot == 0 then
  826.   red = 1
  827.   setCur(1, 2)
  828.   print("Need More Redstone, RedCount: "..itemslot)
  829.   stime(0.56)
  830.   setCur(1, 3)
  831.   bRunning = false
  832.   return
  833. end
  834.    end
  835.            
  836. function rsOut(side, redtest)
  837.  rs.setOutput(side, redtest)
  838.   end
  839.  
  840. function tLeft()
  841.  rsOut("front", true)
  842.  turtle.turnLeft()
  843.   sleep(3)
  844.   end
  845.  
  846. function tRight()
  847.  rsOut("front", false)
  848.  turtle.turnRight()
  849.   sleep(3)
  850.   end
  851.  
  852. function tDig()
  853.  turtle.select(2)
  854.  turtle.dig()
  855.  turtle.select(1)
  856. end
  857.  
  858. function turnE()
  859.  if tdetectOut == true then
  860.    tLeft()
  861.     tRight()
  862.      tDig()
  863.      elseif tdetectOut == false then
  864.        --cred() --?
  865.        red = 0
  866.        cred()
  867.        stime(0.15)
  868.        testI()
  869.        setCur(1, 4)
  870.        return
  871.         end
  872.            end
  873.              
  874. function tplace()
  875.  tSel(1)
  876.  setCur(1, 2)
  877.  print("Is Placing Resource..")
  878.  stime(0.35)
  879.  turtle.place()
  880.  setCur(1, 3)
  881.  print("Clearing Screen..")
  882.  stime(0.25)
  883.  clr()
  884.  testI()
  885.  setCur(1, 4)
  886. end
  887.    
  888. function testINS()
  889.   p1, p2 = turtle.inspect()
  890.   if p1 == true then
  891.   for k,v in pairs(p2) do
  892.   if v == "minecraft:obsidian" then
  893.   print(v)
  894.   sleep(0.15)
  895.   turtle.select(2)
  896.   tDig()
  897.   turtle.select(1)
  898.   setCur(1, 4)
  899.   print("Found Obsidian Returning.")
  900.   stime(0.25)
  901.   tdetectOut = false
  902.   return
  903.   elseif v == "minecraft:redstone" then
  904.   setCur(1, 3)
  905.   print(r)
  906.   stime(0.25)
  907.   end
  908.      end
  909.         end
  910.            end
  911.  
  912. function tdet()
  913.  turtle.detect()
  914.  if turtle.detect(tdetectOut) == true then
  915.  tdetectOut = true
  916.  testINS()
  917.  setCur(1, 1)
  918.  term.write("Returned True Block: "..ptrue)
  919.  stime(0.65)
  920.  setCur(1, 2)
  921.  print("Block is There.")
  922.  stime(0.50)
  923.  clr()
  924.  elseif turtle.detect(tdetectOut) == false then
  925.  tdetectOut = false
  926.  setCur(1, 1)
  927.  term.write("Returned False Block: "..pfalse)
  928.  stime(0.50)
  929.  setCur(1, 2)
  930.  term.write("Its An AirBlock..")
  931.  stime(0.6)
  932.  tplace()
  933.  --wTo()
  934. end
  935.    end         
  936.            
  937. function trun()
  938.  if rs.getInput("back", true) then
  939.  clr()
  940.  clrl(1, 1)
  941.  print("Redstone Has Stoped The Program.")
  942.  bRunning = false
  943.  return
  944.  end   
  945.        end         
  946.  
  947.  function SidMonkey()  
  948.  if sid == 1 then
  949.  trun()
  950.  elseif sid == 0 then
  951.  while bRunning do
  952.  trun()
  953.  end
  954.     end
  955.       end    
  956.      
  957. -- Put This In Ur obsid Turtle   
  958. -- clr()
  959. -- WaitA()
  960. -- tdet()
  961. -- testINS()
  962. -- turnE()
  963. -- SidMonkey
  964.  
  965. -- Crafter
  966.  
  967. function cln()
  968. term.clear()
  969. term.setCursorPos(1, 1)
  970. setColor(colors.yellow)
  971. end
  972.  
  973.  function texthelp()
  974.  term.setCursorPos(curX, curY)
  975.  term.clearLine(clrX, clrY)
  976.  end
  977.  
  978.  function refuelAll()
  979.  turtle.select(16)
  980.  turtle.refuel(64)
  981.  turtle.select(1)
  982.  end    
  983.  
  984. -- function fdis()
  985. -- Tf = turtle.getFuelLevel()
  986. -- term.setCursorPos(2, 11)
  987. -- print("Fuel Level = ".."["..Tf.."]")
  988. -- end
  989.  
  990.  function checkf()
  991.  local amount = turtle.getFuelLevel()
  992.  if turtle.getFuelLevel() < 5 then
  993.   turtle.select(16)
  994.   turtle.refuel(1)
  995.   turtle.select(1)
  996.  elseif turtle.getFuelLevel() > 5 then
  997.   texthelp()
  998.   term.setTextColor(work)
  999.   print(amount)
  1000.   sleep(0.35)
  1001.   gui()
  1002.   end
  1003.      end
  1004.  
  1005. function check()
  1006.  for i = 1,16 do
  1007.  turtle.select(i)
  1008.  cln()
  1009.  print("Scaning Crafter: "..i)
  1010.  if i == 16 then
  1011.  turtle.select(1)
  1012.  term.setTextColor(work)
  1013.  print("Crafting...")
  1014.  sleep(0.15)
  1015.  cln()
  1016.  gui()
  1017.  end
  1018.     end
  1019.        end
  1020.          
  1021. function srunB()
  1022. cln()
  1023. for b = 1,3 do
  1024. print("DEBUG B")
  1025. turtle.select(b)
  1026. if turtle.getItemSpace(b) >=1 then
  1027. turtle.transferTo(1, a)
  1028. elseif turtle.getItemSpace(b) <=1 then
  1029. if b == 3 then
  1030. srunN()
  1031. end
  1032.    end
  1033.       end
  1034.          end
  1035.      
  1036. function srunN()
  1037. cln()
  1038. for n = 5,7 do
  1039. print("DEBUG N")
  1040. turtle.select(n)
  1041. if turtle.getItemSpace(n) >=1 then
  1042. turtle.transferTo(1, a)
  1043. elseif turtle.getItemSpace(n) <=1 then
  1044. if n == 7 then
  1045. srunM()
  1046. end
  1047.    end
  1048.       end
  1049.          end
  1050.  
  1051. function srunM()
  1052. cln()
  1053. for m = 9,11 do
  1054. print("DEBUG M")
  1055. turtle.select(m)
  1056. if turtle.getItemSpace(m) >=1 then
  1057. turtle.transferTo(1, a)
  1058. elseif turtle.getItemSpace(m) <=1 then
  1059. if m == 11 then
  1060. finish()
  1061. gui()
  1062. end
  1063.    end
  1064.       end
  1065.          end
  1066.  
  1067. function test()
  1068. gui()
  1069. end
  1070.  
  1071. function sCheck()
  1072. cln()
  1073. srunB()
  1074. srunN()--
  1075. srunM()--
  1076. turtle.select(1)
  1077. test()
  1078. if sid == 1 then      
  1079. turtle.turnLeft()    
  1080. elseif sid == 0 then
  1081. test()
  1082. end
  1083.    end
  1084.  
  1085. function gui()  
  1086. cln()
  1087. print("|Press R to Refuel Min.    |")
  1088. print("|Press RAlt to Refuel Max. |")
  1089. print("|Press Up/Down Go Up/Down. |")
  1090. print("|Press ArrowKeys To Turn.  |")
  1091. print("|Press Alt To Compress.    |")
  1092. print("|Press Space To CraftMin.  |")
  1093. print("|Press LCtrl To CraftMax.  |")
  1094. print("|Press RCtrl To Go Forward.|")
  1095. term.setTextColor(colors.green)
  1096. print("|Press Enter To Exit.      |")
  1097. term.setTextColor(colors.yellow)
  1098. print("---------------------------")
  1099. print("                           ")
  1100. print("---------------------------")
  1101. end
  1102. --gui()
  1103.  
  1104. function CRAFTER()
  1105. while bRunning do
  1106. event, key = os.pullEvent("key")
  1107. if event == "key" then
  1108. if key == keys.enter then
  1109. cln()
  1110. term.setTextColor(work2)
  1111. turtle.turnRight()
  1112. print("Please Enter Passcode..")
  1113. sleep(0.25)
  1114. cln()
  1115. masterLock()
  1116. bRunning = false
  1117. end
  1118. if not key == keys.enter then
  1119. check()
  1120. else
  1121. if event == "key" then
  1122. if key == 57 then -- #1 -- Space
  1123.  check()
  1124.  turtle.craft(1)
  1125.  elseif key == 29 then -- #1 -- Left Ctrl
  1126.  check()
  1127.  turtle.craft()
  1128.  elseif key == keys.left then -- Left Arrow
  1129.  texthelp()
  1130.  turtle.turnLeft()
  1131.  term.setTextColor(work)
  1132.  print("Turned Left")
  1133.  sleep(0.25)
  1134.  gui()
  1135.  elseif key == keys.right then -- Right Arrow
  1136.  texthelp()
  1137.  turtle.turnRight()
  1138.  term.setTextColor(work)
  1139.  print("Turned Right")
  1140.  sleep(0.25)
  1141.  gui()
  1142.  elseif key == 19 then -- R
  1143.  texthelp()
  1144.  -- Action Work
  1145.  texthelp()
  1146.  term.setTextColor(work)
  1147.  print("Refreashing!")
  1148.  sleep(0.25)
  1149.  turtle.select(1)
  1150.  gui()
  1151.  elseif key == 184 then -- Right Alt
  1152.  texthelp()
  1153.  refuelAll()
  1154.  term.setTextColor(work)
  1155.  print("Refueled All")
  1156.  sleep(1)
  1157.  refuelAll()
  1158.  sleep(0.8)
  1159.  gui()
  1160.  elseif key == 157 then --Right Ctrl
  1161.  texthelp()
  1162.  turtle.forward()
  1163.  term.setTextColor(work)
  1164.  print("Went Forward!")
  1165.  sleep(0.25)
  1166.  gui()
  1167.  elseif key == 56 then -- Left Alt
  1168.  texthelp()
  1169.  term.setTextColor(work)
  1170.  print("COMPRESSIN..")
  1171.  turtle.suckDown(64)
  1172.  turtle.select(1)
  1173.  turtle.suckDown(64)
  1174.  turtle.select(2)
  1175.  turtle.suckDown(64)
  1176.  turtle.select(3)
  1177.  turtle.suckDown(64)
  1178.  turtle.select(5)
  1179.  turtle.suckDown(64)
  1180.  turtle.select(6)
  1181.  turtle.suckDown(64)
  1182.  turtle.select(7)
  1183.  turtle.suckDown(64)
  1184.  turtle.select(9)
  1185.  turtle.suckDown(64)
  1186.  turtle.select(10)
  1187.  turtle.suckDown(64)
  1188.  turtle.select(11)
  1189.  turtle.suckDown(64)
  1190.  texthelp()
  1191.  term.setTextColor(work2)
  1192.  print("Compressed!")
  1193.  sleep(0.5)
  1194.  turtle.craft()
  1195.  turtle.transferTo(1, a)
  1196.  turtle.select(1)
  1197.  gui()
  1198.  elseif key == 200 then -- Up arrow
  1199.   turtle.up()
  1200.   texthelp()
  1201.   term.setTextColor(work)
  1202.   print("Went Up!")
  1203.   sleep(0.25)
  1204.   gui()
  1205.  elseif key == 210 then -- Keypad Ins - 0
  1206.   turtle.back()
  1207.   texthelp()
  1208.   term.setTextColor(work)
  1209.   print("Went Back!")
  1210.  sleep(0.25)
  1211.   gui()
  1212.  elseif key == 208 then -- Down Arrow
  1213.   turtle.down()
  1214.   texthelp()
  1215.   term.setTextColor(work)
  1216.   print("Went Down!")
  1217.   sleep(0.25)
  1218.   gui()
  1219.  elseif key == 48 then -- B
  1220.   bCheck()
  1221.   texthelp()
  1222.   term.setTextColor(work)
  1223.   print(test)
  1224.   sleep(t)
  1225.   gui()
  1226.  elseif key == 47 then -- V
  1227.   sCheck()
  1228.   texthelp()
  1229.   term.setTextColor(work)
  1230.   print(test)
  1231.   sleep(0.25)
  1232.   gui()
  1233.   if sidD == 1 then
  1234.   checkf()
  1235.   turtle.up()
  1236.   if turtle.detectUp(test) == true then -- Delete if doesnt work
  1237.   turtle.dropUp(64)
  1238.   turtle.down()
  1239.   texthelp()
  1240.   term.setTextColor(work)
  1241.   print(test)
  1242.   gui()
  1243.   elseif turtle.detectUp(test) == false then
  1244.   texthelp()
  1245.   term.setTextColor(work)
  1246.   turtle.down()
  1247.   print(test)
  1248.   gui()
  1249.   elseif not sidD == 0 then
  1250.  end
  1251.     end
  1252.  elseif key == 207 then
  1253.   for c = 1,16 do
  1254.   turtle.select(c)
  1255.   turtle.dropDown()
  1256.   texthelp()
  1257.   term.setTextColor(work)
  1258.   print("Takin out The Trash..")
  1259.   sleep(0.25)
  1260.   gui()
  1261.   if c == 16 then
  1262.   turtle.select(1)
  1263.   texthelp()
  1264.   print("Took Out The Trash!")
  1265.   sleep(0.25)
  1266.   gui()
  1267.   end
  1268.     end
  1269.        end
  1270.           end
  1271.              end
  1272.                 end
  1273.                    end  
  1274.                       end                  
  1275. --CRAFTER()
  1276.  
  1277. -- Antimation    
  1278.  
  1279. r1 = "Ooo"
  1280. r2 = "oOo"
  1281. r3 = "ooO"
  1282.  
  1283. r1z = "Xoo"
  1284. r2z = "oXo"
  1285. r3z = "ooX"
  1286.  
  1287. function drawA(writeA)
  1288. run_a = writeA
  1289. end
  1290.  
  1291. function drawB(writeB)
  1292. run_b = writeB
  1293. end
  1294.  
  1295. function drawC(writeC)
  1296. run_c = writeC
  1297. end
  1298.  
  1299. local function testsid(sid)
  1300. if sid == 0 then
  1301. draw(r1)
  1302. draw(r2)
  1303. draw(r3)
  1304. elseif sid == 1 then
  1305. draw(r1z)
  1306. draw(r2z)
  1307. draw(r3z)
  1308. end
  1309.    end   
  1310.      
  1311. -- Antimate Functions
  1312. function a1(time)
  1313. clrl(1, 2)
  1314. print(drawA())
  1315. sleep(time)
  1316. end
  1317.  
  1318. function a2(time)
  1319. clrl(1, 2)
  1320. print(drawB())
  1321. sleep(time)
  1322. end
  1323.  
  1324. function a3(time)
  1325. clrl(1, 2)
  1326. print(drawC())
  1327. sleep(time)
  1328. end
  1329.  
  1330. -- Run the antimation
  1331. function AntiDraw(time)
  1332. clrl(1, 2)
  1333. a1(time)
  1334. a2(time)
  1335. a3(time)
  1336. clrl(1, 2)
  1337. print("Done.")
  1338. clrl(1, 3)
  1339. end
  1340.  
  1341. -- Help Stuff
  1342.  
  1343. -- fs stuff
  1344. -- print("")
  1345. -- if fs.exists("/text") then
  1346. -- write("")
  1347. -- file = fs.open("/text","r")
  1348. -- varable = file.readall()
  1349. -- fs.close()  
  1350.  
  1351. -- New Text
  1352. -- print("No Gen")
  1353. -- print("Do 1 now")
  1354. -- newText = read()
  1355. -- file = fs.open("/text", "w")
  1356. -- file.write(newText)
  1357. -- file.close()
  1358.  
  1359.  
  1360. -- Send Program
  1361. -- local id = 4
  1362. -- targs = {...}
  1363. -- if targs[1] then
  1364. -- message = targs[1]
  1365. -- if targs[1] == message then
  1366. -- rednet.send(4, message)
  1367. -- print("Sent!")
  1368.   -- end
  1369.      -- end
  1370.  
  1371.      -- Inspect Varable Method
  1372. -- local success, data = turtle.inspect()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement