Advertisement
untamemadman

RCTurtle-Ars Nouveau-Client

Feb 27th, 2024 (edited)
779
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. if pocket then
  2.     rednet.open("back")
  3. else
  4.     rednet.open("right")
  5. end
  6.  
  7. --# load the touchpoint API
  8. os.loadAPI("touchpoint")
  9.  
  10. --# initialize a new button set on the top monitor
  11. local t = touchpoint.new()
  12.  
  13. --# add buttons
  14. if pocket then
  15.     t:add("Abjuration", nil, 2, 2, 12, 3, colors.red, colors.lime)
  16.     t:add("Conjuration", nil, 15, 2, 25, 3, colors.red, colors.lime)
  17.  
  18.     t:add("Air", nil, 2, 5, 12, 6, colors.red, colors.lime)
  19.     t:add("Earth", nil, 15, 5, 25, 6, colors.red, colors.lime)
  20.  
  21.     t:add("Fire", nil, 2, 8, 12, 9, colors.red, colors.lime)
  22.     t:add("Manipulation", nil, 15, 8, 25, 9, colors.red, colors.lime)
  23.  
  24.     t:add("Water", nil, 2, 11, 12, 12, colors.red, colors.lime)
  25.     t:add("Anima", nil, 15, 11, 25, 12, colors.red, colors.lime)
  26.  
  27.     t:add("RESTART", nil, 2, 18, 10, 19, colors.red, colors.lime)
  28. else
  29.     t:add("Abjuration", nil, 2, 2, 13, 3, colors.red, colors.lime)
  30.     t:add("Conjuration", nil, 16, 2, 27, 3, colors.red, colors.lime)
  31.  
  32.     t:add("Air", nil, 2, 5, 13, 6, colors.red, colors.lime)
  33.     t:add("Earth", nil, 16, 5, 27, 6, colors.red, colors.lime)
  34.  
  35.     t:add("Fire", nil, 2, 8, 13, 9, colors.red, colors.lime)
  36.     t:add("Manipulation", nil, 16, 8, 27, 9, colors.red, colors.lime)
  37.  
  38.     t:add("Water", nil, 2, 11, 13, 12, colors.red, colors.lime)
  39.     t:add("Anima", nil, 16, 11, 27, 12, colors.red, colors.lime)
  40.  
  41.     t:add("RESTART", nil, 2, 18, 10, 19, colors.red, colors.lime)
  42. end
  43.  
  44. --# draw the buttons
  45. t:draw()
  46.  
  47. local Turtle_1 = 8
  48. local Turtle_1_state = 0
  49. local Turtle_2 = 9
  50. local Turtle_2_state = 0
  51. local Turtle_3 = 10
  52. local Turtle_3_state = 0
  53. local Turtle_4 = 11
  54. local Turtle_4_state = 0
  55. local Turtle_5 = 12
  56. local Turtle_5_state = 0
  57. local Turtle_6 = 13
  58. local Turtle_6_state = 0
  59. local Turtle_7 = 2
  60. local Turtle_7_state = 0
  61. local Turtle_8 = 5
  62. local Turtle_8_state = 0
  63.  
  64. while true do
  65.     --# handleEvents will convert monitor_touch events to button_click if it was on a button
  66.     local event, p1 = t:handleEvents(os.pullEvent())
  67.     if event == "button_click" then
  68.         if p1 == "Abjuration" then
  69.             t:toggleButton(p1)
  70.             if Turtle_1_state == 0 then
  71.                 Turtle_1_state = 1
  72.                 rednet.send(Turtle_1, "TD_place")
  73.             elseif Turtle_1_state == 1 then
  74.                 Turtle_1_state = 0
  75.                 rednet.send(Turtle_1, "TD_pickup")
  76.             end
  77.         elseif p1 == "Conjuration" then
  78.             t:toggleButton(p1)
  79.             if Turtle_2_state == 0 then
  80.                 Turtle_2_state = 1
  81.                 rednet.send(Turtle_2, "TD_place")
  82.             elseif Turtle_2_state == 1 then
  83.                 Turtle_2_state = 0
  84.                 rednet.send(Turtle_2, "TD_pickup")
  85.             end
  86.         elseif p1 == "Air" then
  87.             t:toggleButton(p1)
  88.             if Turtle_3_state == 0 then
  89.                 Turtle_3_state = 1
  90.                 rednet.send(Turtle_3, "TD_place")
  91.             elseif Turtle_3_state == 1 then
  92.                 Turtle_3_state = 0
  93.                 rednet.send(Turtle_3, "TD_pickup")
  94.             end
  95.         elseif p1 == "Earth" then
  96.             t:toggleButton(p1)
  97.             if Turtle_4_state == 0 then
  98.                 Turtle_4_state = 1
  99.                 rednet.send(Turtle_4, "TD_place")
  100.             elseif Turtle_4_state == 1 then
  101.                 Turtle_4_state = 0
  102.                 rednet.send(Turtle_4, "TD_pickup")
  103.             end
  104.         elseif p1 == "Fire" then
  105.             t:toggleButton(p1)
  106.             if Turtle_5_state == 0 then
  107.                 Turtle_5_state = 1
  108.                 rednet.send(Turtle_5, "TD_place")
  109.             elseif Turtle_5_state == 1 then
  110.                 Turtle_5_state = 0
  111.                 rednet.send(Turtle_5, "TD_pickup")
  112.             end
  113.         elseif p1 == "Manipulation" then
  114.             t:toggleButton(p1)
  115.             if Turtle_6_state == 0 then
  116.                 Turtle_6_state = 1
  117.                 rednet.send(Turtle_6, "TD_place")
  118.             elseif Turtle_6_state == 1 then
  119.                 Turtle_6_state = 0
  120.                 rednet.send(Turtle_6, "TD_pickup")
  121.             end
  122.         elseif p1 == "Water" then
  123.             t:toggleButton(p1)
  124.             if Turtle_7_state == 0 then
  125.                 Turtle_7_state = 1
  126.                 rednet.send(Turtle_7, "TD_place")
  127.             elseif Turtle_7_state == 1 then
  128.                 Turtle_7_state = 0
  129.                 rednet.send(Turtle_7, "TD_pickup")
  130.             end
  131.         elseif p1 == "Anima" then
  132.             t:toggleButton(p1)
  133.             if Turtle_8_state == 0 then
  134.                 Turtle_8_state = 1
  135.                 rednet.send(Turtle_8, "TD_place")
  136.             elseif Turtle_8_state == 1 then
  137.                 Turtle_8_state = 0
  138.                 rednet.send(Turtle_8, "TD_pickup")
  139.             end
  140.         elseif p1 == "RESTART" then
  141.             t:toggleButton(p1)
  142.             shell.run("reboot")
  143.         end
  144.     end
  145. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement