MrDj200

PrivateElevatorCaller

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