Advertisement
Guest User

startup

a guest
Jul 29th, 2014
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.41 KB | None | 0 0
  1. -- Apps
  2. shell.run("energy")
  3.  
  4. --Statuses
  5. local WheatFarm = true
  6.  
  7. -- IDs
  8. local Wheat = 676
  9.  
  10. -- Peripherals
  11. rednet.open("back")
  12. local m = peripheral.wrap("top")
  13.  
  14. -- Labels
  15. local Labels = {
  16. {["name"]="lblWheat", ["x"]=5, ["y"]=5, ["text"]="Online", ["color"]=colors.green}
  17. }
  18.  
  19. --rednet.send(Wheat, "toggle")
  20.  
  21. function SetLabel(lbl, txt)
  22.   Labels[lbl]["text"] = txt
  23.   PrintControls()
  24. end
  25.  
  26. function SetLabelColor(lbl, color)
  27.   Label[lbl]["color"] = color
  28.   PrintControls()
  29. end
  30.  
  31. function PrintControls()
  32.   m.clear()
  33.   for k,v in pairs(Labels) do
  34.     m.setCursorPos(Labels[k]["x"], Labels[k]["y"])
  35.     m.setTextColor(Labels[k]["color"])
  36.     m.write(Labels[k]["text"])
  37.   end
  38. end
  39.  
  40. PrintControls()
  41. while true do
  42.   local ev,p1,p2,p3 = os.pullEvent()
  43.   if(ev=="rednet_message") then
  44.     if(p1==Wheat) then
  45.       if(p2=="true") then
  46.         SetLabelColor("lblWheat", colors.green)
  47.         SetLabel("lblWheat", "Online")
  48.         WheatFarm = true
  49.       elseif(p2=="false") then
  50.         SetLabelColor("lblWheat", colors.red)
  51.         SetLabel("lblWheat", "Suspended")
  52.         WheatFarm = false
  53.       end
  54.     end
  55.   elseif(ev=="monitor_touch") then
  56.     for k,v in pairs(Labels) do
  57.       print(p2.." >= "..Labels[k]["x"])
  58.       print(p2.." <= "..string.len(Labels[k]["text"]))
  59.       if(p2 >= Labels[k]["x"] and string.len(Labels[k]["text"]) <= p2) then
  60.         print("success")
  61.       end
  62.     end
  63.   end
  64. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement