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: setting weather parameters programmatically  (Read 410 times)

fly77

  • Hero Member
  • *****
  • Posts: 606
setting weather parameters programmatically
« on: March 23, 2019, 06:57:55 am »

I'd like to set enviromental parameters programmatically from a javascript file of a model.
I tried in many ways but could not figure out how to pass values to the   "set_weather_params()"   method.
I allways get syntax errors.
Any hint ?



Code: [Select]

var $environment,weather,rain;

function init_vehicle(){
 ..........
    $environment = this.$query_interface("ot::js::environment.get");     
    weather = $environment.get_weather_params();   
    rain=weather.rain_density;
}


function update_frame(dt, engine, brake, steering)
{
 ......   
    $environment.set_weather_params( weather.rain_density:1 );

}
Logged

cameni

  • Brano Kemen
  • Outerra Administrator
  • Hero Member
  • *****
  • Posts: 6651
  • Pegs is clever, but tae hain’t a touch sentimental
    • outerra.com
Re: setting weather parameters programmatically
« Reply #1 on: March 25, 2019, 03:58:32 am »

It expects the same object you receive from get_weather_params.
You can log it via $log(JSON.stringify(obj)) to see what's in there.
Logged

fly77

  • Hero Member
  • *****
  • Posts: 606
Re: setting weather parameters programmatically
« Reply #2 on: March 25, 2019, 04:41:00 am »

Thank you very much cameni..works ! will be very useful to use weather parameters as global variables for trying to set up a micro game.

Code: [Select]
var $environment,weather,rain;

function init_vehicle(){
 ..........
    $environment = this.$query_interface("ot::js::environment.get");     
    weather = $environment.get_weather_params();   
    rain=weather.rain_density;
}


function update_frame(dt, engine, brake, steering)
{
 ......   
  weather.rain_density=1; 
  $environment.set_weather_params(weather);

}
« Last Edit: March 25, 2019, 04:53:56 pm by fly77 »
Logged