Advertisement
thatparadox

RailElevator

Oct 25th, 2015
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.85 KB | None | 0 0
  1. mon = peripheral.find("monitor")
  2. rednet.open("right") --possibly "wireless_modem"?
  3. Rside = "back" -- set redstone output side
  4.  
  5. function drawBackground()
  6.   mon.setBackgroundColor(colors.black)
  7.   mon.clear()
  8.   mon.setTextColor(colors.black)
  9.   x,y = mon.getSize()
  10.   for yc = 1,15 do
  11.     if yc%2 == 1 then
  12.       mon.setBackgroundColor(colors.lightBlue)
  13.     else
  14.       mon.setBackgroundColor(colors.lightGray)
  15.     end
  16.     for xc = 1,x do
  17.       mon.setCursorPos(xc, yc)
  18.       mon.write(" ")
  19.     end
  20.   mon.setCursorPos(x/2,yc)
  21.   mon.write(yc)
  22.   end
  23. end
  24.  
  25.  
  26. function drawButtons()
  27.   x,y = mon.getSize()
  28.   for i=1,y do
  29.     if fs.exists(tostring(i)) then
  30.       file = fs.open(tostring(i), "r")
  31.       label = file.readAll()
  32.       file.close()
  33.       mon.setCursorPos(x/2, i)
  34.       if i%2 == 1 then
  35.         mon.setBackgroundColor(colors.lightBlue)
  36.       else
  37.         mon.setBackgroundColor(colors.lightGray)
  38.       end
  39.       mon.setTextColor(colors.white)
  40.       mon.write(i)
  41.       mon.setCursorPos(x/2, i)
  42.     end
  43.   end
  44. end
  45.  
  46.  
  47. if fs.exists("level") == false then
  48.   print("What level is this?")
  49.   write("> ")
  50.   level = read()
  51.   term.clear()
  52.   term.setCursorPos(1,1)
  53.   file = fs.open("level", "w")
  54.   file.write(level)
  55.   file.close()
  56. else
  57.   file = fs.open("level", "r")
  58.   level = file.readAll()
  59.   file.close()
  60. end
  61. drawBackground()
  62. drawButtons()
  63. while true do
  64.   event, param1, param2, param3 = os.pullEvent()
  65.   if event == "rednet_message" then
  66.     if tonumber(param2) == tonumber(level) then
  67.       print("inc")
  68.       rs.setOutput(Rside,true)
  69.     else
  70.       rs.setOutput(Rside, false)
  71.     end
  72.   elseif event == "monitor_touch" then
  73.     if tonumber(param3) == tonumber(level) then
  74.       rs.setOutput(Rside, true)
  75.       rednet.broadcast(param3)
  76.     else
  77.       rednet.broadcast(param3)
  78.       rs.setOutput(Rside, false)
  79.     end
  80.   end
  81. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement