Outerra forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Outerra Tech Demo download. Help with graphics driver issues

Author Topic: How to register more actions associated with keys ?  (Read 2015 times)

fly77

  • Full Member
  • ***
  • Posts: 201
How to register more actions associated with keys ?
« on: December 07, 2018, 12:26:55 pm »

As we develop more complex models with more buttons and knobs we need to associate more and more actions/events to keys registering them. While it is clear how to do this
there is however a difficulty to find out/guess  the right  token& name.

//Register event action handler
    //@param name hierarchic action name, file/group/action
    //@param group activation group where the action is assigned (can be enabled/disabled together)
    //@param channels number of extra channels that the handler supports
    //@return slot id or -1 on fail
    int register_event__( const coid::token& name, uint group = 0, uint channels = 0 );

(https://github.com/Outerra/anteworld/blob/master/include/ot/vehicle_physics.h)


By having a look at the F1 -> control  menu of key associations for some events the correct token name can be guessed with some luck and trial and error, for others I could't guess the right token name.


"Passing beam lamps"  --->  this.register_event("car/lights/passing",  function(v) {some code ....;});   // key L             not so obvious but could deduce from models available

               "Horn"          -->  this.register_event("car/controls/horn",  function(v) {some code ....;});   // key H              by trial I could find it out that it works but not if token name is "car/controls/Horn" as would be guessed instead
       
 "Master Arm on/off"      -->   this.register_event("air/weapons/master_arm", function(v) {some code ....;});  // key J    again seems that Capitals must be avoided in token name

"Toggle geo stabilized tracking on/off"  --> ??   couldn't guess so far which token name works....    // key K

similarly for lots of other actions it is not really easy to guess the token name that works..

Any help from developers is greatly appreciated .

   
« Last Edit: December 07, 2018, 02:14:48 pm by fly77 »
Logged

cameni

  • Brano Kemen
  • Outerra Administrator
  • Hero Member
  • *****
  • Posts: 6542
  • Pegs is clever, but tae hain’t a touch sentimental
    • outerra.com
Re: How to register more actions associated with keys ?
« Reply #1 on: December 08, 2018, 04:15:10 am »

Go to the iomap folder and check the cfg files there. The action name is file_name/group/action
Logged

fly77

  • Full Member
  • ***
  • Posts: 201
Re: How to register more actions associated with keys ?
« Reply #2 on: December 08, 2018, 06:30:20 am »

Thank you very much cameni ! 
Logged

fly77

  • Full Member
  • ***
  • Posts: 201
Re: How to register more actions associated with keys ?
« Reply #3 on: December 30, 2018, 02:14:19 pm »

I am trying to register an axis of an airplaine using LEFT RIGHT UP DOWN arrows using the default binding defined in iomaps (verified in the air/sensor menu) to control the fps camera position of the Cessna by the arrow keys.
however the controlled variable that i named "camx" does not change as verified by printing its value on a canvas. What is wrong with the code below ?

Code: [Select]
var camx;

function initialize(reload){
...
   camx=0;
   this.register_axis("air/sensor/slew_azimuth", {minval:0, maxval:1, vel:1, center:0}, function(v){       
    camx = v*2;
  });

}


function update_frame(dt){
....
this.set_fps_camera_pos({x:-0.25+camx, y:-0.2, z:0.8});
...
}

« Last Edit: December 30, 2018, 02:21:36 pm by fly77 »
Logged