Dodedodo33

Basecontrol v2.0

May 30th, 2013
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. os.loadAPI("button")
  2. m=peripheral.wrap("left")
  3. rednet.open("back")
  4. local sheepon = false
  5. local sugaron = false
  6. local digon = false
  7. local xpon = false
  8. local meaton = false
  9.  
  10. function drawHeading()
  11.    button.heading("--------- BaseControl v2.0 ---------")
  12. end
  13.  
  14. function drawButtons()
  15.    button.setTable("Toggle Sheep",sheep,3,16,6,10)
  16.    button.setTable("Toggle Sugar",sugar,19,32,6,10)
  17.    button.setTable("Toggle Dig",dig,35,48,6,10)
  18.    button.setTable("Toggle XP",xp,51,64,6,10)
  19.    button.setTable("Toggle Meat",meat,67,80,6,10)
  20.    button.screen()
  21. end
  22.  
  23. function drawText()
  24.    button.label(3,3,"Sheep farm:")
  25.    button.label(19,3,"Sugar farm:")
  26.    button.label(35,3,"Digging Rig:")
  27.    button.label(51,3,"XP Farm:")
  28.    button.label(67,3,"Meat Farm:")
  29.    button.label(69,12,"by: dodedodo33")
  30. end
  31.  
  32. function drawStatus()
  33.    if sheepon then
  34.       button.label(3,4,"active")
  35.    else
  36.       button.label(3,4,"inactive")
  37.    end
  38.    if sugaron then
  39.       button.label(19,4,"active")
  40.    else
  41.       button.label(19,4,"inactive")
  42.    end
  43.    if digon then
  44.       button.label(35,4,"active")
  45.    else
  46.       button.label(35,4,"inactive")
  47.    end
  48.    if xpon then
  49.       button.label(51,4,"active")
  50.    else
  51.       button.label(51,4,"inactive")
  52.    end
  53.    if meaton then
  54.       button.label(67,4,"active")
  55.    else
  56.       button.label(67,4,"inactive")
  57.    end
  58. end
  59.  
  60. function drawScreen()
  61.    m.clear()
  62.    drawHeading()
  63.    drawText()
  64.    drawButtons()
  65.    drawStatus()
  66. end
  67.  
  68. function sheep()
  69.    button.flash("Toggle Sheep")
  70.    sheepon = not sheepon
  71.    if sheepon then
  72.       shell.run("redset","right","yellow","true")
  73.    else
  74.       shell.run("redset","right","yellow","false")
  75.    end
  76. end
  77.  
  78. function sugar()
  79.    button.flash("Toggle Sugar")
  80.    sugaron = not sugaron
  81.    if sugaron then
  82.       shell.run("redset","right","red","true")
  83.    else
  84.       shell.run("redset","right","red","false")
  85.    end
  86. end
  87.  
  88. function dig()
  89.    button.flash("Toggle Dig")
  90.    digon = not digon
  91.    if digon then
  92.       shell.run("redset","right","green","true")
  93.    else
  94.       shell.run("redset","right","green","false")
  95.    end
  96. end
  97.  
  98. function xp()
  99.    button.flash("Toggle XP")
  100.    xpon = not xpon
  101.    if xpon then
  102.       shell.run("redset","right","blue","false")
  103.    else
  104.       shell.run("redset","right","blue","true")
  105.    end
  106. end
  107.  
  108. function meat()
  109.    meaton = not meaton
  110.    if meaton then
  111.       button.toggleButton("Toggle Meat")
  112.       shell.run("sendmsg","89","place")
  113.       id,msg,dist = rednet.receive()
  114.       button.toggleButton("Toggle Meat")
  115.    else
  116.      button.toggleButton("Toggle Meat")
  117.      shell.run("sendmsg","89","remove")
  118.      id,msg,dist = rednet.receive()
  119.      button.toggleButton("Toggle Meat")
  120.    end
  121. end
  122.  
  123. function getClick()
  124.    event,side,x,y = os.pullEvent("monitor_touch")
  125.    button.checkxy(x,y)
  126. end
  127.  
  128. drawScreen()
  129. shell.run("redset","right","blue","true")
  130. shell.run("sendmsg","89","remove")
  131. while true do
  132.    getClick()
  133.    drawScreen()
  134. end
Advertisement
Add Comment
Please, Sign In to add comment