This post has information useful for those using the 1.9 beta.

Andrew decided to call the new inputs system I cooked up "funky trees". Somehow escapes me why, but I'll roll with it. Here I'll describe what you can do in the land of funk.

First, you can do everything you used to be able to. The new system will only be activated if the input doesn't fit the old system, so all old builds should remain functional.

## Inputs

What you can now do is use the normal input axes:

`Pitch`

`Roll`

`Yaw`

`Throttle`

`Brake`

`Trim`

`VTOL`

`LandingGear`

`FireGuns`

`FireWeapons`

`LaunchCountermeasures`

`Activate1`

`Activate2`

`Activate3`

`Activate4`

`Activate5`

`Activate6`

`Activate7`

`Activate8`

## Flight data

In addition to this you can access some information from the aircraft:

`Altitude`

- Aircraft's altitude in metres`AltitudeAgl`

- Aircraft's altitude above ground level in metres`GS`

- The speed relative to the ground (m/s)`IAS`

- The speed relative to the air, adjusted for the desnity of the air (m/s)`TAS`

- The speed relative to the air (m/s)`Fuel`

- The amount of fuel remaining as a proportion of capacity (0 to 1)`AngleOfAttack`

- The angle of attack (angle airflow vertically meets the boresight) in degrees`AngleOfSlip`

- The horizontal equivalent of angle of attack (degrees)`PitchAngle`

- The pitch of the aircraft (degrees)`RollAngle`

- The roll of the aircraft (degrees)`Heading`

- The heading of the aircraft (degrees)`Time`

- The time since the level loaded (seconds)`GForce`

- The acceleration and gravitational "force" acting on the cockpit in G. I know it's not a force. Shut up.`VerticalG`

- The signed vertical component of the "G Force".`SelectedWeaponName`

- The name of the selected weapon`Latitude`

- The North/South position of the craft (metres)`Longitude`

- The East/West position of the craft (metres)`PitchRate`

- The pitch angular velocity in degrees/second`YawRate`

- The yaw angular velocity in degrees/second`RollRate`

- The roll angular velocity in degrees/second (these 3 inputs are better than using`rate(PitchAngle)`

etc, because they account for wrapping around the angle, as well as being in local space:`rate(Heading)`

is different to`YawRate`

)

## Constants

Values that are always the same:

`pi`

the mathematical constant pi (half a tau, if you will).`e`

the mathematical constant e.`true`

a true boolean value`false`

a false boolean value

## Operators

These are useful for... maths or something.

- Mathematical:

- +, - addition and subtraction (- can be used as a unary operator, for instance
`-Pitch`

- *, / multiplication and division

- +, - addition and subtraction (- can be used as a unary operator, for instance
- Comparison:

- <, > less than, greater than
- <=, >= less than or equal to, greater than or equal to
- ==, != equal to, not equal to

- Boolean:

- &, AND
- |, OR
- !, NOT (this is a unary operator)
- Ternary operator:
`condition ? value_if_true : value_if_false`

- this chooses between two values based on the condition.

## Functions

Finally, there's some helpful functions to do maths for you!

`abs(x)`

- The absolute (positive) value of x.`ceil(x)`

- x rounded up to an integer.`clamp(x, min, max)`

- x clamped between min and max.`clamp01(x)`

- Equivalent to clamp(x, 0, 1).`deltaangle(a, b)`

- The shortest angle delta between angles a and b in degrees.`exp(x)`

- Returns e raised to the power of x.`floor(x)`

- x rounded down to an integer.`inverselerp(a, b, x)`

- Calculates the linear parameter t that produces the interpolant value within the range [a, b].`lerp(a, b, t)`

- Linearly interpolates between a and b, by a proportion of t.`lerpangle(a, b, t)`

- Similar to lerp, but interpolates correctly when values pass 360 degrees.`lerpunclamped(a, b, t)`

- Similar to lerp, but doesn't clamp the value between a and b.`log(x, p)`

- The logarithm of x in base p.`log10(x)`

- Equivalent to log(x, 10).`pingpong(x, l)`

- "Ping-pongs" the value x so it is never larger than l and never less than 0.`max(a, b)`

- The largest value between a and b.`min(a, b)`

- The smallest value between a and b.`pow(x, p)`

- x raised to the power of p.`repeat(x, l)`

- Loops the value x so it is never larger than l and never less than 0.`round(x)`

- Rounds x to the nearest integer.`sign(x)`

- The sign of x (1 if x positive, -1 if x negative)`smoothstep(a, b, t)`

- Similar to lerp, but with smoothing at the ends.`sqrt(x)`

- The square root of x.`sin(x)`

- The sine of x (degrees)`cos(x)`

- The cosine of x (degrees)`tan(x)`

- The tangent of x (degrees)`asin(x)`

- The arc-sine of x (degrees)`acos(x)`

- The arc-cosine of x (degrees)`atan(x)`

- The arc-tangent of x (degrees)

## Memory Functions

These are functions that are special because their output not only depends on inputs but their previous state.

- `sum(x)`

- Returns the sum of all it's inputs over time (the integral of x)

- `rate(x)`

- Returns the rate of change of x relative to its value last frame (the derivative of x)

- `smooth(x, t)`

- When loaded, it's output is set to `x`

. As `x`

changes, the output tries to move to `x`

, but at a rate of no greater than `t`

. This is vaguely equivalent to changing the speed of a rotator.

- `PID(target, current, p, i , d)`

- Evaluates a PID controller with the setpoint of "target", process variable "current" and the gains p, i, and d. Equivalent to: `p * (target - current) + i * sum(target - current) - d * rate(current)`

With all of these at your disposal, I'm excited to see what kind of contraptions you guys come up with, and I'm also open to some suggestions as to some things that could be added.

-WNP78, your funk master.

Inputs that activate based of weapon selected/name

@WNP78 Can I ask is it possible to make the magnet turns on and off more rapidly?

thx

How to do landing gear w/doors (with explaining to can use it more than 4 times (Im good at xml modding) )

@MossySasquatch SelectedWeapons = "Boom 25"

hope it works on mobile

@rexzion SelectedWeapon = "weapon name"

Example for Canon : SelectedWeapons = "Canon"

I found this here: https://www.simpleplanes.com/a/yt8CAx/Death-Machine

how does the

`SelectedWeaponName`

input work?@rexzion abs(x) * -1

Is there a way to get the "abs" function to get the negative value instead of the positive?

Is there any way to get azimuth and elevation angles from my aircraft to my target? I want to make self-operating turrets for my bombers

@WNP78 Thanks so much! I couldn’t figure out what to do as pingpong wasn’t working for me. I guess I needed the time variable in there

@PETG I suppose something like

(Fuel < 0.1) & (pingpong(Time, 1) < 0.5)

would work for that.

Okay, thanks

@MossySasquatch if you're on mobile, there's a known bug, yes. When we get round to releasing a new version it should work.

Hey WNP78, I’m trying to learn some Funk of the Trees, but I can’t figure out how to make something alternate between 0 and 1 once a second. I have the code to activate the loop, just not the loop code. Anyway you could help?

It’s for a magnet that turns on and off to make noise when your fuel is low.

@WNP78, I tried putting the weapon name in quotes and still nothing. Suspect I may have come across a bug.

@MossySasquatch The weapon name indeed must be in quotes (")

Anyone have any idea how to use SelectedWeaponName? I'm trying to make a jet with deployable weapon bays, and I've tried clamp01(SelectedWeaponName=Boom 25) but it doesnt do anything. Do I need to have the weapon name in quotes or parentheses or something? Any help is appreciated. Thanks

How to make a beacon light activate when an activation group is off? I'm trying to figure it out for maybe 20 minutes, no luck..

edit: nvm found it out, i did "Activate8 - 1" in the input.

Oh, and can you set

`max`

and`min`

fields on controls surfaces? I've tried but cant get itAlright sorry for asking so many questions but... I've developed more. I've always wanted a climb/descent/accelaration/decellaration rate monitor for final approaches and such. Obviously theres

`GForce`

, but is`rate(altitude)`

and`rate(TAS)`

a thing? (Or something similar)@WNP78 ohhhh, I knew it must be really simple! Thank you so much

@Panthers4741 for that, you could simply do

`-VTOL + Roll`

, or`Roll - VTOL`

.@WNP78 thank you, I understand now, I previously thought Funky Trees was a separate program, but a simple forum post helped me figure out it is just fancy inputs into XML.

.

So one more question, can I make a

singularinput inverted? For instance if i was making flaperons,`VTOL + Roll`

, could I do some sort of`VTOLinverted + Roll`

to make the VTOL inverted, but not the roll, since that auto-inverts? Thank you@Panthers4741 yes, you can input any expression like this into say, the

`input`

field of an`InputController`

, if you're on mobile with overload, but you seem to know how to use XML. It'll also go in any activationGroup field if you make an expression with a boolean outputOk so how do I get FT? Is it available on mobile? I am usually pretty good at code; I would love to improve using SP! So how do I get funky trees?

Also, the "firegins" and "fireweapons" will work in XML like the other inputs right?