Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("tp")
- p = peripheral.wrap("back")
- m = peripheral.wrap("top")
- m.setTextScale(1)
- t = tp.new("top")
- t:add("Launch", nil, 2, 1, 28, 2, colors.red, colors.orange)
- t:add("Set Target", nil, 2, 5, 28, 6, colors.green, colors.orange)
- t:add("Set Frequency", nil, 2, 9, 28, 10, colors.green, colors.orange)
- t:draw()
- while true do
- m.setBackgroundColor(colors.black)
- local x, y, z = p.getTarget()
- local f = p.getFrequency()
- m.setCursorPos(8, 7)
- m.write("Current Target")
- m.setCursorPos(8, 8)
- m.write("(" .. x .. ", " .. y .. ", " .. z .. ")")
- m.setCursorPos(8, 11)
- m.write("Current Frequency")
- m.setCursorPos(8, 12)
- m.write(f .. "Hz")
- local event, p1 = t:handleEvents(os.pullEvent())
- if event == "button_click" then
- if p1 == "Launch" then
- launchReady = p.canLaunch()
- if launchReady == true then
- t:flash("Launch")
- p.launch()
- else
- t:flash("Launch")
- m.setBackgroundColor(colors.black)
- m.setCursorPos(8, 3)
- m.write("I'm afraid I")
- m.setCursorPos(8, 4)
- m.write("can't do that Dave")
- sleep(1.5)
- m.clear()
- t:draw()
- end
- elseif p1 == "Set Target" then
- t:flash("Set Target")
- m.clear()
- t:draw()
- m.setBackgroundColor(colors.black)
- m.setCursorPos(7,7)
- m.write("Currently setting")
- print("set X coordinate")
- x = tonumber(read())
- print("set detonation height (0 for on impact)")
- y = tonumber(read())
- print("set Z coordinate")
- z = tonumber(read())
- p.setTarget(x,y,z)
- term.clear()
- t:draw()
- elseif p1 == "Set Frequency" then
- t:flash("Set Frequency")
- m.clear()
- t:draw()
- m.setBackgroundColor(colors.black)
- m.setCursorPos(7, 11)
- m.write("Currently setting")
- print("Set New Frequency")
- f = tonumber(read())
- p.setFrequency(f)
- t:draw()
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement