Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local laser = peripheral.find("warpdriveLaser")
- laser.beamFrequency(1420)
- -- Check if the laser was found
- if not laser then
- print("No warpdriveLaser detected")
- os.exit()
- end
- print("Press the 'M' key to emit a laser scan and calculate the layer offset.")
- -- Loop to wait for key events
- while true do
- -- Wait for a key event
- local event, key = os.pullEvent("key")
- -- Check if the "M" key was pressed (key code 50)
- if key == 50 then
- -- Get the laser's own position
- local _, laserY, _ = laser.getLocalPosition()
- -- Emit a laser scan in the Y- direction (0, -1, 0)
- laser.emitBeam(0, -1, 0)
- -- Get the scan result
- local _, _, targetY = laser.getScanResult()
- -- Calculate the layerOffset
- local mineTarget = laserY - targetY
- -- Print the layerOffset
- print("Target is: " .. mineTarget .. "blocks below")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement