-
Notifications
You must be signed in to change notification settings - Fork 0
/
buttons.lua
36 lines (31 loc) · 854 Bytes
/
buttons.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
local xmin, xmax, ymin, ymax
local clicks = 0
term.clear()
term.setCursorPos(1, 1)
term.write("Click two points.")
repeat
local event, button, x, y = os.pullEvent("mouse_click")
if button == 1 then
clicks = clicks + 1
paintutils.drawPixel(x, y, colors.red)
if clicks == 1 then
xmin = x
ymin = y
elseif clicks == 2 then
xmax = x
ymax = y
term.setBackgroundColor(colors.black)
term.clear()
paintutils.drawBox(xmin, ymin, xmax, ymax, colors.red)
term.setCursorPos(1, 1)
term.write("Click to continue.")
end
end
until clicks == 3
term.setBackgroundColor(colors.black)
term.clear()
term.setCursorPos(1, 1)
print("xmin: "..xmin)
print("ymin: "..ymin)
print("xmax: "..xmax)
print("ymax: "..ymax)