Advertisement
Guest User

1

a guest
May 22nd, 2015
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.94 KB | None | 0 0
  1. os.loadAPI("tp")
  2. p = peripheral.wrap("back")
  3. m = peripheral.wrap("top")
  4.  
  5. m.setTextScale(1)
  6.  
  7. t = tp.new("top")
  8.  
  9.   t:add("Launch", nil, 2, 1, 28, 2, colors.red, colors.orange)
  10.   t:add("Set Target", nil, 2, 5, 28, 6, colors.green, colors.orange)
  11.   t:add("Set Frequency", nil, 2, 9, 28, 10, colors.green, colors.orange)
  12.   t:draw()
  13.  
  14. while true do
  15. m.setBackgroundColor(colors.black)
  16. local x, y, z = p.getTarget()
  17. local f = p.getFrequency()
  18. m.setCursorPos(8, 7)
  19. m.write("Current Target")
  20. m.setCursorPos(8, 8)
  21. m.write("(" .. x .. ", " .. y .. ", " .. z .. ")")
  22. m.setCursorPos(8, 11)
  23. m.write("Current Frequency")
  24. m.setCursorPos(8, 12)
  25. m.write(f .. "Hz")
  26.   local event, p1 = t:handleEvents(os.pullEvent())
  27.   if event == "button_click" then
  28.     if p1 == "Launch" then
  29.       launchReady = p.canLaunch()
  30.       if launchReady == true then
  31.         t:flash("Launch")
  32.         p.launch()
  33.       else
  34.         t:flash("Launch")
  35.         m.setBackgroundColor(colors.black)
  36.         m.setCursorPos(8, 3)
  37.         m.write("I'm afraid I")
  38.         m.setCursorPos(8, 4)
  39.         m.write("can't do that Dave")
  40.         sleep(1.5)
  41.         m.clear()
  42.         t:draw()
  43.       end
  44.     elseif p1 == "Set Target" then
  45.       t:flash("Set Target")
  46.       m.clear()
  47.       t:draw()
  48.       m.setBackgroundColor(colors.black)
  49.       m.setCursorPos(7,7)
  50.       m.write("Currently setting")
  51.       print("set X coordinate")
  52.       x = tonumber(read())
  53.       print("set detonation height (0 for on impact)")
  54.       y = tonumber(read())
  55.       print("set Z coordinate")
  56.       z = tonumber(read())
  57.       p.setTarget(x,y,z)
  58.       term.clear()
  59.       t:draw()
  60.     elseif p1 == "Set Frequency" then
  61.       t:flash("Set Frequency")
  62.       m.clear()
  63.       t:draw()
  64.       m.setBackgroundColor(colors.black)
  65.       m.setCursorPos(7, 11)
  66.       m.write("Currently setting")
  67.       print("Set New Frequency")
  68.       f = tonumber(read())
  69.       p.setFrequency(f)
  70.       t:draw()
  71.     end
  72.   end
  73. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement