Hastwell

Liquid XP Counter

Dec 2nd, 2014
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.39 KB | None | 0 0
  1. -- Criteria
  2. --  must be from getAvailableItems()
  3. --  ID of 4403
  4. --  Dmg value seems to be internal fluid dictionary value
  5. --  rawName is "extracells.[fluidname]", including literal spaces
  6. --      for eg, "extracells.liquid xp"
  7. --  
  8. --  Qty is in mB
  9.  
  10. function findMEAccess()
  11.     return peripheral.wrap('right')
  12. end
  13.    
  14. function findMonitor()
  15.     return peripheral.wrap('left')
  16. end
  17.  
  18. function xpToLv(xp)
  19.     local lv = 1
  20.     while xp > 0 do
  21.         if lv < 16 then xp = xp - ((2*lv)+7)
  22.         elseif lv < 30 then xp = xp - ((5*lv)-38)
  23.         else xp = xp - ((9*lv)-158)
  24.         end
  25.        
  26.         if xp > 0 then lv = lv + 1 end
  27.     end
  28.    
  29.     return lv
  30. end
  31.  
  32. function lvToXp(lv)
  33.     local lookupTable = {[40] = 2920,[30] = 1395}
  34.     return lookupTable[lv]
  35. end
  36.  
  37. --function findPeripheralType():
  38. --  return peripheral.wrap('right')
  39.  
  40.  
  41. me = findMEAccess()
  42. mon = findMonitor()
  43.    
  44. function countFluidByName(fluidName)
  45.     local items = me.getAvailableItems()
  46.     for k,v in pairs(items) do
  47.         if v.id == 4403 and v.rawName == ("extracells."..fluidName) then
  48.             return v.qty
  49.         end
  50.     end
  51.    
  52.     return 0
  53. end
  54.  
  55. --print(countFluidByName('liquid xp'))
  56. mon.clear()
  57. mon.setTextScale(0.5)
  58. term.redirect(mon)
  59. xpAmount = countFluidByName('liquid xp')
  60. print((xpAmount/1000)..'B of XP')
  61. print(xpToLv(xpAmount/20)..' Lvs')
  62. print( math.floor((xpAmount/20) / lvToXp(40))..' bookdups' )
  63. print( math.floor((xpAmount/20) / lvToXp(30))..' enchants' )
  64. term.restore()
Advertisement
Add Comment
Please, Sign In to add comment