Essential Functions - Outerra/anteworld GitHub Wiki

Each mod (JavaScript or C++) needs to have at least these functions:

  • init_chassis(params) - used to initialize chassis (shared across all vehicle instances of the same type). It is called only the first time an instance is created and is used to define the vehicle construction, binding bones(steering wheel, gauges, etc.), adding wheels, lights, sounds, sound emitters, action handlers, etc.

  • parameter params - custom parameters from objdef.

  • init_vehicle(reload ) (for vehicle) or initialize(reload ) (for aircraft) - invoked for each new instance of the vehicle (including the first one), it is used to define per-instance parameters.

  • parameter reload - true if object is being reloaded.

When initializing variables for your instance, use "this" keyword for changes to affect only instance of sample car, you are currently in.

  • update_frame() (called each frame) or simulation_step() (called 60 times per second) - invoked each frame or 60 times per second (based on which function is used) to handle the internal state of the object.

update_frame can have following parameters:

  • dt - delta time from previous frame
  • engine - gas pedal state (0..1)
  • brake - brake pedal state (0..1)
  • steering - steering state (-1..1)
  • parking - hand brake state (0..1)

simulation_step can have only parameter dt.

Warning: update_frame parameters contain some values only in case, they are not handled by user...