Advertisement
Guest User

wiremod digital screen library

a guest
Jun 25th, 2017
1,299
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.21 KB | None | 0 0
  1. @name DigiScreen
  2. @inputs S:wirelink
  3.  
  4. # Digital Screen library made by georgeravenholm (STEAM_0:1:66236244)
  5.  
  6. function number wirelink:getHeight()
  7. {
  8. # Eagle, some advanced highspeede gates have internal memory as if they have ram and sgit
  9. # we can use wirelink to directly read and write to it
  10. # the wiki page says that this adress corresponds to the resolution the screen has
  11. # you can either use this adress to set or get the resolution of the screen
  12. return This[1048572] # according to wiki this gets resolution
  13. }
  14.  
  15. function number wirelink:getWidth()
  16. {
  17. return This[1048573]
  18. }
  19.  
  20.  
  21.  
  22.  
  23. # Col is like console screen
  24. function void wirelink:putPixel(X, Y, Col)
  25. {
  26. # oh fuck this is complicated
  27.  
  28. local Size = This:getWidth()
  29. if ( X > Size || Y > Size ) {return} # This prevents drawing pixels outside of the screen
  30.  
  31. # The digital screen allocates (512*3) ^ 2 cells of memory for image data
  32. # you draw to the screen by setting the colour of a cell number
  33.  
  34. # the cell number just goes up and up and up like:
  35.  
  36. # 3x3 screen
  37.  
  38. # 1 2 3
  39. # 4 5 6
  40. # 7 8 9
  41.  
  42. # so to draw to (2,2) you tell cell 5 to become 255, white if colour mode is 0
  43.  
  44. This[Size * Y + X] = Col # Set colour of cell
  45.  
  46. # The colour the cell becomes depends on the colour mode
  47. # read up on colour modes here: https://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexb8dd.html
  48. # if you want to use colour mode 1 (1 cell for r g and b) you have to modify this func
  49. }
  50.  
  51. #kick the Clk
  52. function void wirelink:pauseScreen()
  53. {
  54. #turn off clk
  55. This[1048575]=0
  56. }
  57. function void wirelink:resumeScreen()
  58. {
  59. # "Clk" allows the screen to update
  60. # unless you dont want constant updating, preform resumeScreen() in the if first
  61. #turn on clk
  62. This[1048575]=1
  63.  
  64.  
  65. }
  66.  
  67. function void wirelink:setColMode(Mode)
  68. {
  69. # just leave this at 0 .
  70. # col mode 0 means that 1 cell is a number from 0-255 representing white to black
  71. This[1048569] = Mode
  72. }
  73.  
  74. function void wirelink:clearScreen()
  75. {
  76. # if you dont get what this does then yoyre anm idiot
  77. This[1048574]=1
  78. This[1048574]=0
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement