Advertisement
Guest User

map

a guest
Dec 11th, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.56 KB | None | 0 0
  1. monitor = peripheral.wrap("right")
  2. monitor.clear()
  3. curfloor = -3
  4.  
  5. function scan()
  6.   print("scanning routine")
  7. end
  8.  
  9. function drawFile(f,s)
  10.   fails = fs.open(f,"r")
  11.   for line=1,28 do
  12.     row = fails.readLine()
  13.     if row then
  14.     for char=1,string.len(row) do
  15.       sym = string.sub(row,char,char)
  16.       if s == 1 then
  17.         monitor.setCursorPos(char+24,line)
  18.       else
  19.         monitor.setCursorPos(char,line)
  20.       end
  21.       if sym == "#" then
  22.       monitor.setBackgroundColor(colors.gray)
  23.       monitor.write(" ")
  24.       elseif sym == "r" then
  25.       monitor.setBackgroundColor(colors.red)
  26.       monitor.write(" ")
  27.       elseif sym == "g" then
  28.       monitor.setBackgroundColor(colors.green)
  29.       monitor.write(" ")
  30.       elseif sym == "b" then
  31.       monitor.setBackgroundColor(colors.blue)
  32.       monitor.write(" ")
  33.       else
  34.       monitor.setBackgroundColor(colors.black)
  35.       monitor.write(" ")
  36.       end
  37.      
  38.    
  39.     end
  40.     end
  41.   end
  42.   if s == 0 then
  43.     monitor.setCursorPos(1,1)
  44.     monitor.write("Floor:")
  45.     monitor.setCursorPos(13-string.len(f)/2,1)
  46.     monitor.write(f)
  47.   end
  48. end
  49.  
  50. while true do
  51.   drawFile(tostring(curfloor),0)
  52.   drawFile("sidebar",1)
  53.   event,side,x,y =os.pullEvent("monitor_touch")
  54.   if x >25 and x<29 and y>1 and y<6 then
  55.     if fs.exists(tostring(curfloor+1)) then
  56.       curfloor = curfloor+1
  57.     end
  58.   end
  59.   if x>25 and x<29 and y>6 and y<11 then
  60.     if fs.exists(tostring(curfloor-1)) then
  61.       curfloor = curfloor-1
  62.     end
  63.   end
  64.   if x>25 and x<29 and y>11 and y<16 then
  65.     scan()
  66.   end
  67. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement