Space Engineers

Space Engineers

33 ratings
Guide - Mech Driver (MkII) - Dragon Tech Industries
By drag0nsKin
Mech driver (MkII) - Dragon Tech Industries

Summary
This guide is intended for showing you how to take advantage of this easy-to-use and dynamic script that gives you the power to configure and control your Mechs with ease. I will walk you through the basics with a step-by-step on a simple build to get you started, and we will wrap it up with a layout of all of the available configurations that give you more Mech than most can handle!

Updated to work with Hinges

Lets Get Started
   
Award
Favorite
Favorited
Unfavorite
Beginners Walkthrough
Walkthrough
Although I recommend that you read all the documentation to develop a solid understanding of the script...many of you probably want to get to the point. For this reason I have developed an example "starter" mech and this walkthrough to get you started with using this script!

Here is a link to the mech that you will use in this tutorial:
Walkthrough Mech

This walkthrough follows the steps highlighted in the Usage Guide section. This walkthough should be done in creative mode for ease-of-use.

Step 1 (Build your mech) - This step is mostly done for you. Paste the mech into your world, preferably on the earth-like planet. (make sure the platform is touching voxels).

You are provided with a simple (and uuuugly) bipedal mech. The mech is connected to a test platform. All blocks have been nicely named for you. The mech does not function at this time. It is your job to make it do so :).

Step 2 (Add your driver) - This step is done for you. There is already a programmable block containing the script.

Step 3 (Setup Block Names) - This is where you will begin. You cannot use the script effectively without understanding how to set it up! Lets get started...
  1. Enter the Platform Cockpit (not the one on the mech). Press hotbar key "1". This will make the mech attempt a step. You will see that both legs move together in the same direction. This however is not desirable because we want the legs to move opposite of each other! The script can't do that on it's own so lets help it out!

  2. While in the Platform Cockpit press "K" to enter the console.

  3. Search for "[left]". You should see a landing gear, piston, rocket, and rotors. For all blocks except for the rocket, add an " [a]" to their name (w/o the quotes).

  4. Repeat this for "[right]" blocks except adding an " [b]" to their name. When you are done, exit the console.

    The renamed blocks should look something like this:
    Rotor [left] [ankle] [mech] [a]
    Rotor [right] [ankle] [mech] [b]

  5. Use hotbar key "1" again (you can try it a few times this time). You will see that the left and right legs are now part of different groups and alternate their steps! Congratulations, your mech walks!

    However, you likely noticed that it moves a little slow so lets refine it a bit.

  6. While in the Platform Cockpit press "K" to enter the console.

  7. Search for "Rotor". For [left] ([a]) rotor blocks, add a "vel:-10" to their name. For [right] ([b]) rotor blocks, add a "vel:10" to their name. What we are doing here is telling the hip/ankle Rotors how fast to move.

    Your rotor blocks should look like this:

    Rotor [left] [ankle] [mech] [a] vel:-10
    Rotor [left] [hip] [mech] [a] vel:-10
    Rotor [right] [ankle] [mech] [b] vel:10
    Rotor [right] [hip] [mech] [b] vel:10


  8. Use hotbar key "1" again. You will see that the left and right legs now move much faster! Try hotbar key "2" now. This tells the mech to walk continuously! See how fast it is gonna go!?

  9. Use hotbar key "9" to tell the mech to stand.

  10. Lets try actually walking with it! First save a blueprint copy of your working mech.

  11. The mech is attached to the platform by the bottom of its body as well as the landing gear above it. Remove both the landing gear and the pillar that the mech is attached to.

  12. Enter the mech cockpit and fly the mech to a place where you can set it fairly level with the ground.

  13. The mech's hotbar is a little different from the platform, because it is setup for WSAD control! Press "1" on the hotbar to tell the mech to start listening for WSAD controls, press "2" to stop listening, and press "9" to stand. After pressing "1", press "W" and watch your mech go!

That is it! You are ready to build your own mech!

WARNING
This tutorial may make it seem very simple, but I suggest you take the Walkthrough Mech (the one that you saved that is still on the platform) and try the different configurations mentioned in this guide. This tutorial did not take advantage of many components that would make this Mech a very effective little machine! This will also give you the opportunity to get familiar with the options to build much more powerful, complex, and hopefully sexier walking machines!

Good Luck Engineers!
Definitions - Know your terms
Concepts

  • [a] vs [b]
    Identifier for labeling which group it is that blocks belong to ([a] or [b]). [a] and [b] blocks act on opposite/alternating cycles.

    [a] moves forward while [b] moves backward.
    [b] moves forward while [a] moves backward.

    A step is considered an [a] step when [a] blocks are using their defined velocities (at the same time [b] blocks are using the opposite of their defined velocities).

  • Action
    Each block and component of a mech leg, regardless of walking style, falls into one of two categories: single action or double action.

    Single action blocks have one action that they execute per step and double action blocks have...yep you guessed it two actions that they execute within a single step.

    For Example:
    A single action block may be a rotor that swings a leg forward for one step, and then backward for the next.
    A double action block may be a piston that pulls the leg up and then pushes it back back down within one forward step.

  • Tags
    Tags are used for block identities. They can also be passed as parameters to a command to tell a command to only run on blocks that share that tag.

    At minimum, you must use the following tags
    • [mech] - Identifying tag for all blocks that interact with this script. All blocks must have this tag on them
    • [a] - Identifying tag for group A blocks.
    • [b] - Identifying tag for group B blocks.

    You can create any tag you find useful when running the script, defining components, or even just for searching blocks in the control panel.
    For Example
    [left], [right], [front], [back], [upper], [mid], [lower], [hip], [knee], [foot], etc.

    Default tags.
    [mech] - This tag cannot be defaulted and must be added to all blocks that interact with this script. This tag will be used as the argument if no tags are passed with a command.
    [a] - If a block is not set to a [b] tag, then it is considered an [a] tag. Therefore you are only required to define [b] blocks, however it may be useful to define [a] blocks as well.

Terms

Some may be self-explanatory, but this is more for distinguishing terms that may have multiple and/or conflicting meanings.

  • Block - Rotor, Hinge, Piston, Landing Gear. Any in-game block used for the purposes of this script.
  • Component - A group of Blocks that share a common purpose.

  • Driver - The programmable block containing this script.

  • Step - One motion of a leg. A single step is one forward motion, where the backward motion would be another step.

  • Step Cycle - The full iteration of a leg. The combination of a forward motion and a backwards motion.

  • Reverse Cycle - The full iteration of a reverse. The combination of a reversed step and a standard step.

  • Command - Commands are passed as arguments to the script when using the Run option.

  • Tag - Tags are identifiers added to block names. Tags are of the format "[MyTagGoesHere]". Multiple tags can be added to a single block.
Available Commands - Control your Mech
Commands

Commands are how to tell the script what you want it to do.

To use a command simply pass it as the argument when running the script.

Current Commands
  • watch - Script will listen for WSAD control inputs and map them to the following commands: walk, reverseab, reversea, and reverseb (respectively).
  • unwatch - Script will stop listening for WSAD control inputs.
  • stand - Returns all blocks to their designated center position.
  • crouch - Returns all blocks to their designated crouchposition.
  • walk - Executes Step Cycles repetitively.
  • walk1 - Executes one Step.
  • run - Toggles mech between walk/run configurations found in CustomData of the PB.
  • reversea - Executes Reverse Cycles repetitively while reversing Steps for [a] blocks.
  • reverseb - Executes Reverse Cycles repetitively while reversing Steps for [b] blocks.
  • reversea1 - Executes one Reverse Cycle while reversing [a] blocks.
  • reverseb1 - Executes one Reverse Cycle while reversing [b] blocks.
  • reverseab - Executes Reverse Cycles repetitively while reversing Steps for [a] and [b] blocks.
  • reverseab1 - Executes one Reverse Cycle while reversing [a] and [b] blocks.
  • stop - Stops any currently executing command.
  • reset - Resets the internal memory of the script. Does not effect configurations. In effect recompiles the script.
  • setup - Starting state of script. Command allows script to setup internal memory and ensure that script is ready for execution.
  • none - State that the script switches to after setup, designating that it is ready. Also the state used when an invalid command is provided.

Using Tags with Commands

Tags can also be passed as part of the arguments when running a command. This tells the script to only execute the command on blocks that have the provided tag(s).

For example

You could pass [left] to a "reversea" command and the script will only execute the command on [left] blocks.

To do so simply pass the command to the script in the following format:

Command : Tag1,Tag2,Tag3

More Examples

walk - When no tag is provided to the script, it uses the "[mech]" tag (all blocks).
reversea:[left] -Executes reversea command on [left] blocks.
stop:[front],[middle] - Executes a stop command on [front] and [middle] blocks only.

Here is an example hotbar configuration:

1 - Run with argument: watch - To make the mech listen for WSAD key presses.
2 - Run with argument: run - I use this once my mech gets up to speed so I can toggle from walk to run, or from run to walk when I want to slow down.
3 - Run with argument: stand - For when I am ready to stop.
3 - Run with argument: stand
Custom Configuration - Tell your mech how to move
Configuration

Configuration is how Engineers customize their Mech's behaviors. Configurations range from upper-level controls like how fast to walk and default values to use for blocks, to concise controls like velocities, gyroscope balance, logging/debugging, and so much more!

Currently there are two types of configuration: Block Level and Global.

Block Level

Block Level configurations allow Engineers to configure and control each block's behavior independently.

How to use block level configurations

Block Level configurations are set by adding strings (words) to a block's name. They look like "key:value" or tags ("[MyTagGoesHere]").

For Example
If you have a rotor whose velocity should be 1, you should name it like so:
Rotor [mech] vel:1

If you want that same rotor to be part of a group, add that group to it's name:
Rotor [mech] [a] vel:1

NOTE: All Block Level configurations must be separated by a space!

For Example
Rotor [mech] [a] vel:1 center:0

Current Block Level configuration options:
  • vel - Shorthand for velocity. This is the velocity at which the block will move with when triggered by commands. Example: "vel:1".

    The value provided is used on a block's preferred step ([a] or [b]) and the value is multiplied by -1 on a block's unpreferred step (Ex: 1 to -1 or -1 to 1).

  • center - The value the block will try and return to when running a stand command. Only works with Pistons, Rotors and Hinges so it will be a Piston's extension or a Rotor's/Hinge's degree.

  • crouch - The value the block will try and return to when running a crouch command. Only works with Pistons, Rotors, and Hinges so it will be a Piston's extension or a Rotor's/Hinge's degree.

  • action - Identifier for the type of action (single or double) that a block has. The value can only be "single" or "double", however you are only required to define "action:double" blocks since a block will default to the "action:single" type.

  • ig - Shorthand for ignore. Allows a block to be ignored for a given step (a or b). Example: "ig:b"

  • ov - Shorthand for override. Allows a thruster's override to be managed by the script. Example: "ov:300000"

  • dir - Shorthand for direction. The value can only be "forward" or "backward". Allows the script to determine when to use a thruster's override (It uses forward thrusters on Walk commands and backward thrusters on Reverse commands).

  • Defaults - These define what will be used if the value is not defined at the Block Level:
    • vel - Defaults to the Global option (below).
    • center - Defaults to the Global option (below).
    • action - Defaults to single action. Therefore you are only required to define "action:double" blocks.
    • ig - Defaults to do not ignore for any step.

Global

Global configurations allow for all setup that cannot be defined at the Block level. Global configurations can be found in your Driver's CustomData.

The script will setup the CustomData anytime that it detects that it is missing CustomData for the Driver. It will provide default values at that time, but values must remain defined within CustomData. These values cannot otherwise be defaulted by the script and must be defined!

Global configurations also use the "key:value" format.

Current Global configuration options
  • Time variables - These allow precise control over the time between each step and each step's double action.
    • seconds_per_step - The time in seconds between each step.
    • milliseconds_per_step - For more precision, the time in milliseconds between each step.
    • seconds_per_double_step - The time in seconds after starting a step before initiating double action.
    • milliseconds_per_double_step - For more precision, the time in milliseconds after starting a step before initiating double action.

    NOTE: Time values are used in combination with eachother.
    For Example
    Values of "seconds_per_step:1" and "milliseconds_per_step:500" result in a 1.5 second per step value.

  • Mech variables - These allow global configuration of the mech and blocks.
    • default_velocity - The default velocity setting that will be applied to any blocks that don't have a vel configuration. This value is also used when the stand command is running.
    • default_center - The default center setting that will be applied to any blocks that don't have a center configuration.
    • default_crouch - The default crouch setting that will be applied to any blocks that don't have a crouch configuration.
    • gyroscope_tilt_offset_yaw - This value will be applied to Balance Gyroscope's Yaw override to help balance mech while walking.
    • gyroscope_tilt_offset_pitch - This value will be applied to Balance Gyroscope's Pitch override to help balance mech while walking.
    • gyroscope_tilt_offset_roll - This value will be applied to Balance Gyroscope's Roll override to help balance mech while walking.
    • user_override_control - Allows a user's WSAD input to override any currently running command. Script will return to previous command once user input stops.
    • max_stand_attempts - The maximum number of times (script self-repeats command) to attempt a stand. The mech will not stop it's stand action until all blocks have reached their center value OR this value is reached.

  • Logging controls - Allows control over which outputs are displayed and how they are displayed.
    • debug - Allows surface level debugging. Enables output for sequence initiations and script flow.
    • deep_debug - Allows further debugging. Enables extra output for variable values and action determination.
    • append_logs - Logs will append to existing logs rather than overwriting them.

      NOTE: Logs will eventually excede max size and you will no longer see continued output. Use sparingly or in conjunction with clear_log_per_command.
    • clear_log_per_command - Logs will clear each time the user runs a command. Reduces output to only the most recent run.
Usage Guide - Recommended build steps
Usage Guide
This guide is intended to give you a "big-picture" idea of how to build and setup a mech.
  1. Build your mech's legs

    To ensure your design will work, I recommend building a test platform with legs only first. I like to have my mech raised well above the ground so I can test the walking patterns in the air while secured to a stable platform (preferably a station).

    Once you know your mech will walk, let your style and imagination take over on the rest of the mech design!

    *Pro Tip*: In his tutorial @BlackArmor exposes a valuable tip when building larger mechs. Pistons mounted on rotors can help balance weight and stabilize legs!

  2. Add the driver

    Once your legs are built, add a Programmable block to your mech (add "[mech]" to it's name). Add the script and Compile + Save & Exit. You should see some output in the Driver's Console.

    You can confirm setup is complete by checking your Driver's CustomData (you should see lots of stuff in there!). You can leave it as-is for now.

  3. Setup Block names

    You can do one configuration at a time or each blocks entire configuration, its up to you!
    • Add the [mech] tag to all blocks that you plan on using through the script.
      This includes: Rotors, Pistons, Thrusters, Gyroscopes, Cockpit/Flight Seat/Remote Control, Programmable Blocks, LCD/Text Panels,
    • Add the group tag to blocks ([a] or [b]) to pistons and rotors.
    • Add "action:double" to all double action pistons and rotors.
    • Add "vel", "center", and "ig" configurations to pistons and rotors.
    • Add "ov" and "dir" configurations to thrusters.

  4. Setup your commands.
    • WSAD - Utilize natural controls for your mech.

      Set the script's default argument or a hotbar option to "watch" command. When you run that command the script watches (and waits) for your input! You may also utilize the "unwatch" command to stop the script from watching for input.
      This option works in combination with traditional hotbar options AND traditional WSAD controls (thrusters/wheels)!
    • Hotbar - Utilize your hotbar for easy access to commands.
      I recommend starting with a "walk1" for easy monitoring of walking pattern and a "stand" for resetting blocks to their center. Maybe a "stop" command if you want to be cautious!

  5. Test your configurations!

    It is possible that you won't nail it in your first try, but don't fret!

    When trying to correct configuration I recommend checking block groups first. Make sure you have correctly labeled which blocks belong to which group ([a] or [b]).

  6. *Pro Tips*:

    Have you labeled a block as a [b] block, but it still seems to move like [a] blocks? Try setting your vel to a negative value! Ex: "vel:-1".

    Does your mech walk too slow or too fast? Is the double action timing off? Your Driver's CustomData is the answer! Adjust Time variables to your required specifications!

    Did you read the log? Utilize output (like Panel [mech]) for status' and reporting. You may also want to try the debug option in CustomData for further insight!
More Example Builds
Examples

Below are some example configurations. These were taken from live working mechs!

Bipedal (two legs)
Mech Controlled Parts
  • Driver [mech]
  • Gyroscope [mech]
  • Panel [mech]
  • Piston [left] [mech] [a] center:1 vel:-2
  • Piston [right] [mech] [b] center:1 vel:-2
  • Rotor [left] [foot] [mech] [a] center:-29
  • Rotor [left] [hip] [mech] [a] center:30 vel:10
  • Rotor [left] [knee] [mech] [a] center:0 vel:0
  • Rotor [right] [foot] [mech] [b] center:29
  • Rotor [right] [hip] [mech] [b] center:-30 vel:-10
  • Rotor [right] [knee] [mech] [b] center:0 vel:0

Description
[a] ([left]) and [b] ([right]) legs alternate forward/backwards positions opposite of each other.

[left], [right], [foot], [hip], [knee], [foot] are all only identity tags that help organize blocks.

Walking Pattern
  • The pistons retract on their forward step (vel:-2) and extend on backward step ((vel:-2) * -1).
  • Hip rotors move the fastest followed by knee rotors and then foot rotors for optimal stride.
  • Knee rotors move freely so we define their velocity as zero (so the script won't move them), but we set a center value for balanced standing.
  • This build includes a gyroscope for help balancing the mech while walking.

Turning Pattern
This build utilizes gyroscopes for turning.

Reversing Pattern
Using command "reversea1:[left]" followed by "reverseb1:[right]" effectively walks the mech backwards.

Quadpedal (four legs)
Here is an example quad mech
  • Driver [mech]
  • Panel [mech]
  • Piston [back] [left] [mech] [b] vel:1 action:double ig:a
  • Piston [back] [right] [mech] [a] vel:1 action:double ig:b
  • Piston [front] [left] [mech] [a] vel:1 action:double ig:b
  • Piston [front] [right] [mech] [b] vel:1 action:double ig:a
  • Rotor [back] [left] [mech] [b] vel:-4 center:20
  • Rotor [back] [right] [mech] [a] vel:4 center:160
  • Rotor [front] [left] [mech] [a] vel:-4 center:-20
  • Rotor [front] [right] [mech] [b] vel:4 center:200

Description
Group [a] is [back] [right] and [front] [left].
Group [b] is [back] [left] and [front] [right].

[back], [front], [left], [right] are all only identity tags that help organize blocks.

Walking Pattern
  • The pistons extend and then retract on their forward step (vel:1 action:double). They do not move on their backward step (ig:a or ig:b)
  • Rotors move the entire leg component in a swinging motion, while piston extension/rectraction give leg clearance and then grip.
  • Two legs on opposite corners of the mech maintain contact with the ground for balance and grip.

Turning Pattern
  • Using command "reversea:[front]". This will utilize only the front legs to rotate the mech towards it's left side.
  • Using command "reverseb:[front]". This will utilize only the front legs to rotate the mech towards it's right side.

Reversing Pattern
Using command "reverseab" effectively walks the mech backwards.

Hexapedal (six legs)
  • Driver [mech]
  • Panel [mech]
  • Rotor [left] [back] [bottom] [mech] [a] vel:5 center:0
  • Rotor [left] [back] [top] [mech] [b] vel:5 action:double center:0 ig:a
  • Rotor [left] [front] [bottom] [mech] [a] vel:5 center:0
  • Rotor [left] [front] [top] [mech] [b] vel:5 action:double center:0 ig:a
  • Rotor [left] [middle] [bottom] [mech] [b] vel:5 center:0
  • Rotor [left] [middle] [top] [mech] [a] vel:5 action:double center:0 ig:b
  • Rotor [right] [back] [bottom] [mech] [a] vel:5 center:0
  • Rotor [right] [back] [top] [mech] [a] vel:-5 action:double center:0 ig:b
  • Rotor [right] [front] [bottom] [mech] [a] vel:5 center:0
  • Rotor [right] [front] [top] [mech] [a] vel:-5 action:double center:0 ig:b
  • Rotor [right] [middle] [bottom] [mech] [b] vel:5 center:0
  • Rotor [right] [middle] [top] [mech] [b] vel:-5 action:double center:0 ig:a

Description
Group [a] is [left] [back], [left] [front], and [right] [middle].
Group [b] is [right] [back], [right] [front] and [left] [middle].

A well balanced walking style with many optional variations. Notice that this specific build also has no pistons!

[back], [front], [middle], [left], [right] are all only identity tags that help organize blocks.

Walking Pattern
  • Legs have two components: A swinging component ([bottom]) for forward/backwards motion, and a double action component ([top]) for alternating clearance and grip.
  • double action components are ignored on their backwards motion to increase grip and forward movement.
  • Two legs on opposite corners of the mech maintain contact with the ground along with a middle leg on one side for balance and grip.

Turning Pattern
  • Using command "reversea:[front]". This will utilize only the front legs to rotate the mech towards it's left side.
  • Using command "reverseb:[front]". This will utilize only the front legs to rotate the mech towards it's right side.

Reversing Pattern
Using command "reverseab" effectively walks the mech backwards.
15 Comments
Pamelz 29 Sep, 2021 @ 12:51pm 
small light block is stuck in place. The only thing is moving is just left leg. Right leg is TRYING to move, but the block which has the landing gear - is forcefully stuck in place.
Cutting_Board 20 May, 2021 @ 11:46am 
This script sounds awesome but I've fiddled with it for over 30 minutes now and can't get the legs to move at all.
The Erubian Warlord 5 Mar, 2021 @ 12:49am 
can this extend to an 8 legged walker?
COMMANDBrawler 8 Dec, 2020 @ 10:40pm 
dang i cannot seem to get it to work, when i try to walk my own mech my pistons push me backward i find this quide so complicated :( i need whelp. i wanna build mechs and i see the potential of this poggers script
Charles Dankly 21 Aug, 2020 @ 7:34pm 
hmm, so, it is complianing that the length cant be 0, but the legs Ive made it are the same as the default walkthrough legs
Josh The squash 29 Oct, 2019 @ 10:12pm 
Hey can any of you guys help me make a mech
Malacanth 23 Jul, 2019 @ 8:11pm 
@drag0nsKin Awhile back when I was working on mech you recommended your script, well I am back to mechs and could use your assistance
drag0nsKin  [author] 1 Dec, 2018 @ 4:29pm 
Sure! That will take some time though. Out of curiosity, have you tried the beginners walk through? That example mech has a nice introduction to the functionality and how to use it. You can find a quadroped example here too if you want to get a little more advanced.
Gray 1 Dec, 2018 @ 2:47pm 
Can you please link like a video or something? I have no clue how any of this works and this guide doesn't help much.
drag0nsKin  [author] 16 Mar, 2018 @ 10:00pm 
Absolutely, though I don't know how practical they are. The benefit of even #'s of legs is the balance factor. With an uneven # of legs the Mech faces the chance of not being supported from one side.

That is not to say that some clever engineer couldn't create a balanced Tripedal and use this script to make it walk :steammocking: