daily pastebin goal
41%
SHARE
TWEET

elevator

a guest Jan 29th, 2018 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local types = peripheral.getNames()
  2. local mons = { }
  3. for _,m in pairs(types) do
  4.   if peripheral.getType(m) == 'monitor' then
  5.     table.insert(mons, peripheral.wrap(m))
  6.   end
  7. end
  8.  
  9. local floors = {
  10.   { name = 'Ndiniz ',  ri = 7 },
  11.   { name = 'Bedroom',  ri = 8 },
  12.   { name = 'Storage',  ri = 9 },
  13.   { name = 'Ground ',  ri = 6 },
  14.   { name = 'Smeltery', ri = 5 },
  15. }
  16.  
  17. local function clear(bg)
  18.   for _, monitor in pairs(mons) do
  19.      monitor.setBackgroundColor(bg)
  20.      monitor.setTextScale(.5)
  21.      monitor.clear()
  22.   end
  23. end
  24.  
  25. local function write(x, y, text, fg, bg)
  26.   for _, monitor in pairs(mons) do
  27.     monitor.setTextColor(fg)
  28.     monitor.setBackgroundColor(bg)
  29.     monitor.setCursorPos(x, y)
  30.     monitor.write(text)
  31.   end
  32. end
  33.  
  34. local function drawMenu()
  35.   for i, floor in ipairs(floors) do
  36.     write(5, i*2, floor.name, colors.white, colors.gray)
  37.   end
  38. end
  39.  
  40. clear(colors.gray)
  41. drawMenu()
  42. while true do
  43.   local event,button,X,Y = os.pullEvent()
  44.     if event == "monitor_touch" then
  45.       drawMenu()
  46.       local floorNo = math.floor(Y / 2)
  47.       local floor = floors[floorNo]
  48.       if floor then
  49.         write(5, floorNo * 2, floor.name, colors.white, colors.lime)
  50.      
  51.         local ri = 'redstone_integrator_' .. floor.ri
  52.         peripheral.call(ri, "setOutput", 'south', true)
  53.         os.sleep(.5)
  54.         peripheral.call(ri, "setOutput", 'south', false)
  55.       end
  56.    end
  57. end
RAW Paste Data
Pastebin PRO WINTER Special!
Get 40% OFF Pastebin PRO accounts!
Top