Interactive elements ‐ how to use them - Outerra/anteworld GitHub Wiki
You can find more about interactive elements in Vehicle Interactive elements setup (Vehicle IK) .
Interactive elements can have predefined values, which define their behaviour, so they can be used as button, slider, knob, lever or stick.
You can find these values in Scene editor -> Plugins -> Entity properties -> Bone attributes.
Properties labeled as "action" are the ones, that are important for us (for now), those are:
- ot_knob_action_name - "action" used in action handler (if there is any)
- ot_knob_action_velocity - "vel" in action handler "options"
- ot_knob_action_acceleration - "acc" in action handler "options"
- ot_knob_action_centering - "center" in action handler "options"
- ot_knob_action_min_value - "minval" in action handler "options"
- ot_knob_action_max_value - "maxval" in action handler "options"
- ot_knob_action_positions - "positions" in action handler "options"
- ot_knob_action_channel - "channels" in action handler "options"
In script
For using the elements with predefined values in script, you can use following action handlers:
- register_handler("action", function) - this handler works with predefined parameters.
- register_axis("action", { }, function) - when this handler has no "options" properties (just empty braces), it works the same as register_handler(), but you can also add new properties, or overwrite predefined properties by defining them here.
Examples:
this.register_handler("vehicle/controls/brake", function(v) { } // works with predefined values (see image above)
this.register_axis("vehicle/controls/brake", {vel: 10}, function(v) { ) // also works with predefined values, except velocity, which is now set to 10
Note: be careful, when defining positions parameters, as it may significantly change the element functionality. For more info see Control elements .
For "action" is normally used format "cfg_file_name/group_name/action_name ", which works with interactive element only when the action (ot_knob_action_name) is already predefined (e.g. when an element with predefined action "vehicle/controls/brake" is interacted with, action handlers in our examples would be called).
In case, that the interactive element does not have an action, then automatic generated name format "knob_action_[name of bone]" is used.
this.register_handler("knob_action_brake_pedal", function(v) { }