AdvancedPeripherals icon indicating copy to clipboard operation
AdvancedPeripherals copied to clipboard

[Suggestion] Simple Distance Sensor

Open Peekofwar opened this issue 3 years ago • 2 comments

Describe your idea

Would be nice to have some sort of simple distance sensor that would output the distance between it and a block in front of it in a straight line.

Possible deployments:

  • Detect where a Create Mod elevator cabin stops in a shaft to confirm/calibrate the positioning of the lift
  • Detect an entity or intruder in an area by checking for a change in distance (could be done with tripwire hooks, but is less clean and technically takes up more space)

Possible methods/functions exposed to the programmer:

  • setLaserVisible(boolean) enables a visible laser (default off)
  • getLaserVisible() returns true if the laser is set to visible, else false
  • setDetectTransparent(boolean) would make it detect transparent blocks (default off)
  • getDetectTransparent() returns true if it is set to detect transparent blocks, else false
  • setHeightMode(value) sets a value that determines which height the sensor's laser is emitted from.
    • This could be a predetermined number of modes like 1 is low, 2 is center, and 3 is high,
    • Or it could be a value between 0.0625 and 0.9375 (basically aligning with the 16x16 textures) and round to the nearest 1/16th (in-range) -- I'd propose naming it setHeight() instead
  • getHeightMode() Returns a value corresponding to the configured height mode (name this getHeight() instead if it's not predetermined modes)
  • getDistance() would return the distance (in blocks/metres) of the detected block or entity. Returns -1 if nothing is detected in range.

If the sensor does not detect something as it's out of range, then it should probably return a value of -1.

Peekofwar avatar Jul 24 '22 01:07 Peekofwar

For what would you need the height? For something like slabs?

SirEndii avatar Jul 24 '22 18:07 SirEndii

For what would you need the height? For something like slabs?

Yeah, just some way to adjust for low-obstacles like slabs could be useful. Not really necessary, but would be a nice thing to have if you need it.

Peekofwar avatar Jul 25 '22 22:07 Peekofwar