space_ex v0.8.0 SpaceEx.ExpressionBuilder

Much simpler syntax for SpaceEx.KRPC.Expression.

This can be used to streamline the creation of events. For example, the rather unwieldy syntax

# Wait until under 1,000m altitude:
srf_altitude = Flight.surface_altitude(flight) |> ProcedureCall.create()

expr =
  Expression.less_than(
    conn,
    Expression.call(conn, srf_altitude),
    Expression.constant_double(conn, 1_000)
  )

Event.create(conn, expr) |> Event.wait()

Can be replaced with

use ExpressionBuilder

expr =
  ExpressionBuilder.build conn do
    Flight.surface_altitude(flight) < double(1_000)
  end

For a full list of supported syntax forms, see SpaceEx.ExpressionBuilder.Syntax.

It’s recommended that you include this module via use, so that it can issue require statements for other modules it uses macros from.

Link to this section Summary

Link to this section Functions

Link to this macro build(conn, opts \\ [], block) (macro)

Builds a SpaceEx.KRPC.Expression based on the supplied block of code.

Syntax elements are sourced from SpaceEx.ExpressionBuilder.Syntax. See that module for details.

opts may be omitted. If present, additional options are possible:

  • opts[:as_string] — If true, the code to generate an expression will be returned as a string. This may be useful for debugging issues with your expressions.
Link to this function pipeline(a, arg, opts)