Anteworld - Outerra Game > Modding: Importer, Tools & Utilities
How to register more actions associated with keys ?
fly77:
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 .
cameni:
Go to the iomap folder and check the cfg files there. The action name is file_name/group/action
fly77:
Thank you very much cameni !
fly77:
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: ---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});
...
}
--- End code ---
cameni:
How are the keys bound in your air.cfg?
Navigation
[0] Message Index
[#] Next page
Go to full version