Guest User

1

a guest
Feb 16th, 2013
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.68 KB | None | 0 0
  1. local XP = peripheral.wrap("left")
  2. local Anvil= peripheral.wrap("right")
  3. local hora,nivel
  4.  
  5. XP.setAutoCollect(true)
  6.  
  7. local function UI()
  8.     hora = os.time()
  9.     term.clear()
  10.     term.setCursorPos(31,1)
  11.     print(textutils.formatTime(hora))
  12.     term.setCursorPos(1,3)
  13.     nivel = XP.getLevels()
  14.     print("\tTengo "..nivel.." niveles de experiencia.")
  15.     term.setCursorPos(1,5)
  16.     print("\tUsar Slot1 y Slot 2 para reparar objetos.")
  17.     print("\tUsar Slot1 para encantar.")
  18.     print("\n\t\t1. Encantar")
  19.     print("\t\t2. Reparar")
  20.     os.startTimer(1)
  21. end
  22.  
  23. local function canRepair()
  24.   term.clear()
  25.     if nivel < 1 then
  26.         return
  27.     end
  28.     local cost = Anvil.getRepairCost(1,2)
  29.     if cost > 0 then
  30.         term.setCursorPos(4,6)
  31.         print("Reparar este objeto costar�A1 "..tostring(cost)..". �BFContinuar? S/N")
  32.         local input = read()
  33.         if input=="S" then
  34.             Anvil.repair(1,2)
  35.         end
  36.     else
  37.         print("No se puede reparar . . .");
  38.         sleep(1)
  39.     end
  40.     os.startTimer(1)
  41. end
  42. local function tryEnchant()
  43.     if nivel < 1 then
  44.         return
  45.     end
  46.     if turtle.getItemCount(1) < 0 then
  47.         return
  48.     end
  49.     term.clear()
  50.     term.setCursorPos(1,3)
  51.     print("\t\t�BFCuantos niveles usar (1-30)?")
  52.     input = 0
  53.     while tonumber(input) < 1 or tonumber(input) > 30 do
  54.         local input = read()
  55.         print(input)
  56.         if XP.enchant(tonumber(input)) then
  57.             print("Se ha encantado el objeto")
  58.             break;
  59.         else
  60.             print("No se ha podido hacer el encantamiento")
  61.         end
  62.     end
  63.     sleep(1)
  64.     os.startTimer(1)
  65. end
  66.  
  67. local a,b,c,d
  68. UI()
  69.  
  70. while true do
  71.     a,b,c,d = os.pullEvent()
  72.     if a=="timer" then
  73.         UI()
  74.     elseif a=="key" and b==2 then
  75.         tryEnchant()
  76.   --XP.setAutoCollect(true)
  77.     elseif a=="key" and b==3 then
  78.         canRepair()
  79.   --XP.setAutoCollect(true)
  80.     end
  81. end
Advertisement
Add Comment
Please, Sign In to add comment