Dodedodo33

enchant program turtle

May 18th, 2013
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.38 KB | None | 0 0
  1. function GetLevels()
  2.   m=peripheral.wrap("right")
  3.   local Levels = m.getLevels()  
  4.   print("There are ".. Levels.." levels stored")
  5. end
  6.  
  7. function Enchant()
  8.   term.clear()
  9.   term.setCursorPos(1,1)
  10.   select(1)
  11.   GetLevels()
  12.   print("Enchanting item at Which Level?")
  13.   print("Choose from 5,10,15,20,25 or 30")
  14.   local EnchantLVL = read()
  15.   if type(Levels) ~= "number" then
  16.     print("Incorrect value for enchanting level given, please try again...")
  17.     sleep(3)
  18.   elseif EnchantLVL > Levels then
  19.     print("Cannot enchant, not enough Levels available.")
  20.     sleep(3)
  21.   elseif EnchantLVL == "5" then
  22.      m.enchant(5)
  23.      print("Enchanting Finished :)")
  24.   elseif EnchantLVL == "10" then
  25.      m.enchant(10)
  26.      print("Enchanting Finished :)")
  27.   elseif EnchantLVL == "15" then
  28.      m.enchant(15)
  29.      print("Enchanting Finished :)")
  30.   elseif EnchantLVL == "20" then
  31.      m.enchant(20)
  32.      print("Enchanting Finished :)")
  33.   elseif EnchantLVL == "25" then
  34.      m.enchant(25)
  35.      print("Enchanting Finished :)")
  36.   elseif EnchantLVL == "30" then
  37.      m.enchant(30)
  38.      print("Enchanting Finished :)")
  39.   else
  40.    print("Incorrect value for enchanting level given, please try again...")
  41.    sleep(3)
  42.  end
  43. end
  44.  
  45. while true do
  46. term.clear()
  47. term.setCursorPos(1,1)
  48. print("To enchant an item, place it in slot 1 and press any character key...")
  49. os.pullEvent("char")
  50. Enchant()
  51. end
Advertisement
Add Comment
Please, Sign In to add comment