Space Engineers

Space Engineers

107 ratings
Turret Alarm v2
   
Award
Favorite
Favorited
Unfavorite
File Size
Posted
Updated
532.012 KB
8 Oct, 2020 @ 10:03am
15 Jul, 2023 @ 10:05am
28 Change Notes ( view )

Subscribe to download
Turret Alarm v2

Description
A small script that turns your turrets into an automatic alarm that trigger if an enemy is detected or its loss
Can be used both in vanilla and with WeaponCore


Update 2023.2.1
Now script can work with one trigger setup
Added "error" to script status options


Notes
Automatic updating of blocks starts approximately every 6 seconds (at the moment, the update depends on the game ticks directly) and allows you to change the blocks used and tracked by the script without manually restarting it. To disable this function, the script has a special switch in the parameters section.

For the convenience of tracking the status of the script, it is now possible to display its information on the LCD panel. To do this, add the prefix [TA LCD] to the required panel. If you want to display information on a specific panel in a block with multiple LCD's, then you need to add a prefix with the panel number in the list of block panels. For example, to display script state on the right monitor of Control Seat, you will need to add the following prefix to the block: "[TA LCD][2]"

MeshMode - now you can set the 3 different modes to the script: 0 - default (default TurretAlarm behavior), 1 - Tower (checking the turrets and sending updates to the base) and 2 - Base (receiving the messages from any grids via antennas or laser signal and start/stop the triggers)
For using MeshMode just change the parameter in the script or CustomData (0-3) and set up unique broadcast tag.

WC threats mode is a new method of obtaining enemy grids. This mode ensure that you will detect threats with any WC blocks. This mode can be useful on grids with a significant number of weapons as it works more optimized that original vanilla method. Caution, you cannot use WC threats mode and the mode of operation with certain turrets ("turretsTag") at the same time. WC threats will have the highest priority!

Hybrid turrets list allows now not to worry about switching between vanilla and weaponcore modes. Now you can use both types of turrets on your grid.
And because of that, now the Vanilla mode, WC mode and override mode is deprecated and removed from the script

SETUP
1) Place on your grid turrets
2) Place on your grid 2 Timer blocks
3) Name timer blocks as "DetectionTrigger" and/or "LostTrigger" (You can change it's names in the script)
4) Place programmable block and paste this script in it
5) Set up your timer blocks as you wish

OPTIONAL STEPS
1) Enable delay (Set "detectionTriggerDelay" and/or "lostTriggerDelay" as true) and set the required time in the script ("detectionTriggerDelayTime" and "lostTriggerDelayTime". letter 'F' MUST be at the end)
2) Add a prefix [TA LCD] to the required LCD panels to display the script state
3) Specify the tag you need so that the script only works with certain turrets (Change "turretsTag")
4) Set 'searchInGrids' to 1 if you want use turrets from subgrids
5) Add "Run" command on the button panel and/or control seats with one of the following arguments:
a) "refresh" - script will refresh list of used blocks
b) "refresh switch" - disable or enable auto block refresh
c) "switch lcd" - disable or enable the use of LCDs by the script

Thanks to:
Sigmund Froid and his api guide for WeaponCore
Xaker_Two for testing and contribution in some features
Chuckination for contribution in WC threats mode

Updates:
dd/mm/yy
22/02/22: Major Update 2022.1.4
23/02/22: Minor Update 2022.1.5

Warning
100% functioning of the script is not guaranteed due to the use of the WeaponCore API, which may change from time to time, but is pursued as the final goal.

When using groups of turrets with tags, make sure that there are no other blocks in the group other than the turrets. Currently, the search for blocks in groups is not supported

Problems?
If you have any problems with the script, please write to the Troubleshooting discussion.

Want to be on the edge of news and see what other will not? Join the OPC discord! https://discord.gg/zZHAccYpzV
If you want to support me, I now have a Patreon page[www.patreon.com]
Popular Discussions View All (1)
24
14 Sep, 2023 @ 2:48pm
PINNED: Troubleshooting
Foltast
148 Comments
Foltast  [author] 2 Oct, 2024 @ 7:19am 
AFAIK there is no API for searchlights, so no
Creamy Catboy 2 Oct, 2024 @ 3:29am 
Is there anyway to use Searchlights instead of turrets?
<#690b04>0micron 23 Sep, 2023 @ 11:15am 
Thanks very much!
Foltast  [author] 23 Sep, 2023 @ 10:40am 
Yep, turrets should be on for the script
With this script there is no other way to detect, no
<#690b04>0micron 23 Sep, 2023 @ 9:19am 
This may be a dumb question but the turrets have to be on for this script to work correct? Is there a way for this script to detect enemies before turrets begin firing at them?
Kham 16 Jul, 2023 @ 7:57am 
@Sir Connery in the Custom Data for the PB you can change the name of the timers it's looking for so you could name them however you want.
Kham 16 Jul, 2023 @ 7:53am 
@Foltast thanks man, I'll check it out! :)
Sir Connery 16 Jul, 2023 @ 4:46am 
A small non-essential request. The timer block has to be named TriggerDetect. If it was possible to just have blocks including the name for example. Timer TriggerDetect. So I could keep using my naming conventions for everything. Same for the LCD.

I can live without it, but it would declutter my Control Panel and having every Timer in the same place is a comfort in a game with 100s of functional blocks.
Sir Connery 16 Jul, 2023 @ 4:46am 
Just letting you know this is an essential script for me. Good work.

I can trigger my whole base defence setup with it when the Turrets detect an enemy. Lights, choppers launching to defend with the automation blocks etc.
Foltast  [author] 15 Jul, 2023 @ 10:05am 
Should be done :)