Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ---Initialization, this is part when you have to define all global variables and APIs to use(and hardware as well).
- local term=request('term')---this will allow ya to use some terminal related functions, such as term.clear(), etc. Works with printed text only
- local component=request('component')---this will allow you to use components
- local gpu=component.gpu---this will allow you to use all GPU related stuff (also a reason why you had to define component)
- local forecolor=0xFF0000---this is a hexadecimal numeric value of foreground color in RGB. This is Red as possible.
- local backcolor=0x0000FF---this in the other hand is as blue as possible. Google 'hexadecimal colors', you will find all numbers you need.
- local w,h=gpu.getResolution()---will get and store your resolution of screen in w-width and h-height
- term.clear()---clears text, don't remember if there is any by default
- gpu.setDepth(8)---this will set 8-bit color depth (8-bit is max, not sure if by default tho)
- ---now we can write some stuff
- ---gpu.set(x:num,y:num,text:string)
- 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')
- ---.set is your way to go if you want to play with colors, it is more controllable and relayable than print()
- ---Text up there will be in default colors, b/w, now let's change it
- gpu.setForeground(forecolor)
- gpu.setBackground(backcolor)---both self explaning. Just set color of text and it's background.
- gpu.set(1,2,'Hello, I am in color now!!!!')---Red text on blue background in line 2.
- term.clear()---nothing happens as those typings on screen aren't terminal related, rather GPU specific things.
- os.sleep(5)---sleep for 5 sec, cute, isn't it?
- gpu.setBackground(0x000000)---black background
- 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.
- ---Screen is cleared after 5 seconds as it will fill area equal to your resolution.
- 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