-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuttonLib.lua
40 lines (32 loc) · 844 Bytes
/
buttonLib.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
37
38
39
40
--This project is under the CC-BY-4.0 license
--https://github.com/morgatronday1234
function prep()
term.setBackgroundColor(colors.black)
term.setTextColor(colors.white)
term.clear()
end
--buttons = {
-- {3, 3, 6, 6, colors.green, function() print("on") os.sleep(0.5) prep() end},
-- {9, 3, 12, 6, colors.red, function() print("off") os.sleep(0.5) prep() end}
--}
createButtons = function(buttons)
while(true)
do
for _, button_box in pairs(buttons)
do
paintutils.drawFilledBox(button_box[1], button_box[2], button_box[3], button_box[4], button_box[5])
end
event, _, x, y = os.pullEvent("mouse_click")
for _, button in pairs(buttons)
do
if button[6]
then
if (x <= button[3]) and (x >= button[1]) and (y <= button[4]) and (y >= button[2])
then
button[6]()
end
end
end
end
end
--createButtons(buttons)