columna1

Copmputercraft Multiple monitor draw

Jun 19th, 2013
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.03 KB | None | 0 0
  1. --v 1.1 -- this is untested but it is supposed to make it so that you can start at a higher monitor than monitor_0 please post on the forums if there is a problem
  2.  
  3. --this is a program made by columna1 please do not claim as your own
  4. --You have permission to edit and use this code as you please just make sure to credit me
  5.  
  6.  
  7. --How to use
  8. --make a bunch of monitors THEY ALL HAVE TO BE THE SAME SIZE all next to eachother
  9. --make sure you make a rectangle
  10. --connect each one with a wired modem and connect them all to the computer on the left side
  11. --NOW LISTEN UP THIS IS IMPORTANT*********!!!!!!!!!!!!!!
  12. --you have to connect all the monitors in a certain way
  13. --facing the frot you need to connect each monitor from left to right starting from the first row
  14. --then you need to go down to the second row and add from left to right one by one
  15. --and continue one by one etc
  16.  
  17. --some tips if you mess up or already have monitors connected with modems in a world
  18. --you can change the startmonitor variable below to specfy the first monitor
  19. --if you accidentaly clicked one and connected it in the wrong order you can use some nbt editor to go
  20. --to that block and set the value "peripheral id" to -1 and go to the save folder and into the computer folder
  21. --and open the file: lastid_monitor and change it to -1 or whichever was the last correct connection
  22.  
  23. --if you already placed some:
  24. --go to the save folder and into the computer folder
  25. --and open the file: lastid_monitor and change it to -1
  26.  
  27.  
  28. -- limitations:
  29. --all monitors have to be the same size!
  30. --there cant be uneven edges (it cant have a layer that is 3 wide when the rest is 4)
  31.  
  32. startmonitor = 0 -- change this is your monitors dont start at monitor_0
  33.  
  34. sm = startmonitor
  35. modem = peripheral.wrap("left")
  36. xmons = 8
  37. ymons = 6
  38. scale = 0.5
  39. modem.callRemote("monitor_"..sm,"setTextScale",scale)
  40. xchars,ychars = modem.callRemote("monitor_"..sm,"getSize")
  41. arg = {...}
  42. if fs.exists(arg[1]) == false then
  43.     error("no such file")
  44. end
  45. dataa = ""
  46. line = {}
  47. rum = 1
  48. l = 0
  49. file = fs.open(arg[1],"r")
  50.     while rum do
  51.         rum = file.readLine()
  52.         l = l + 1
  53.         if rum then line[#line+1] = rum end
  54.     end
  55. print(l)
  56. lines = l
  57. file.close()
  58. for i = 0,xmons*ymons - 1 do
  59.     modem.callRemote("monitor_"..i+sm,"setTextScale",scale)
  60.     modem.callRemote("monitor_"..i+sm,"clear")
  61. end
  62. function str(sn,stri)
  63.     if split > 1 then
  64.         stt = stri:sub((sn-1)*xchars,sn*xchars)
  65.         return stt
  66.     end
  67. end
  68. function printLine(line,strings)
  69.     mon = 0
  70.     for d = 1,ymons-1 do
  71.         if line > ychars*d then mon = xmons*d end
  72.     end
  73.     split = 1
  74.     for c = 1,xmons - 1 do
  75.         if #strings > xchars*c then split = c+1 end
  76.     end
  77.     monadd = 0
  78.     for s = 1,split do
  79.         modem.callRemote("monitor_"..mon+monadd+sm,"setCursorPos",1,line-((mon/xmons)*ychars))
  80.         modem.callRemote("monitor_"..mon+monadd+sm,"write",str(s,strings))
  81.         monadd = monadd + 1
  82.     end
  83. end
  84. fi = fs.open(arg[1],"r")
  85. if ychars*ymons > lines then
  86.     for i = 1,lines-1 do
  87.         printLine(i,fi.readLine())
  88.     end
  89. else
  90.     for i = 1,ychars*ymons do
  91.         printLine(i,fi.readLine())
  92.     end
  93. end
  94. fi.close()
Advertisement
Add Comment
Please, Sign In to add comment