Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if pocket then
- rednet.open("back")
- else
- rednet.open("right")
- end
- --# load the touchpoint API
- os.loadAPI("touchpoint")
- --# initialize a new button set on the top monitor
- local t = touchpoint.new()
- --# add buttons
- if pocket then
- t:add("Abjuration", nil, 2, 2, 12, 3, colors.red, colors.lime)
- t:add("Conjuration", nil, 15, 2, 25, 3, colors.red, colors.lime)
- t:add("Air", nil, 2, 5, 12, 6, colors.red, colors.lime)
- t:add("Earth", nil, 15, 5, 25, 6, colors.red, colors.lime)
- t:add("Fire", nil, 2, 8, 12, 9, colors.red, colors.lime)
- t:add("Manipulation", nil, 15, 8, 25, 9, colors.red, colors.lime)
- t:add("Water", nil, 2, 11, 12, 12, colors.red, colors.lime)
- t:add("Anima", nil, 15, 11, 25, 12, colors.red, colors.lime)
- t:add("RESTART", nil, 2, 18, 10, 19, colors.red, colors.lime)
- else
- t:add("Abjuration", nil, 2, 2, 13, 3, colors.red, colors.lime)
- t:add("Conjuration", nil, 16, 2, 27, 3, colors.red, colors.lime)
- t:add("Air", nil, 2, 5, 13, 6, colors.red, colors.lime)
- t:add("Earth", nil, 16, 5, 27, 6, colors.red, colors.lime)
- t:add("Fire", nil, 2, 8, 13, 9, colors.red, colors.lime)
- t:add("Manipulation", nil, 16, 8, 27, 9, colors.red, colors.lime)
- t:add("Water", nil, 2, 11, 13, 12, colors.red, colors.lime)
- t:add("Anima", nil, 16, 11, 27, 12, colors.red, colors.lime)
- t:add("RESTART", nil, 2, 18, 10, 19, colors.red, colors.lime)
- end
- --# draw the buttons
- t:draw()
- local Turtle_1 = 8
- local Turtle_1_state = 0
- local Turtle_2 = 9
- local Turtle_2_state = 0
- local Turtle_3 = 10
- local Turtle_3_state = 0
- local Turtle_4 = 11
- local Turtle_4_state = 0
- local Turtle_5 = 12
- local Turtle_5_state = 0
- local Turtle_6 = 13
- local Turtle_6_state = 0
- local Turtle_7 = 2
- local Turtle_7_state = 0
- local Turtle_8 = 5
- local Turtle_8_state = 0
- while true do
- --# handleEvents will convert monitor_touch events to button_click if it was on a button
- local event, p1 = t:handleEvents(os.pullEvent())
- if event == "button_click" then
- if p1 == "Abjuration" then
- t:toggleButton(p1)
- if Turtle_1_state == 0 then
- Turtle_1_state = 1
- rednet.send(Turtle_1, "TD_place")
- elseif Turtle_1_state == 1 then
- Turtle_1_state = 0
- rednet.send(Turtle_1, "TD_pickup")
- end
- elseif p1 == "Conjuration" then
- t:toggleButton(p1)
- if Turtle_2_state == 0 then
- Turtle_2_state = 1
- rednet.send(Turtle_2, "TD_place")
- elseif Turtle_2_state == 1 then
- Turtle_2_state = 0
- rednet.send(Turtle_2, "TD_pickup")
- end
- elseif p1 == "Air" then
- t:toggleButton(p1)
- if Turtle_3_state == 0 then
- Turtle_3_state = 1
- rednet.send(Turtle_3, "TD_place")
- elseif Turtle_3_state == 1 then
- Turtle_3_state = 0
- rednet.send(Turtle_3, "TD_pickup")
- end
- elseif p1 == "Earth" then
- t:toggleButton(p1)
- if Turtle_4_state == 0 then
- Turtle_4_state = 1
- rednet.send(Turtle_4, "TD_place")
- elseif Turtle_4_state == 1 then
- Turtle_4_state = 0
- rednet.send(Turtle_4, "TD_pickup")
- end
- elseif p1 == "Fire" then
- t:toggleButton(p1)
- if Turtle_5_state == 0 then
- Turtle_5_state = 1
- rednet.send(Turtle_5, "TD_place")
- elseif Turtle_5_state == 1 then
- Turtle_5_state = 0
- rednet.send(Turtle_5, "TD_pickup")
- end
- elseif p1 == "Manipulation" then
- t:toggleButton(p1)
- if Turtle_6_state == 0 then
- Turtle_6_state = 1
- rednet.send(Turtle_6, "TD_place")
- elseif Turtle_6_state == 1 then
- Turtle_6_state = 0
- rednet.send(Turtle_6, "TD_pickup")
- end
- elseif p1 == "Water" then
- t:toggleButton(p1)
- if Turtle_7_state == 0 then
- Turtle_7_state = 1
- rednet.send(Turtle_7, "TD_place")
- elseif Turtle_7_state == 1 then
- Turtle_7_state = 0
- rednet.send(Turtle_7, "TD_pickup")
- end
- elseif p1 == "Anima" then
- t:toggleButton(p1)
- if Turtle_8_state == 0 then
- Turtle_8_state = 1
- rednet.send(Turtle_8, "TD_place")
- elseif Turtle_8_state == 1 then
- Turtle_8_state = 0
- rednet.send(Turtle_8, "TD_pickup")
- end
- elseif p1 == "RESTART" then
- t:toggleButton(p1)
- shell.run("reboot")
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement