Space Engineers

Space Engineers

EasyCommands
152 Comments
Merlin of Mines  [author] 23 Feb @ 1:05pm 
Hey @Experementor, sorry for long delay.

I believe you should be able to get the custom data of an LCD screen by fetching the Terminal Block type for your block name.

set myData to "My LCD Screen" terminal block data
print "My Data: \n" + myData
Experementor 20 Nov, 2024 @ 4:50am 
Hello @Merlin!
I was wondering if there's any way at all to pull text from custom data of an LCD screen. I'm trying to make more or less a dialogue tree thing and I want to store the possible texts in the displays themselves - in Custom Data - but so far couldn't find a way to access it. Help would be very appreciated
solickm 2 Nov, 2024 @ 10:46pm 
@Merlin

"Eureka'd" upon what should be a more elegant solution, but being able to pull the waypoint info from the various AI blocks using EasyCommands would be great if possible.

Mahalos!
solickm 1 Nov, 2024 @ 9:44pm 
@Merlin

Been playing with how it can be used with the AI blocks and such, and have hit a wall.
How can you get the info of the "waypoints" that are made in the AI Recorder block?
My various attempts yields all the various info for the block, EXCEPT for the waypoint info.
Need some form of conditional check of what order the waypoints are in so that the path may be reversed to facilitate auto-docking.
I have the AI Rec/AI Flight working so that my craft can dock, and even so the path is automatically reversed for UN-docking with various other EZComms/timer block actions being made during the process.
But, suppose I pilot the craft out myself instead of having the AI un-dock me, and later wish to auto-DOCK, the AI Recorder flight path will still be set to the UN-dock path.

Perhaps something like the DOCK path could be set as a global variable in EZComms, while the reversed UNDOCK path is another that could be recalled when needed.
Mahalo
Merlin of Mines  [author] 3 May, 2024 @ 7:27pm 
@Sasquatch

Glad you figured it out. I would call out that you *can* name your blocks whatever you want, but in some cases you may need to tell EasyCommands what kind of block to look for in your Selector.

By default, EasyCommands looks at the last block type name in your name to infer the block type, if you haven't specified one. So "Piston Drill" would be looking for a Drill, whereas "Drill Piston" would be looking for a piston.

If needed, you can clarify to EasyCommands what block type to look for by specifying it after the block name.

Here's some examples:

#This would look for a drill
set "Piston Drill" height to 5

#This would look for a piston
set "Drill Piston" height to 5

#This would look for a piston
set "Piston Drill" piston height to 5

#This would look for a drill
turn on "Drill Piston" drill

See Selectors for more information:
https://spaceengineers.merlinofmines.com/EasyCommands/selectors

Hope that helps!
Sasquatch 2 May, 2024 @ 3:18pm 
@Merlin of Mines thanks, ill have alook.

I'm having a problem with pistons, or version of the mod.
if i paste old blueprint(circa2022) i can set piston speed by:
set the "Elevator Piston" velocity to 2
or
set "Elevator Piston" speed to 2
but when i load current version to programming block neither does work, same goes for checking piston current position or reversing them..


As i was typing this i found the problem, Do not name you pistons like: "Piston Drill", Piston Dril" works flawlesly
Merlin of Mines  [author] 2 May, 2024 @ 8:59am 
Hey @Sasquatch.

Unfortunately the Welder block doesn't provide support to detect if it has unfinished blocks in range, so EasyCommands can't detect this.

You can definitely determine if a connector is locked and/or a merge block is merged. Check out the block handlers for these for examples:

https://spaceengineers.merlinofmines.com/EasyCommands/blockHandlers/connector
https://spaceengineers.merlinofmines.com/EasyCommands/blockHandlers/merge
Sasquatch 28 Apr, 2024 @ 10:22am 
Is there a way of checking if welder block has any unfinished blocks in range, or if connector is locked/merge block merged. wleder would be preffered as i can pause pistons on my mineshaft drillers(deep ores mod) until components are manufactured and conveyors welded.
Merlin of Mines  [author] 10 Apr, 2024 @ 8:52pm 
Oh, I guess I didn't answer your original question of how to set a specific display on a sci-fi button panel.

You can do this via:

set "Button Panel" display[0] images to ["Danger", "Offline"]


print "Button Panel" display[0] images joined "\n"

set "Button Panel" display[0] interval to 1.5


or, by name:

#Print Display names
print "Button Panel" display names

#Set the button images
set "Button Panel" display["Numpad 2"] images to ["Danger", "Offline"]

#Set the button image change interval
set "Button Panel" display["Numpad 2"] interval to 0.5
Merlin of Mines  [author] 10 Apr, 2024 @ 8:44pm 
@TheTomRom Forgot to mention, I have an image list here:
https://spaceengineers.merlinofmines.com/EasyCommands/blockHandlers/display

If one is not listed, you can figure this out by adding the image you want to your text panel and then print the images using the command I mentioned, and that'll get you the image name.

Hope that helps!
Merlin of Mines  [author] 10 Apr, 2024 @ 8:43pm 
Hey TheTomRom!

You can set the ImageChangeInterval using "interval". Looks like I don't have this documented.

#Sets the interval to 1.5 seconds
set "My Display Panel" display interval to 1.5

You can set the images using "images" (this one is documented)

Here's an example:

print "Current Images: "
print "Text Panel" display images joined "\n"

# Set the images
set "Text Panel" display images to ["Danger", "Offline"]

# Set the display interval
set "Text Panel" display interval to 1.5
TheTomRom 30 Mar, 2024 @ 4:07pm 
Hi Merlin of Mines, I am still using this great script but I stumbled across two problems:

1) Using a sci-fi button panel (the one with screens) I want to set the "ImageChangeInterval" for one screen but I cannot figure out how to do it. As the display block does not inherit from the terminal block, it seems that the syntax might be different?! Could you help me out here?

2) Also, with the display blocks, there is an option to define the image rotation. Here, again, I was unable to understand how to set that with "EasyCommands"

Cheers and thanks in advance!
Merlin of Mines  [author] 1 Feb, 2024 @ 1:06pm 
@serjevski

To some extent, yes. Check out
Controlling Unsupported Block Types [spaceengineers.merlinofmines.com]
serjevski 29 Jan, 2024 @ 1:25pm 
Can I control any modded blocks? i.e. "Moisture Vaporator" (https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=709975763)
Merlin of Mines  [author] 14 Jan, 2024 @ 9:07am 
Hey @solickm!

There isn't a built-in property for this, but you can set it using the in-game property using the following:


set isSharingInertiaTensor to "My Hinge" hinge "ShareInertiaTensor" property
print "Sharing Inertia Tensor: " + isSharingInertiaTensor

print "Setting Share Inertia Tensor to true"
set "My Hinge" hinge "ShareInertiaTensor" property to true

print "New Property Value: " + "My Hinge" hinge "ShareInertiaTensor" property

You can get the list of block property names using:
print "My Hinge" hinge properties joined "\n"

Cheers!
Rednight 7 Jan, 2024 @ 8:08am 
This is great ty!
chfish 6 Jan, 2024 @ 9:29pm 
Thank you for creating this! It's amazing! So many uses. Great work!
solickm 5 Jan, 2024 @ 7:53pm 
Picked this up a couple days ago, and love it so far. The slog of learning the syntax of any new programming language and learning through trial-and-error is standard with any new programming language, but this is way better than what I foresaw with C+/C++/C#/etc.

I cannot seem to find any documentation in the guides or within these comments/discussions regarding functions accessible through experimental mode, specifically the "Share Inertia Tensor" function.
BENBOBBY 19 Sep, 2023 @ 8:22am 
Hmm for some reason the following line gives a parsing exception:

when "My Camera" camera is triggered
Merlin of Mines  [author] 3 Aug, 2023 @ 8:17pm 
Hey Tyger,

There isn't a built in way, but you can do this yourself using a loop:

for each i in 0..10
increase "My Wheel" suspension height by 1
wait 0.1
Merlin of Mines  [author] 3 Aug, 2023 @ 8:14pm 
Hey @TheTomRom

Glad you're enjoying the script. IIRC cameras will detect grids and voxels. Unfortunately you can't distinguish between currently, but I don't think that'd be an issue for your use case.
-_Tyger_- 29 Jul, 2023 @ 5:08pm 
Is it possible to move wheel suspension to a given height more slowly or specify a speed? Right now it slams down to the low height, then bounces up off the ground when going back to max.
TheTomRom 28 Jul, 2023 @ 8:26am 
This some gread coding you have done here! I very much appreciate both the simplicity to get started on one hand and the complexity on the other hand if you want to extend the automation - thanks for all the work you have put into this!

I also have a small question: Is the camera block handler only triggered by grids or by voxels, too?

I have always wanted to do something like a proximity sensor. I know that there are a few out there but people mostly use this in the 500-5000 m range to detect enemys. My idea is to use the raycast feature for close proximity feedback (like in your car showing the distance when parking). I would use this for landing with large ships in tight spaces (instead of going in to 3rd person view).
Oskarowski 3 May, 2023 @ 1:37pm 
@Merlin, dude... RESPECT! What a great piece of work. Amazing! :steamthumbsup:
Merlin of Mines  [author] 19 Apr, 2023 @ 6:14pm 
Hey @Mouyom,

Definitely sounds doable. You can use a Projector's Ratio property to get whether the projector is 0% or 100% built.


You can rotate a rotor either to a specific angle, or in your case, just reverse it.

And you can turn on/off welders/grinders pretty easily.

Feel free to add more detail on what you're trying to accomplish in the Scripting Questions discussion, and I can help out further.

Here's a rough script to get you started, though I'm not quite sure what conditional checks you are looking for or in what order. I'm not sure you need the projector ratio (could just look for the existence of batteries in Battery Group 1, and you may be able to default to the ratio (should return 0 if none found and comparing against a number).

https://pastebin.com/Awvgd1Du


I didn't test it so it may have some parsing errors, but should get you started. Let me know if that helps! I didn't end up needing the projector ratio, but maybe I misunderstood the requirements.
Mouryom 19 Apr, 2023 @ 12:06am 
Hallo, I've got a rotor, projecor welders, grinder and two battery groups. The projector projects two battery groups. When group 1 is below 1% for example i want to turn on group 2, turn on the grinders rotate the rotor 90 degrees. And the other way around. When projector status is for example 10/10 buildable i want to turn of grinders, turn on welders and reverse the rotor 90 degrees. When 10/10 build (projection completed) turn of welders. Is that a possibility with rhe script? If so can you help me setup the beginning?
Merlin of Mines  [author] 23 Mar, 2023 @ 8:31pm 
@BENBOBBY

I've done my best to expose all available properties from the vanilla blocks either directly or indirectly through the "properties", "actions", and "detailed Info" of all blocks. You can definitely do things like read a hydrogen tank's fill percentage.

There are limits though, the script can only detect and react to things that are exposed to the Scripting API. Unfortunately that does not include "enemy ship comes within 1km", but you can have a turret or sensor wired up and detect when those blocks have a target, which gets you close. Again, happy to discuss specifics in the Scripting Questions discussion.

Ya, I could probably get a world created, others have asked for this as well. I'll give this some serious consideration.

Cheers!
BENBOBBY 23 Mar, 2023 @ 5:54pm 
@Merlin Ah excellent, sounds perfect! I've been waiting for Easy Automation to be updated with more advanced functions and all this time there's been this script lol. Looks like I've got some reading to do!....

Skimming through your website it looks like you've got everything I was hoping covered! I didn't see it explicitly mentioned but I assume its possible to read
advanced block properties (e.g. hydrogen tank filled percentage)? Also is it possible to trigger events on enemy spotted (e.g if enemy ships come within 1km, close all gates) and similar functions for the new Event Controller?

My only suggestion would be to create a world demonstrating some scripts like Coren did if possible. I know you have the examples page, but those are quite advanced and is better actually seeing it live in game all fully set up. Anyways many thanks for creating this amazing script :D
Merlin of Mines  [author] 22 Mar, 2023 @ 6:24pm 
Hey BENBOBBY@

I think you'll find EasyCommands up to the task for just about whatever you want to do: Conditions, functions, threads, block commands, text & LCD support, Collections, inventory management, item production, Cross-Grid scripting, keyboard & mouse input, and more.

I also think you'll find the syntax to be cleaner, but maybe I'm biased. Check it out and see if it does what you need! I'm also happy to answer questions in the Scripting Questions discussion.

Check out spaceengineers.merlinofmines.com/EasyCommands for all the available functionality.

Cheers!
BENBOBBY 22 Mar, 2023 @ 2:14pm 
Ive been using the Easy Automation script, which is great but quite limited so was looking for something more advanced and came across this.... It looks great but I was wondering if it can do everything (and more) that Easy Automation can do?
Aquilartz 22 Feb, 2023 @ 5:21am 
Thanks Merlin!
Merlin of Mines  [author] 21 Feb, 2023 @ 2:57pm 
Hey Aquilartz! Feel free to post what you're trying to do and your current script in the Scripting Questions discussion and I can help take a look.
Aquilartz 21 Feb, 2023 @ 7:21am 
I found an item on the workshop that uses this script but when I try to change the script in any way it completely breaks and doesn't do what it's supposed to do, could I ask for some help if anyone in the comments has time for it? Thanks in advance :D
MedvePapus 16 Jan, 2023 @ 12:28pm 
Oh my god I love you! That is EXACTLY what I needed! Oh my god! Thank you!
Merlin of Mines  [author] 15 Jan, 2023 @ 3:39pm 
Hey @MedvePapus

You can use the Display Block Handler to set the text of an LCD:

https://spaceengineers.merlinofmines.com/EasyCommands/blockHandlers/display

set "My LCD" display text to "Some Value"

You can continually check a condition by spinning off a separate thread which then replays.

https://spaceengineers.merlinofmines.com/EasyCommands/threads#asynchronous-threads


Here's an example script that I think does what you're looking for:
https://pastebin.com/DyJZZfxd

Let me know if that helps!
MedvePapus 15 Jan, 2023 @ 2:47pm 
Or is there a way to continuously check if the connector is connected?
Then I can just make a light block light up or off whether it's connected or not.
At the moment I need to re-run the command block everytime to check if it's connected.
MedvePapus 15 Jan, 2023 @ 2:42pm 
I looked through the documentation but I can't seem to find how to print text to the LCD.
Did I miss it or there's no such thing?

I'm trying to display "connected" if the ship's connector is locked and "Disconnected" if it's not.
Merlin of Mines  [author] 14 Jan, 2023 @ 8:08pm 
Hey there! v2.0.0 is out, which introduces some new support for managing threads including an "await" command you can use for async & wait behavior, as well as some basic thread management including renaming and terminating threads by name or by type.

There's also a couple small life improvements including "helm" keyword for cockpits and battery input/output limit support.

Check it out and let me know if I've broken anything. Cheers!
MedvePapus 10 Jul, 2022 @ 11:21am 
Just what I was looking for & its up to date. nice!
Merlin of Mines  [author] 10 Jul, 2022 @ 11:03am 
Hey folks! v1.5.2 is out with a bugfix for the formatting of large numbers, and a couple of hopefully useful small features, namely support for customize number formatting, and treating some block type keywords as either a block or a block group, such as landing gear, inventories, displays, wheel suspension, and grids.

As always, please let me know if you notice anything broken.
Merlin of Mines  [author] 1 Jun, 2022 @ 7:59pm 
Hey folks! v1.5.1 is out with a fix for the Mute command and to fix restarting your program after registering to listen for events on a channel. Shouldn't have broken anything but please holler if you notice anything broken.
Merlin of Mines  [author] 22 May, 2022 @ 7:24pm 
@Kateye

v1.5.0 fixes that annoying issue where the for loop would not complete immediately and execute for "0". Let me know what you think :).
Merlin of Mines  [author] 22 May, 2022 @ 7:21pm 
Hey folks! I've just released v1.5.0.

This latest release adds multi-word properties, which enables things like

if "My Connector" is ready to connect
set "My Light" color to green

Importantly, this release changes the default property aggregation from "SUM" to a special default aggregation. This new aggregation will give you a list of the block properties for non-numeric properties, and returns an empty list instead of 0 when there are no blocks. This should make more sense for most non-numeric properties.

I also added a few sought after features such as
* Grid Block Handler
* Build/Damage information for all terminal blocks
* "Ready to Connect" support for connectors & magnets

And a few other life improvements & bug fixes.


As usual, please holler if anything is broken!

Happy Scripting
Gray 21 May, 2022 @ 2:44pm 
SUCCESS !!! Thank you ! So that info solved the follower ships issue, but they still just sat there doing nothing, until i changed the Remote Control settings to Flight Mode 'One Way'.... just as an FYI to add to your updated script page maybe?
Merlin of Mines  [author] 21 May, 2022 @ 2:05pm 
You'll need to edit the script to change the name of the cockpit / remote block it is looking for, otherwise it won't find it and then try to add "0" to a vector.

I get the same error locally until I fixed the name of the cockpit it was looking for on my listener ship, and then it works.
Gray 21 May, 2022 @ 12:44pm 
@Merlin of Mines - Hey! thanks for sorting this. So yes that fixed that issue thhanks BUT,, now onn the follower ships i get this:

Queued Threads: 1
Async Threads: 1
[Message] follow
Exception Occured:
Cannot perform operation: plus on
types: number, vector

*sigh* sorry :/
Merlin of Mines  [author] 21 May, 2022 @ 12:21pm 
Hey Gray!

Just tried it out myself. The issue is likely that it's looking for your program to be called "Test Program" and since it isn't finding it, a selector index of 0 is causing the exception. This happened for me locally as well.

Remove that line and it should work for you. I should update the example.

Here's a script that compiled for me locally:
https://pastebin.com/9XdQNbae
Gray 21 May, 2022 @ 12:20pm 
@Kato - Apologies ! I missed it was you that replied, sorry...Any other ideas?
Gray 21 May, 2022 @ 11:34am 
@Merlin of Mines - Steam did not notify me of your reply ! Anyhow, i started a new empty world:

1) I pasted in a workshop ship and made sure the cockpit was named Fighter Cockpit
2) Added a missing antenna and programmable block
3) Copied the ship twice more to be the followers. Not added scripts yet
4) Added the Sender script to the PB of lead ship and it just throws up the following before i even
add the other listener scripts

Queued Threads: 1
Async Threads: 0
[Main] sendCommand
Command: setLocation
79.8681433162037:-61.5472103524662:-
57.0774588447639
100

Exception Occurred:

Offset and length were out of bounds for
the array or count is greater than the
number of elements from index to the
end of the source collection


I wanna pull my hair out... Why won't this work for me? :((
Merlin of Mines  [author] 21 May, 2022 @ 9:19am 
Hey Kateye,

I've been using empty list to represent null. The issue here is that aggregations by default use sum and if you don't find any blocks you get "0", which is definitely not correct.

I'm going to re-do the default aggregation mode so that for string types (and maybe others), as well as for some properties like names, text & media, the default aggregation will use lists.

The result will be that "the names of all doors that are open" will result in an empty list when none are found, vs 0. This will (1) shortcircuit the for loop and (2) enable you to check whether it is empty simply by saying "if x is empty"