GraySloth

ComputerCraft: MiscPeripherals: 'xp' Various xp upgrade uses

Mar 5th, 2013
621
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.81 KB | None | 0 0
  1. --v0.1 by GraySloth 2013-Mar-03 For the miscperipherals mod with the XP Upgrade, Still experimental, your magical results may vary.
  2.  
  3. local tArgs = { ... }
  4. --variables
  5. local sCommand = tArgs[1]
  6. local sNumber = tonumber( tArgs[2] )
  7. local drop = true
  8. local dropTo = "up"
  9. local suckFrom = "forward"
  10. xp = peripheral.wrap("right")
  11.  
  12. if #tArgs < 1 then
  13.    print("Type: xp help")
  14.    return
  15. end
  16. --functions
  17. function vacuum()
  18.    if suckFrom == "forward" then
  19.       print(xp.get())
  20.    elseif suckFrom == "up" then
  21.       print(xp.getUp())
  22.    elseif suckFrom == "down" then
  23.       print(xp.getDown())
  24.    end
  25. end
  26.      
  27.  
  28. function pipe()
  29.    if drop then
  30.       if dropTo == "up" then
  31.          turtle.dropUp()
  32.       elseif dropTo == "down" then
  33.          turtle.dropDown()
  34.       end
  35.    end
  36. end
  37.  
  38. function lvl()
  39.    print("Level: "..xp.getLevels())
  40. end
  41.  
  42. function clear()
  43.    term.clear()
  44.    term.setCursorPos(1,1)
  45. end
  46.    
  47. local input = nil  
  48. sEnchant = false
  49.  
  50. if sCommand == "kill" then
  51.    xp.setAutoCollect(true)
  52.    while true do
  53.       clear()
  54.       lvl()
  55.       turtle.attack()
  56.       os.sleep(.1)
  57.       xp.collect()
  58.       pipe()
  59.    end
  60. elseif sCommand == "add" then
  61.    turtle.select(sNumber)
  62.    print("Added "..xp.add().." XP to turtle")
  63.    lvl()
  64. elseif sCommand == "level" then
  65.    lvl()
  66. elseif sCommand == "collect" then
  67.    while true do
  68.       clear()
  69.       print("collecting xp press ctrl+t to stop ")
  70.       lvl()
  71.       xp.collect()
  72.       os.sleep(0.5)
  73.    end
  74. elseif sCommand == "enchant" then
  75.    turtle.select(sNumber)
  76.    clear()
  77.    while (input == nil) or (sEnchant == false) do      
  78.       print("I have "..xp.getLevels().." levels, how many do you want to use?\n")
  79.       write("Max lvl 30: ")
  80.       input = tonumber(read())
  81.       if (input == nil) or (input < 1) then
  82.          clear()
  83.          print("Try again, but this time enter a NUMBER that makes sense or hold ctrl+t to exit.\n")      
  84.       elseif input > 30 then
  85.          clear()
  86.          print("What are you nuts? 30 is the max unless you are trying to destroy the fabric of reality.")
  87.          print("Try again or hold ctrl+t to exit.\n")    
  88.       elseif input > 0 then
  89.          clear()
  90.          textutils.slowWrite( "Mekka Lekka Hi Mekka Hiney Ho! \n" )
  91.          if xp.enchant(input) then
  92.             sEnchant = true
  93.             print("The wish is granted, long live ComputerCraft.\n")
  94.             lvl()          
  95.          else
  96.             clear()
  97.             print("The enchantmet failed, and you call yourself a wizard.")
  98.             print("Try again, or hold ctrl+t to exit.\n")
  99.          end
  100.       end
  101.    end
  102. elseif sCommand == "suck" then
  103.    while true do
  104.       clear()
  105.       vacuum()
  106.       lvl()
  107.       pipe()
  108.       os.sleep(1)
  109.    end
  110. else
  111.    clear()
  112.    print("xp kill: attacks and collects XP and loot from mobs, needs weapon or tool\n")
  113.    print("*press any key to continue*")
  114.    os.pullEvent("key")
  115.    clear()
  116.    print("xp add <#slot>: Adds all XP from XP bottles or monster eggs, Returns the amount of XP added.\n")
  117.    print("*press any key to continue*")
  118.    os.pullEvent("key")
  119.    clear()
  120.    print("xp level: Returns the Level on the turtle.\n")  
  121.    print("*press any key to continue*")
  122.    os.pullEvent("key")
  123.    clear()
  124.    print("xp collect: Collects XP from XP orbs on the ground in a 2 block radius around the turtle.\n")
  125.    print("*press any key to continue*")
  126.    os.pullEvent("key")
  127.    clear()
  128.    print("xp enchant <#slot>: Enchants the item in the selected slot using to be specified levels.\n")
  129.    print("*press any key to continue*")
  130.    os.pullEvent("key")
  131.    clear()
  132.    print("xp suck: sucks XP out of ONLY vanilla furnaces and can put the item into other inventorys but NOT pipes or tubes, for best results set local drop to false to keep contents in turtle or true to send out.\n")
  133.    print("*press any key to continue*")
  134.    os.pullEvent("key")
  135.    clear()
  136. end
Advertisement
Add Comment
Please, Sign In to add comment