thatparadox

Armor Manager

Jan 7th, 2015
400
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.47 KB | None | 0 0
  1. mon = peripheral.find("monitor")
  2.  
  3. function drawBackground()
  4.   mon.setBackgroundColor(colors.black)
  5.   mon.clear()
  6.   mon.setTextColor(colors.black)
  7.   x,y = mon.getSize()
  8.   for yc = 1,15 do
  9.     if yc%2 == 1 then
  10.       mon.setBackgroundColor(colors.lightBlue)
  11.     else
  12.       mon.setBackgroundColor(colors.lightGray)
  13.     end
  14.     for xc = 1,x do
  15.       mon.setCursorPos(xc, yc)
  16.       mon.write(" ")
  17.     end
  18.   mon.setCursorPos(1,yc)
  19.   mon.write(yc..":")
  20.   end
  21. end
  22.  
  23. function inputPage(level)
  24.   mon.clear()
  25.   mon.setBackgroundColor(colors.lightGray)
  26.   mon.setCursorPos(x/2 - 4, y/2-1)
  27.   mon.write("Enter label")
  28.   mon.setCursorPos(x/2 - 4, y/2+1)
  29.   mon.write("in computer")
  30.   term.clear()
  31.   x,y = term.getSize()
  32.   term.setCursorPos(x/2-8, y/2-2)
  33.   print("Enter Armor Type")
  34.   term.setCursorPos(x/2 - 8, y/2)
  35.   print("                ")
  36.   term.setCursorPos(x/2 - 8, y/2)
  37.   label = read()
  38.   term.setBackgroundColor(colors.black)
  39.   term.clear()
  40.   file = fs.open(tostring(param3), "w")
  41.   file.write(label)
  42.   file.close()
  43. end
  44.  
  45. function drawButtons()
  46.   x,y = mon.getSize()
  47.   for i=1,14 do
  48.     if fs.exists(tostring(i)) then
  49.       file = fs.open(tostring(i), "r")
  50.       label = file.readAll()
  51.       file.close()
  52.       mon.setCursorPos(x/2 - string.len(label)/2, i)
  53.       if i%2 == 1 then
  54.         mon.setBackgroundColor(colors.lightBlue)
  55.       else
  56.         mon.setBackgroundColor(colors.lightGray)
  57.       end
  58.       mon.setTextColor(colors.white)
  59.       mon.write(label)
  60.       mon.setCursorPos(x-2, i)
  61.       mon.setBackgroundColor(colors.black)
  62.       mon.setTextColor(colors.white)
  63.       mon.write(" X ")
  64.     end
  65.   end
  66.   mon.setBackgroundColor(colors.lightBlue)
  67.   mon.setCursorPos(x/2 - 5, 15)
  68.   mon.write("Unequip Armour")
  69.   if unequip then
  70.     mon.setBackgroundColor(colors.black)
  71.     mon.setTextColor(colors.white)
  72.     mon.setCursorPos(x/2 - 10, 17)
  73.     mon.write("Ready to unequip armour")
  74.     mon.setCursorPos(x/2 - 12, 19)
  75.     mon.write("Please stand on Transporter")
  76.   end
  77. end
  78.  
  79. while true do
  80.   x,y=mon.getSize()
  81.   mon.clear()
  82.   drawBackground()
  83.   drawButtons()
  84.   event, param1, param2, param3 = os.pullEvent("monitor_touch")
  85.   if param2 < x - 2 and param3 < 15 then
  86.     if fs.exists(tostring(param3)) then
  87.       rs.setAnalogOutput("back", tonumber(param3))
  88.       unequip = false
  89.     else
  90.     inputPage(param3)
  91.     end
  92.   elseif param3 == 15 then
  93.     rs.setAnalogOutput("back", 15)
  94.     unequip = true
  95.   else
  96.     fs.delete(tostring(param3))
  97.   end
  98. end
Add Comment
Please, Sign In to add comment