Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- variables
- local camera
- local modem
- for _, name in ipairs(peripheral.getNames()) do
- if (peripheral.getType(name) == "warpdriveLaserCamera") then
- camera = peripheral.wrap(name)
- end
- if (peripheral.getType(name) == "modem") then
- modem = peripheral.wrap(name)
- end
- end
- assert(not (camera == nil))
- assert(not (modem == nil))
- -- setup
- camera.beamFrequency(1420)
- camera.videoChannel(66)
- -- callBacks
- function callBack()
- type, x_, y_, z_, id, meta, res = camera.getScanResult()
- if res ~= -1 then
- target = textutils.serialize( { x = x_, y = y_, z = z_ } )
- print("Targeting "..target)
- modem.transmit(3, 1, target)
- end
- end
- -- loop
- local loop = true
- local interval = 0.1
- local timer = os.startTimer(0)
- while loop do
- local event, arg1, arg2, arg3, arg4 = os.pullEvent()
- if (event == "timer") then
- callBack()
- os.startTimer(interval)
- end
- if (event == "key") then
- if (arg1 == keys.space) then
- break
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement