Hey all, I know that the console allows me to span a vehicle (or a prop) using the function below: core_vehicles.spawnNewVehicle("cardboard_box", {config = 'vehicles/cardboard_box/large.pc'}); I'm trying to span a pile of boxes at random places by using a loop: local items = 0; while (items < 50) do core_vehicles.spawnNewVehicle("cardboard_box", {config = 'vehicles/cardboard_box/large.pc'}); items = items + 1; end However I'd like to have some control where to spawn them, currently they space one after each other equally, which is expected since I'm not specifying where to spawn them. Is it possible to control where to span things (or even the orientation) using this function? I didn't find any references. Thanks in advance.
Hey, here's an example code that spawns those boxes in a circular pattern on Gridmap V2: Code: local items = 10 local offset = vec3(-150, -200, 105) for i = 0, items - 1 do local angle = i / items * 2 * math.pi local x = math.cos(angle) * 10 local y = math.sin(angle) * 10 local z = 0 local vehPos = vec3(x, y, z) + offset local vehRot = quatFromAxisAngle(vec3(0,0,1), -angle) core_vehicles.spawnNewVehicle("cardboard_box", {config = 'vehicles/cardboard_box/large.pc', pos = vehPos, rot = vehRot}) end Here's the result: Sounds like you type it all in the console and execute it that way, but in my opinion, here's an easier way to do it for longer code: 1. Create a Lua file (lets say name it test.lua) in the BeamNG userfolder 2. Write your code there 3. And just execute the Lua file in the console using Code: dofile("test.lua")