Forums » Your showcase, tips and tutorial discussions »
Generate IMML at runtime
Added by Craig Presti about 4 years ago
Here's an example that generates a non-movable box and 50 physics based sphere's when the park is loaded.
It accomplishes this run-time addition by using the following script in the OnLoad event:
--generate a base
scene:write("<Primitive Type='Box' Position='0,0,0' Size='100,0.5,100'>"..
"<Physics Enabled='True'/>"..
"<Material Diffuse='#FF0000'/>"..
"</Primitive>", nil)
v = vector(0,50,0)
i = 0
--generate 50 spheres
while(i < 50) do
v.x = math.random(-10,10)
v.z = math.random(-10,10)
scene:write("<Primitive Complexity='Low' Type='Sphere' Position='"..v:tostring().."' Size='1,1,1'>"..
"<Physics Enabled='True' Movable='True' Weight='20'/>"..
"</Primitive>", nil)
i = i+1
end