Utility Scripts · Physical Controls

Lever

Lever is a lever with a pivot at the bottom of its rod and limited rotation around local +X.

GML
jolt_control_lever(options=undefined)

Call jolt_start() before creation. Every factory accepts one optional options struct and returns JoltControl, or undefined on error. Common options: parent, position/rotation or local_position/local_rotation, mass, resistance and output. Dimensions are full lengths in metres, mass is in kg; this API uses degrees for angles. See Mounting, Size and Rendering for shared configuration.

ItemMeaning / default
size{x:0.1, y:0.1, z:1}
mass1 kg
min_angle / max_angle−45° / 45°
initial_angle0°
auto_return / targetfalse / 0.5
drive{max_torque:10, frequency:4, damping:1}
detents[]

The reference rod extends from the pivot along +Z. Min and max must contain zero and span more than 0 but less than 180°. The value is (angle − min_angle) / (max_angle − min_angle), clamped to 0..1. With asymmetric limits, physical zero therefore need not produce 0.5.

target is a canonical value in 0..1. set_target() alone only stores the target; enable the drive with auto_return: true or set_auto_return(true). The body moves towards it physically; creation does not place the body at target.

Example#

GML
lever = jolt_control_lever({
    min_angle: -40, max_angle: 40,
    detents: [0, 0.5, 1],
    output: {min: -1, max: 1}
});
var command = lever.get_output_value();

Current project integrations#

Verified operation contracts#

These contracts distinguish units, return values, errors and lifetime according to the current implementation. Check results: false, 0 and undefined can mean different things for different methods.

Symbol / ownerSignatureOperation contract
jolt_control_leverjolt_control_lever(options=undefined)Requires managed world, optional options, returns owning JoltControl or undefined. Without parent world position/rotation; with parent local_position/local_rotation, do not mix. Lever: size .1/.1/1 m, mass1 kg, min/max -45/45°, initial0, auto_return false, target.5; +X axis, lever +Z.