View difference between Paste ID: YXT5kQAp and Z9bJ7uLC
SHOW: | | - or go back to the newest paste.
1
--# load the Touchpoint API
2
os.loadAPI("touchpoint")
3
p = peripheral.wrap("back")
4
5
--# FUNCTIONS
6
7
function pulse()
8
        redstone.setOutput("back", true)
9-
        end
9+
        sleep(0,5)
10
        redstone.setOutput("back", false)
11-
function peat2()
11+
end
12-
        p.setFreq(222)
12+
 
13-
        end
13+
14
        p.setFreq(151)
15
        pulse()
16
end
17
 
18
function pumpkin()
19-
t:add("label", nil, 2, 2, 14, 11, colors.red, colors.lime)
19+
        p.setFreq(152)
20-
t:add("Power", nil, 16, 2, 28, 11, colors.lime, colors.red)
20+
        pulse()
21
end
22
23
function melon()
24
        p.setFreq(153)
25
        pulse()
26
end
27
28
--# intialize a new button set on the top monitor
29
local t = touchpoint.new("top")
30-
    if p1 == "label" then
30+
31
--# add buttons
32
t:add("PEAT", nil, 2, 2, 16, 4, colors.red, colors.lime)
33-
      peat2()
33+
--t:add("PUMPKIN", nil, 2, 2, 28, 11, colors.lime, colors.red)
34
--t:add("MELON", nil, 2, 2, 28, 11, colors.lime, colors.red)
35
36
--# draw the buttons
37
t:draw()
38
39
while true do
40
  local event, p1 = t:handleEvents(os.pullEvent())
41
  if event == "button_click" then
42
    t:toggleButton(p1)
43
   
44
    if p1 == "PEAT" then
45
      peat()
46
    --elseif p1 == "PUMPKIN" then
47
    --  pumpkin()
48
    else
49
      melon()
50
    end
51
  end
52
end