Space Engineers

Space Engineers

260 ratings
[PARK] Piston And Rotor Keybinds
4
2
3
3
   
Award
Favorite
Favorited
Unfavorite
File Size
Posted
Updated
426.077 KB
9 Dec, 2019 @ 5:50pm
28 Apr, 2023 @ 4:43pm
15 Change Notes ( view )

Subscribe to download
[PARK] Piston And Rotor Keybinds

Description
This is a script intended to make things like cranes simpler and easier to control. It allows you to control rotors and pistons using movement commands through a cockpit. As a result, you can have four six axes of control, per profile (which I will explain a bit later).

This makes this script useful for things like cranes and possibly rotor based tank steering, although it could potentially be used for anything you want keybind controls for.

Update 1.2.9:
Minor update adding in the setting "togglePistonPower" to only enable pistons for when they are moving. defaults to off in case you want to manually enable/disable pistons, but may reduce the noise pistons make while stationary if enabled.

Update 1.2.5:
Added return to zero functionality.
Three new terms have been added to the generated ini files, Return Position, Return Speed, and Return Order Priority.
When you run the command "Return", it will return each part to the set position, provided it has a speed set, in the order of the lowest Return Order Priority first.

If you set the Return Order Priority to -1, it will cause parts to return to their neutral position whenever their input isn't being received, and won't be considered when executing the return command.

Update 1.2.0:
Added in support for mouse controls with help from Marii. Now you can control your end effectors more... effectively.

Added in ramping so you can tap control things, as well as a general speed multiplier you can define with commands. With both of these it should be a lot easier to make small, precise movements.

Setup is surprisingly easy, even for how I predicted it to be.

1) Put all the rotors, pistons, and ship controllers in a group called "PARK" (You can change this in the script.)

2) Compile the script for the first time. It may give some warnings if the controllers have thruster or wheel control enabled. This does not prevent the script from running.

3) Go into the customData of the blocks and you will find something similar to this:

;Provide the RPM of the part when the corresponding key is pressed.
[PARK:Main]
Forward=0
Backward=0
Left=0
Right=0
Up=0
Down=0
Roll Left=0
Roll Right=0
Pitch Up = 0
Pitch Down = 0
Yaw Left = 0
Yaw Right = 0
Return Position=0
Return Speed=0
Return Order Priority=0

Each of the values represent movement commands that can be read through the cockpit. When the corresponding key is pressed, it adds the corresponding value to the velocity of the part. This is additive, it will sum up the total value and apply that value to the part. For rotors, it is RPM, for pistons, it is M/S, for suspension, it is the throttle ratio.

For example, if you want a rotor to turn clockwise when you press forward, and counterclockwise when you press backward, then you just need to set "Forward=[a_positive_value]" and "Backward=[a_negative_value]".

By default, the script ramps up in speed until it hits the defined speed over 3 ticks. This should make fine adjustments easier. You can change this at the beginning of the script.

Thanks to a recent addition added in by Marii, you can also use mouse controls to move components run by PARK.
The last four settings correspond to that.

Recently, I added in Return Angle, Return Speed, and Return Order Priority.
If you run the command "Return", it will return to the angle set, at a set speed, prioritized lowest first.
So if you want a part to return to 15 degrees at a speed of 2 RPM after the first set of the controlled parts moved, then you can do:
"Return Angle=15"
"Return Speed=2"
"Return Order Priority=1" (0 goes first, 1 is second.)
Setting Return Order Priority to -1 causes the part to return to neutral positon immediately after control is released.

Set this up as desired.

4) Recompile to get the script to recognize changes.

(Optional) The script allows you to set up multiple profiles. To add a new profile:

5) Go into the customData of the programmable block. Add the name of the new profile on a newline.

For example, the initial pregenerated profile should look like this:

"Main" (The actual value contained within quotation marks.)

And to add a new profile to it could make it look like something like this:

"Main
Secondary"

There is no rule that says you must add them one at a time.

6) Recompile the PB to get it to recognize changes. The PB will take the new string and use it to generate a new section in each block. This will appear similar to the the first example, but incorporating the name of the profile you just defined.

7) Set up as normal.

Commands:
"enable" Lets the script read commands from the cockpit.
"disable" Disables the cockpit from reading commands from the cockpit. The script will stop movement if it is moving.
"toggle" Toggles between the enabled and disabled states.
"return" Returns the parts to the defined zero position provided they have a return speed.
"mult <ratio>" sets the multiplier that effects the speed of configured parts. "mult 2" would double speed, for example.

Anything other than the above will be considered a command to switch profiles.
For example, typing "secondary" would cause the script to attempt to switch to that profile, and gives a warning if no such profile exists.

Note, the commands are not case-sensitive, at least for now.

Footnote:
I have noticed that often when people set up cranes in survival they usually just use clunky terminal options to actuate things. I hope that this system at least allows you to set up your cranes with more natural controls. I created this script to make it easier to control cranes without being all that much more difficult to set up. I hope you find this script useful.

TODO:
0) Not sure, feel free to leave suggestions for me.
Popular Discussions View All (3)
4
20 Jun @ 10:32pm
Runs, but does not create the sample "Custom Data" info in the instructions
GrumpyGoblin
2
31 May @ 10:42am
Exception, then initialising
José Runter
3
3 May, 2023 @ 4:35pm
Exception caught
Gemini Sierra
177 Comments
Leconite 16 Nov @ 5:17am 
From Above
"Anything other than the above will be considered a command to switch profiles.
For example, typing "secondary" would cause the script to attempt to switch to that profile, and gives a warning if no such profile exists."

To control / use your Arms Profile run the PARK PB with the command Arms
To control / use your Main profile run the PARK PB with the command Main

If the currently running profile has return value set up, you can run the PARK PB with the return command to reset the profile to it's return position.
Strong Hoov ✅ 16 Nov @ 5:06am 
Okay i've got 2 Profiles "Main. and "Arms. for a mech controls...Now could PLEASE give us an TEXT / VISUAL example on how to "Command" Between these new "Profiles or USE a specific Profile...
=NeO= 13 Nov @ 11:44am 
Another problem i'm having in 2 different saves is that the return priority only works when it's set to 0, everything higher that 0 is ignored, does anyone have the same problem?
jiyuueno 10 Nov @ 9:53pm 
Everything works just fine after i pop a fresh remote control onto the grid, but for whatever reason, without fail, each time I start up my game, I have to go thru the ritual of remote replacement.

On my previous save, running all the exact same mods, with a fairly identical-ish crane truck, it worked flawlessly for weeks. (until Klang saw fit to completely destroy all that I had created)
Trekki  [author] 10 Nov @ 8:01pm 
The value after mult is a floating point number so you can do stuff like "mult 1.25" if you want.
Also huh, I am not sure what is going on, it should be converting the text to lowercase before running the command, maybe next time I mess with scripts I can go into it and see if I missed some kind of language compatibility issue.
jiyuueno 10 Nov @ 6:35pm 
@Kham No, just "Main", and after setting them up they work fine, until i have to save and quit for whatever reason, then once I load up my save again, I have to Grind down my control block and reset all my hotbars.
Also thats good to know about "mult 2". Though if it doubles everything, Ide rather have the finer control over each setting with profiles.
Kham 10 Nov @ 6:32am 
@jiyuueno are your actual command in run "run main" etc? Because you should just be putting the name in the run command so "main".
Also if you want to increase speed you don't need to use another profile just use a run command "mult 2" for double speed "mult 1" for the normal speed set in custom data, "mult 3" for triple speed etc.
jiyuueno 9 Nov @ 9:57pm 
Running PARK for a crane thru a Remote control block, whenever I reload the save, I cannot switch between control groups with the run command ( "run main" "run fast" that sort of thing) PARK still functions, but its just stuck on "Main" forever. The only fix I have found so far is to grind down, replace, and set up a new remote control block each time I Load my game.
Leconite 31 Oct @ 6:24am 
More specific information about the configuration of the tank would be helpful.
It is currently unclear if PARK is being used to steer the turret, or the entire tank.
MrFox 31 Oct @ 5:09am 
WHen you press D it goes left..
When you hit A it goes left...
even tried to set a - rpm number didn work