Space Engineers

Space Engineers

Not enough ratings
Trekker's Simple Turret Sensor
   
Award
Favorite
Favorited
Unfavorite
File Size
Posted
3.865 KB
10 Nov, 2019 @ 5:54pm
1 Change Note ( view )

Subscribe to download
Trekker's Simple Turret Sensor

Description
A simple tool for triggering timers based on whether turrets are engaged with the target or not.

To set up:
0 Set up a group called "Sensor" for turrets, and a group called "Timer" for timers. These can be changed in the CustomData of the PB, for which the settings will appear when it is first compiled.
1 Go into the CustomData of timers you want to trigger when something enters turret range, and put "[Enter]".
2 Go into the CustomData of timers you want to trigger when something leaves turret range, and put "[Leave]".
If you don't have the [] characters, you can either copy the tag using the one inside of the PB's CustomData, or change it to anything you would like in there.

The config file:
{
[TurretSensor]
Turret Group Name=Sensor
Timer Group Name=Timer
On enter trigger timer tag=[Enter]
On leave trigger timer tag=[Leave]
Delay before we trigger leave timers=120
}
This should actually explain itself. Sensor is the group of turrets it uses, and Timer is the group of all the timers used by this script. The tags are what you put inside of the timer blocks to get it to trigger on different conditions, and the delay is the period of time it will wait, in ticks, before it will consider the turrets disengaged.

Keep in mind when changing settings that you must recompile the code to recognize changes.

Also keep in mind with the way the script works that the script iterates over turrets one-by-one for performance reasons. Set the delay low to make it snappy, but if it is low enough that it can trigger false while iterating over disengaged turrets in the group, that can cause the script to trigger engage and disengage timers back to back to back. It takes 10 ticks for it to iterate over a turret, so if you have for example two turrets in a group, you could set the value to 20 ticks and it won't interrupt itself.