Advertisement
Guest User

mobCon.lua

a guest
Jul 31st, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.78 KB | None | 0 0
  1. os.loadAPI('usr/mobController/Prison.lua')
  2. textScale=0.5
  3.  
  4. hdr={
  5.    [[ _____ _              __  __ ]],
  6.    [[/  ___( )            / _|/ _|]],
  7.    [[\ `--.|/ _ __  _   _| |_| |_ ]],
  8.    [[ `--. \ | '_ \| | | |  _|  _|]],
  9.    [[/\__/ / | | | | |_| | | | |  ]],
  10.    [[\____/  |_| |_|\__,_|_| |_|  ]],
  11.     }
  12.  
  13. mon = peripheral.wrap('top')
  14. monX, monY = mon.getSize()
  15. panel1 = window.create(mon, 1, 1, monX, #hdr)
  16. panel2 = window.create(mon, 1, #hdr+1, monX*0.3333, monY)
  17. panel3 = window.create(mon, monX*0.3333+1, #hdr+1, monX, monY)
  18.  
  19. panels={panel1, panel2, panel3}
  20. panel_props = {
  21.     {panel=panel1, background = colors.lightGray, textColor=colors.blue},
  22.     {panel=panel2, background = colors.blue, textColor=colors.white},
  23.     {panel=panel3, background = colors.gray, textColor=colors.white},
  24.     --{panel=panel4, background = colors.orange, textColor = colors.white}
  25. }
  26.  
  27. mon.setTextScale(textScale)
  28.  
  29.  
  30. term.redirect(panel1)
  31. term.setBackgroundColor(panel_props[1].background)
  32. term.setTextColor(panel_props[1].textColor)
  33. term.clear()
  34. term.setCursorPos(3,3)
  35. print('hello')
  36. for k,v in pairs(hdr) do
  37. print(v)
  38. end
  39.  
  40. for k,v in pairs(panels) do
  41.     for a,b in pairs(panel_props) do
  42.         if b.panel == v and v~=panel1 then
  43.             term.redirect(v)
  44.             term.setBackgroundColor(b.background)
  45.             term.setTextColor(b.textColor)
  46.             term.setCursorPos(1,1)
  47.             term.clear()
  48.         end
  49.     end
  50. end
  51. mon.setCursorPos(1,1)
  52.  
  53. while true do
  54.     scs, prisons = Prison.getPrisons()
  55.     if not scs then
  56.         scs, prisons = Prison.readChest(chest)
  57.     end
  58.     t = term.current()
  59.     term.redirect(panel2)
  60.     term.clear()
  61.     term.setCursorPos(1,1)
  62.     print('     Mobs    ')
  63.     for k, v in pairs(prisons) do
  64.         if string.find(v.meta.displayName, 'blizz')  then
  65.             displayName = 'Blizz'
  66.         else
  67.             displayName = v.meta.displayName:gsub('Mob Imprisonment Tool ', '')
  68.             displayName = displayName:gsub('[()]', '')
  69.         end    
  70.         print(displayName)
  71.     end
  72.     p2x, p2y = term.getSize()
  73.     term.setCursorPos(p2x/2-3, p2y-#hdr)
  74.     print('reset')
  75.     term.redirect(t)
  76.    
  77.     event, periph, x, y  = os.pullEvent('monitor_touch')
  78.     panel3.write(event, periph, x, y,'\n')
  79.     if event then
  80.         if x<monX*0.33 and y>#hdr+1 and y<=#hdr+1+#prisons then
  81.             t = term.current()
  82.             term.redirect(panel3)
  83.             prison = prisons[y-(#hdr+1)]
  84.             if not prison then
  85.                 print('No prison selected')
  86.             else
  87.                 term.clear()
  88.                 term.setCursorPos(1,1)
  89.                
  90.                 print(prison.meta.displayName)
  91.                 print(prison.slot)
  92.             end
  93.             term.redirect(t)
  94.         end
  95.    end    
  96. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement