Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- All credits go to the author, Engineer
- term.clear()
- term.setCursorPos(1,1)
- local buttons = { "left top", "right top", "left bottom", "right bottom" }
- local cButton = { }
- function display( input, button )
- term.setBackgroundColor( colors.black )
- term.setCursorPos(1,19)
- term.clearLine()
- if button then
- write( input )
- else
- write( "Current button: ".. input )
- end
- end
- print( "Click everywhere on the screen to place a marker." )
- for i = 1, 3 do
- display( buttons[i] )
- while true do
- local evt, button, x, y = os.pullEvent( "mouse_click" )
- if buttons[i] == "left top" then
- paintutils.drawPixel( x, y, colors.orange )
- table.insert( cButton, x )
- table.insert( cButton, y )
- break
- elseif buttons[i] == "right top" and x > cButton[1] and y == cButton[2] then
- paintutils.drawPixel( x, y, colors.magenta )
- table.insert( cButton, x )
- break
- elseif buttons[i] == "left bottom" and y > cButton[2] and x == cButton[1] then
- paintutils.drawPixel( x, y, colors.lightBlue )
- table.insert( cButton, y )
- paintutils.drawPixel( cButton[3], cButton[4], colors.yellow )
- display( buttons[4] )
- break
- end
- end
- end
- sleep(1)
- term.setBackgroundColor( 32768 )
- term.clear()
- term.setCursorPos( 1,1 )
- print( "Your button will be printed shortly" )
- sleep(1.5)
- term.clear()
- paintutils.drawLine( tonumber( cButton[1] ), tonumber( cButton[2] ), tonumber( cButton[3] ), tonumber( cButton[2] ), 512 )
- paintutils.drawLine( tonumber( cButton[1] ), tonumber( cButton[4] ), tonumber( cButton[3] ), tonumber( cButton[4] ), 512 )
- paintutils.drawLine( tonumber( cButton[1] ), tonumber( cButton[2] ), tonumber( cButton[1] ), tonumber( cButton[4] ), 512 )
- paintutils.drawLine( tonumber( cButton[3] ), tonumber( cButton[2] ), tonumber( cButton[3] ), tonumber( cButton[4] ), 512 )
- display( "Hit enter to continue ", true )
- while true do
- local evt, key = os.pullEvent( "key" )
- if key == 28 then
- break
- end
- end
- term.clear()
- term.setCursorPos( 1,1 )
- print( "Your values\n" )
- print( "xMin = " .. cButton[1] )
- print( "xMax = " .. cButton[3] )
- print( "yMin = " .. cButton[2] )
- print( "yMax = " .. cButton[4] )
Advertisement
Add Comment
Please, Sign In to add comment