Advertisement
Guest User

advancedMontiorApi

a guest
Jul 21st, 2017
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. function getMonitorInstance(name)
  2. return periferals.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,length
  22. for x = 1,width
  23. --(cell x,y) is at (y-1)*width + (x-1)
  24. instance.setCursorPos(x,y)
  25. instance.setBackgroundColor(myScreenBColor[(y-1)*width + (x-1)])
  26. instance.setTextColor(myScreenTextColor[(y-1)*width + (x-1)])
  27. instance.write(myScreenText[(y-1)*width + (x-1)])
  28.  
  29.  
  30. end
  31.  
  32.  
  33. end
  34. function writePixel(instance,myScreenText,myScreenTextColor,myScreenBColor,x,y,color,bcolor,text)
  35.  
  36. local length,width = instance.getSize();
  37. if (text == false) then
  38. myScreenText[(y-1)*width + (x-1)] = " "
  39. else
  40. myScreenText[(y-1)*width+(x-1)] = text
  41. end
  42.  
  43. if (bcolor ~= false)
  44. myScreenBColor[(y-1)*width +(x-1)] = bcolor
  45. end
  46. if(color ~= false)
  47. myScreenTextColor[(y-1)*width + (x-1)]= color
  48. end
  49.  
  50. return myScreenText,myScreenTextColor,myScreenBColor
  51.  
  52. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement