Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- A program to control multiple mining turtles.
- -- For UnbrokenMotion and Friends.
- -- Version 0.1.
- local termWidth, termHeight = term.getSize()
- local termHalfWidth = termWidth / 2
- local termHalfHeight = termHeight / 2
- -- Setup start.
- -- Self explanatory, prints text centered on the screen.
- -- Or at least, it tries to.
- function centeredText(y, text)
- local textLength = string.len(text)
- local cursorXPos = termHalfWidth - (textLength / 2)
- term.setCursorPos(cursorXPos, y)
- term.write(text)
- end
- -- A y/n dialog screen.
- function truthDialog(text, bgColor, fgColor)
- -- Set background color.
- paintutils.drawFilledBox(1, 2, termWidth, termHeight, bgColor)
- term.setBackgroundColor(bgColor)
- term.setTextColor(fgColor)
- centeredText(termHalfHeight, text)
- --draw buttons.
- local yesEnd = (termHalfWidth - 1)
- local yesStart = (yesEnd - 4)
- local noStart = (termHalfWidth + 1)
- local noEnd = (noStart + 3)
- local yPos = (termHalfHeight + 2)
- paintutils.drawLine(yesStart, yPos, yesEnd, yPos, colors.lightBlue)
- paintutils.drawLine(noStart, yPos, noEnd, yPos, colors.lightBlue)
- term.setCursorPos(yesStart+1, yPos)
- term.write("yes")
- term.setCursorPos(noStart+1, yPos)
- term.write("no")
- --wait for input.
- while true do
- local event, button, x, y = os.pullEvent("mouse_click")
- if y == yPos then
- if x >= yesStart and x <= yesEnd then
- return true
- elseif x >= noStart and x <= noEnd then
- return false
- end
- end
- end
- end
- local value = truthDialog("Hello, world!", colors.blue, colors.white)
- print(value)
- sleep(1)
- -- Setup End.
- term.setCursorPos(1, termHeight)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement