Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.08 KB | None | 0 0
  1. ---Initialization, this is part when you have to define all global variables and APIs to use(and hardware as well).
  2. local term=request('term')---this will allow ya to use some terminal related functions, such as term.clear(), etc. Works with printed text only
  3. local component=request('component')---this will allow you to use components
  4. local gpu=component.gpu---this will allow you to use all GPU related stuff (also a reason why you had to define component)
  5. local forecolor=0xFF0000---this is a hexadecimal numeric value of foreground color in RGB. This is Red as possible.
  6. local backcolor=0x0000FF---this in the other hand is as blue as possible. Google 'hexadecimal colors', you will find all numbers you need.
  7. local w,h=gpu.getResolution()---will get and store your resolution of screen in w-width and h-height
  8.  
  9. term.clear()---clears text, don't remember if there is any by default
  10. gpu.setDepth(8)---this will set 8-bit color depth (8-bit is max, not sure if by default tho)
  11.  
  12. ---now we can write some stuff
  13. ---gpu.set(x:num,y:num,text:string)
  14. gpu.set(1,1,'Hello world!")---this will print 'Hello world' text on screen starting at 0 0 coords. See that I am not using print('text')
  15. ---.set is your way to go if you want to play with colors, it is more controllable and relayable than print()
  16. ---Text up there will be in default colors, b/w, now let's change it
  17. gpu.setForeground(forecolor)
  18. gpu.setBackground(backcolor)---both self explaning. Just set color of text and it's background.
  19. gpu.set(1,2,'Hello, I am in color now!!!!')---Red text on blue background in line 2.
  20. term.clear()---nothing happens as those typings on screen aren't terminal related, rather GPU specific things.
  21. os.sleep(5)---sleep for 5 sec, cute, isn't it?
  22. gpu.setBackground(0x000000)---black background
  23. gpu.fill(1,1,w,h,' ')---this will fill rectangular area with it's top left corner at 1,1, while being w width and h high. Filled with blank black spaces.
  24. ---Screen is cleared after 5 seconds as it will fill area equal to your resolution.
  25. os.exit()---exits program (in case you have loops this is way to go, here it isn't necessary)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement