I'm referring to this thread. http://www.beamng.com/threads/i-need-help-moding-scenario.27512/ (Since I got 1 reply at monday - not complaining just explaining why I made 2nd thread.) Simply I want to activate erase function only when this scenario is loaded. Also I'd be happy if you could help me deleting Prefabs and TSStatics from map via mod, but leaving barriers around arena. Because TSStatics are the most demanding right now, but barriers around playground are also part of TSStatic. Code: deleteClassObjects('Prefab') ex. When I put this line in to mod, scenario will not load. Changing 'Prefab' in to anything else for example 'TSStatic' works and will delete every TSStatic from map and will load correctly.
Hey, sorry for the late reply. There is one solution to delete TSStatic objects but it won't work with any of our maps so far. Code: ObjectToDelete = scenetree.findObject("NameOfTheObject") ObjectToDelete:deleteObject() In Lua you have to create an object and use the findObject method to assign the desired TSStatic to it. After that you can delete it with the deleteObject method. The problem is that none of our ststic objects has a name so far. A second solution could be to load all TSStatic objects into one table and afterwards calculate the distance between the starting point and the objects. And every object which is futher afar than x meters needs to be deleted. Code: local objNames = scenetree.findClassObjects('TSStatic') Furthermore I would recommend to load your extension with the scenario. Currently your loading the modScript (which is loaded for every map) and this is loading the veggie.lua. So every map/scenario is affected by this. Just rename your custom lua to fit your scenario name and put it into the scenarios folder. It will be loaded automatically if it has the same name as the scenario. Hope this was kind of helpful. Please let me know if you found a proper solution for you.