User mods, screenshots & videos > Scenery

Make appear/disappear/move programatically objects from a scenery ?

(1/2) > >>

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 ?

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;

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

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

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 =|


[0] Message Index

[#] Next page

Go to full version