Advertisement
Guest User

botnet.lua

a guest
Sep 19th, 2019
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.76 KB | None | 0 0
  1. -- A program to control multiple mining turtles.
  2. -- For UnbrokenMotion and Friends.
  3. -- Version 0.1.
  4.  
  5. local termWidth, termHeight = term.getSize()
  6. local termHalfWidth = termWidth / 2
  7. local termHalfHeight = termHeight / 2
  8.  
  9. -- Setup start.
  10. -- Self explanatory, prints text centered on the screen.
  11. -- Or at least, it tries to.
  12. function centeredText(y, text)
  13.     local textLength = string.len(text)
  14.     local cursorXPos = termHalfWidth - (textLength / 2)
  15.     term.setCursorPos(cursorXPos, y)
  16.     term.write(text)
  17. end
  18.  
  19. -- A y/n dialog screen.
  20. function truthDialog(text, bgColor, fgColor)
  21.     -- Set background color.
  22.     paintutils.drawFilledBox(1, 2, termWidth, termHeight, bgColor)
  23.     term.setBackgroundColor(bgColor)
  24.     term.setTextColor(fgColor)
  25.     centeredText(termHalfHeight, text)
  26.    
  27.     --draw buttons.
  28.     local yesEnd = (termHalfWidth - 1)
  29.     local yesStart = (yesEnd - 4)
  30.     local noStart = (termHalfWidth + 1)
  31.     local noEnd = (noStart + 3)
  32.     local yPos = (termHalfHeight + 2)
  33.  
  34.     paintutils.drawLine(yesStart, yPos, yesEnd, yPos, colors.lightBlue)
  35.     paintutils.drawLine(noStart, yPos, noEnd, yPos, colors.lightBlue)
  36.     term.setCursorPos(yesStart+1, yPos)
  37.     term.write("yes")
  38.    
  39.     term.setCursorPos(noStart+1, yPos)
  40.     term.write("no")
  41.    
  42.     --wait for input.
  43.     while true do
  44.         local event, button, x, y = os.pullEvent("mouse_click")
  45.        
  46.         if y == yPos then
  47.             if x >= yesStart and x <= yesEnd then
  48.                 return true
  49.             elseif x >= noStart and x <= noEnd then
  50.                 return false
  51.             end
  52.         end
  53.     end
  54. end
  55.  
  56. local value = truthDialog("Hello, world!", colors.blue, colors.white)
  57. print(value)
  58. sleep(1)
  59. -- Setup End.
  60.  
  61. term.setCursorPos(1, termHeight)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement