Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. function getMonitorInstance(name)
  2. return peripheral.wrap(name);
  3. end
  4. function createScreen(instance)
  5. myScreenText = {}
  6. myScreenTextColor = {}
  7. myScreenBColor = {}
  8. local length,width = instance.getSize();
  9. for i = 0,length*width, 1 do
  10. myScreenText[i] = " "
  11. myScreenTextColor[i] = colors.white
  12. myScreenBColor[i] = colors.black
  13. end
  14. return myScreenText,myScreenTextColor,myScreenBColor
  15.  
  16. end
  17. function updateScreen(instance,myScreenText,myScreenTextColor,myScreenBColor)
  18. instance.setBackgroundColor(colors.black);
  19. instance.clear()
  20. local length,width = instance.getSize();
  21. for y = 1,width do
  22. for x = 1,length do
  23. --(cell x,y) is at (y-1)*width + (x-1)
  24. instance.setCursorPos(x,y)
  25. instance.setBackgroundColor(myScreenBColor[(y-1)*length + (x-1)])
  26. instance.setTextColor(myScreenTextColor[(y-1)*length + (x-1)])
  27. instance.write(myScreenText[(y-1)*length + (x-1)])
  28.  
  29. end
  30. end
  31. end
  32.  
  33. function writePixel(instance,myScreenText,myScreenTextColor,myScreenBColor,x,y,color,bcolor,text)
  34.  
  35. local length,width = instance.getSize();
  36. if (text == false) then
  37. myScreenText[(y-1)*length + (x-1)] = " "
  38. else
  39. myScreenText[(y-1)*length+(x-1)] = text
  40. end
  41.  
  42. if (bcolor ~= false) then
  43. myScreenBColor[(y-1)*length +(x-1)] = bcolor
  44. end
  45. if(color ~= false) then
  46. myScreenTextColor[(y-1)*length + (x-1)]= color
  47. end
  48.  
  49. return myScreenText,myScreenTextColor,myScreenBColor
  50.  
  51. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement