Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local options = {'Shutdown', 'Reboot'}
- local menuopen = false -- variable for checking if the menu is open, to see if we have to draw it
- while true do
- -- we're going to draw everything before taking mouse input
- -- clear the screen and prepare for the new screen to be drawn, with the color black
- term.setBackgroundColor(colors.black)
- term.clear()
- -- get the width and height of the screen - is more helpful than memorizing numbers
- -- it also makes it adaptable to other monitor sizes.
- local w,h = term.getSize()
- -- draw a line on the bottom of the taskbar from right to left
- paintutils.drawLine(1, h, w, h, colors.blue)
- -- draw the start button with black text and a lime (light green) background
- term.setTextColor(colors.black)
- term.setBackgroundColor(colors.lime)
- term.setCursorPos(1, h)
- write('Start')
- -- draw the start menu, but ONLY if menuopen is true.
- if menuopen then
- term.setBackgroundColor(colors.white)
- term.setTextColor(colors.black)
- -- a for loop basically says:
- -- repeat the following, starting at 1 and ending at the number of options (2 in this case)
- for i=1, #options do
- -- set our cursor to the left, and a y position based on i
- -- so the first time, it'll be h (51) - 1, or 50
- -- then h - 2, 49
- term.setCursorPos(1, h - i)
- -- print the ith of options
- -- so on the first loop, i will be 1, and this will say print(options[1])
- -- and then options[2]
- print(options[i])
- end
- end
- -- here's where we take mouse input.
- -- use os.pullEvent to get the event pulled, the mouse button pressed, then the mouse x and y
- local event, button, mousex, mousey = os.pullEvent('mouse_click')
- -- check if we're within bounds of the start button
- if mousey == h and mousex >= 1 and mousex <= 5 then
- -- set menuopen to the oppsite of menuopen
- -- so if menuopen is true, menuopen is now false.
- menuopen = not menuopen
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment