MrDj200

ElevatorCaller

Jul 21st, 2016
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.29 KB | None | 0 0
  1. --Code by MrDj200 2016.
  2.  
  3. --Put your level under this (Note: The last entry has NO "," at the end!)
  4. levels = {  "ExampleTop",
  5.                 "ExampleMiddle",
  6.                 "ExampleBottom"
  7.             }
  8.            
  9. -- Put your ComputerID's in the same order as above(Note: The last entry has NO "," at the end!)
  10. IDs =   {   1,
  11.                 5,
  12.                 3
  13.             }
  14.            
  15. --On what side is your Wireless Modem? ( "bottom" | "top" | "back" | "front" | "right" | "left" )
  16. rednetSide = "left"
  17.            
  18. --What line and row to start the buttons:          
  19. line = 3
  20. row= 10
  21. space = 1          
  22.                
  23. --The Code starts here. Dont change anything, unless you know what you are doing ;P
  24.  
  25. term.clear()
  26. term.setBackgroundColor(colors.red)
  27. lineNums = {}  
  28.  
  29. function fncButton(x, y)
  30.     --print( "The mouse button 1 was pressed at ", x, " and ", y )
  31.    
  32.     for k, v in pairs(levels) do
  33.         if y == lineNums[k] then
  34.             if x > row - 1 and x < row + #levels[k] + 1 then
  35.                 rednet.open(rednetSide)
  36.                 rednet.send(IDs[k])
  37.             end
  38.         end
  39.     end
  40.    
  41. end
  42.    
  43. for k, v in pairs(levels) do
  44.     term.setCursorPos(row, line)
  45.     term.write(v)
  46.     lineNums[k] = line
  47.     line = line + 1 + space
  48. end
  49.  
  50. while true do
  51.   local event, button, x, y = os.pullEvent( "mouse_click" )
  52.  
  53.   --print( "The mouse button ", button, " was pressed at ", x, " and ", y )
  54.  
  55.     if (button == 1) then
  56.         fncButton(x, y)
  57.     end
  58.  
  59.  end
Advertisement
Add Comment
Please, Sign In to add comment