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: Make appear/disappear/move programatically objects from a scenery ?  (Read 151 times)

fly77

  • Sr. Member
  • ****
  • Posts: 288

Is it possible to use a javascript file (for instance of a vehicle) to make disappear/appear or displace  objects in a scenery previously placed by the scenery editor ? The idea would be to make appear or disappear or displace objects of the scenery depending on time of day (for instance rush hour) or weather conditions to bring the scenery to life? I guess that if it would be possible to get an "id" of objects inside the editor these could then be used to manipulate the objects from within the javascript, but I could not see any information on something like "id" in the scenery editor. Is there a way to get such info to be shown or retrieved somehow ?
« Last Edit: February 24, 2019, 01:17:20 am by fly77 »
Logged

fly77

  • Sr. Member
  • ****
  • Posts: 288
Re: Make appear/disappear/move programatically objects from a scenery ?
« Reply #1 on: March 04, 2019, 12:25:57 pm »

When hitting a building or a static object (vehicle ) with a tracer from the code below I get indeed an "id" that is a large negative number which seems to identify the building/object in the scene. If I hit a spawned vehicle I get a positive small number as result. Hitting the first spawned vehicle gives hitid=0 and hitting a second spawned vehicle gives hitid=1 etc. How can I use this/these ids to make disappear or move the hit object ? More precisely how can I use the returned id to access the object for instance to remove it with the remove_from_scene() command.

hitid =  $explosions.landed_tracers()[0].hitid;
« Last Edit: March 04, 2019, 02:34:13 pm by fly77 »
Logged

cameni

  • Brano Kemen
  • Outerra Administrator
  • Hero Member
  • *****
  • Posts: 6581
  • Pegs is clever, but tae hain’t a touch sentimental
    • outerra.com
Re: Make appear/disappear/move programatically objects from a scenery ?
« Reply #2 on: March 06, 2019, 06:20:10 am »

get_object(id) called on world object will return a reference to the object.
Logged

fly77

  • Sr. Member
  • ****
  • Posts: 288
Re: Make appear/disappear/move programatically objects from a scenery ?
« Reply #3 on: March 06, 2019, 08:28:26 am »

Thank you very much for the kind help..will reward it sharing some new mod.
Logged

fly77

  • Sr. Member
  • ****
  • Posts: 288
Re: Make appear/disappear/move programatically objects from a scenery ?
« Reply #4 on: March 06, 2019, 12:39:51 pm »

Wow !  It works ! I can now destroy vehicles and buildings ! Opens lots of possibilities ! Even damage to "modular" buildings.  Thanks a lot !! Now I'll have to work a lot  =D =|
Logged