Space Engineers

Space Engineers

70 ratings
CAT Basic Raycast Range Finder
   
Award
Favorite
Favorited
Unfavorite
File Size
Posted
Updated
24.973 KB
22 Dec, 2016 @ 11:41am
17 Jan, 2020 @ 9:37pm
12 Change Notes ( view )

Subscribe to download
CAT Basic Raycast Range Finder

Description
For use in camera turrets or collision avoidance, or even plotting ramming manurers a basic script to fire a single beam straight ahead to an adjustable range in order to find out if that path is clear or obstructed.

DLC Free Demo Drone: https://steamproxy.net/sharedfiles/filedetails/?id=1971820463

The script returns the
> Name: name of the object (may return a vague name if object is not friendly)
> Type: large or small grid, asteroid, floating object, human, other entity, ect.
> Relationship: friend, ally, foe, neutral, unowned, ect.
> Position: the centre of mass for the detected object. (as GPS marker)
> Speed: magnate value rather than vector.
> Id: Grid Id unique to each grid.

The script also calculates
> Range: from the camera to the object centre
> Range: from camera to the point of object-ray intersection

If the raycast does not hit an object the script will display that no object was detected on the LCD and follow that with the information of the previous object hit if any under History.
The script also retains and displays the data of the last object hit when the display is updated without a new scan being performed.

The script reports the status of the camera and the current change printing that to the output LCD
The script will also echo camera and LCD related errors to the programmable block description

The script responds to string commands into the programmable block and can be set to either default to doing a scan or to wait for the specific do scan command
Multiple commands can be issued in a single string allowing one button press to set the range, trigger a scan then restore the default range allowing multiple buttons to carry different settings.

Output can be printed to as many LCDs in as many locations as desired.

* Commands:
* 'DoScan' - Perform a scan
* 'DoUpdate' - Update Display without performing scan
* 'clear_his' - Clears the history
* 'Set_Rng:<int>' - Set range to int
* 'Inc_Rng:<int>' - Increase range by int
* 'Dec_Rng:<int>' - Decrease range by int
* 'parse_dist:<ON|OFF>' - Enables or disables the parsing of distances to m/km format (default is meters without 'm' indicator)
* 'show_id:<ON|OFF>' - Enables or disables the showing of detected entity ID
* 'show_gps:<ON|OFF>' - Enables or disables the showing of GPS of detected entity
* 'show_his:<ON|OFF>' - Enables or disables the showing of History
* multiple commands can be separated by ',' eg: Set_Rng:100,DoScan,Set_Rng:10 (which would set range to 100, do a scan and then reset range to 10)

* Global Variables:

* 'gb_DistParse' if true parse meters to KM and truncate decimals to the 2 most significant figures
* 'gb_ShowID' if true show Detected entity Ids
* 'gb_ShowGPS if true show Detected entity GPS
* 'gb_ShowHistory if true show history if nothing detected
* 'gb_DisableRecall if true disables the reading of storage to recover adjusted settings

* 'gs_Cam_Name' The full name of the camera to be used for raycasting

* 'gi_Range' Range of scan

* 'gs_Prefix' defines the Prefix which appears at the start of target LCD names

* The script will only use LCDs that have the Prefix.
* For example: With the gs_Prefix '[RC]' an LCD panel with the name '[RC] LCD' will be used but one with the name '[FP] LCD', 'LCD [RC]' or just 'LCD' will not
* if gs_Prefix is set to null then it is ignored and lcd screens will be used regardless of their Prefix

* gs_LCD_Tag' defines the Tag which appears anywhere in the name of target LCDs
* The script will only use LCDs which have the Tag in their name.
* For example: with the gs_LCD_Tag '[OUT]' an LCD panel with the name '[OUT] LCD', 'LCD [OUT]' or '[OUT]' will be used, but one with the name 'LCD', 'LCD [IN]' or '[IN] LCD' will not.
* if gs_LCD_Tag is set to null then it is ignored and lcd screens will be used regardless of their name

* setting both Prefix and Tag will mean that only an LCD that matches both conditions will be used
* setting both Prefix and Tag to null will result in _ALL_ LCDs being used


* IMPORTANT:
>> if "gb_DisableRecall" is true the script recovery feature will not read storage on reset, but it will still write to storage. This means whatever the default values in the script are set to will be written into storage replacing old saved settings. This makes it possible to change settings by editing the script.

>> If "gb_DisableRecall" is false, on script reset or world load the script recovery feature will read the PBs storage value and parse it to recover it's settings. This will replace the default settings which means editing the script will not be an effective way to change the settings but messages into the PB will cause the stored values to be updated.

>> The recovery effected settings are "gi_Range", "gb_DistParse", "gb_ShowID", "gb_ShowGPS", "gb_ShowHistory", "gb_Turn_On_Cam" and "gb_Scan_Without_Cmd". All others are unaffected by the recovery feature
103 Comments
Levarith 20 Jun @ 6:54am 
Is there a way to charge the camera faster? I am using this script as part of a satellite meant to identify and range distant planets visible from orbit near my home planet and the very long charge time is a bit of a drawback for this.
Afourz 16 Jun @ 12:11pm 
Hello. How to get distance to surface? Like a laser rangefinder etc.
Loues.S.Cat  [author] 5 Sep, 2023 @ 10:41am 
You certainly could.
The script was made before custom data was a thing.
should be easy enough to simple write the returned information to the custom field
Iconaclysm 5 Sep, 2023 @ 7:20am 
This is really cool and useful script but I was wondering if I can use it with a Easy Automation 2 project. Is there a way to return the range to target variable to the Custom Data?
Damine 8 Aug, 2023 @ 12:01am 
program block states no data in mp?
SoulDragonWithFlow 30 Jul, 2023 @ 11:55am 
Never mind; figured it out
SoulDragonWithFlow 30 Jul, 2023 @ 5:31am 
I think I've got it working but I can't see it from my cockpit; the text on the LCD is too small. Tried changing the text size of the LCD in the terminal but it instantly reverts back. What do I change in the script to give me a bigger font size?
Loues.S.Cat  [author] 4 Dec, 2022 @ 6:47pm 
been a while since I did anything in SE but did you remove the <> around the variables?
Dr.Potato 3 Dec, 2022 @ 2:32pm 
yo, question i got a few questions about the script since while using i had some difficulty setting up the arguments. 1) how do i know when the script updated the range it its searching since it doesn't update on the lcd. 2) how do i get it to show the gps cords of a location since i tried show_gps:<ON> yet the lcd don't show?
Loues.S.Cat  [author] 29 Jul, 2022 @ 7:28am 
unless SE has changed the way raycasting works the camera needs to have enough charge to cover the distance requested. this is a function of SE itself, not this script.