Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local m = peripheral.wrap("right")
- local m_width, m_height = m.getSize()
- function clear()
- m.setBackgroundColor(colors.white)
- m.clear()
- end
- function writeToOption(option, text)
- width, height = option.getSize()
- option.setCursorPos((width - string.len(text))/2+1,2)
- option.write(text)
- option.redraw()
- end
- --here i draw the button
- function createOption(x, y, width, height, text)
- --i create a window here
- local option = window.create(m, x, y, width, height)
- option.setCursorPos((width - string.len(text))/2+1,2)
- option.write(text)
- option.redraw()
- return option
- end
- clear()
- option1 = createOption(m_width/10+1, 7, m_width-(m_width/10)-2, 3, "Access Reactor System")
- option2 = createOption(m_width/10+1, 11, m_width-(m_width/10)-2, 3, "Info About Program")
- while true do
- event, side, xPos, yPos = os.pullEvent("monitor_touch")
- x, y = option1.getPosition()
- width, height = option1.getSize()
- if(xPos >= x and xPos <= x+width) then
- if(yPos >= y and yPos <= y+height) then
- --first option clicked
- option1.setBackgroundColor(colors.blue)
- option1.clear()
- writeToOption(option1, "Access Reactor System")
- sleep(1)
- shell.run("reactor")
- break
- end
- end
- x,y = option2.getPosition()
- width, height = option2.getSize()
- if(xPos >= x and xPos <= x+width) then
- if(yPos >= y and yPos <= y+height) then
- option2.setBackgroundColor(colors.blue)
- option2.clear()
- writeToOption(option2, "Info About Program")
- sleep(1)
- shell.run("info")
- break
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement