That one was rather easy to fix. This code works and I can compile it:
phy start
sync on
sync rate 0
make object box 1, 40, 1, 40
position object 1, 0, 0, 0
phy make rigid body static box 1
make object sphere 100, 80
set object cull 100, 0
make object box 2, 4, 16, 4
position object 2, 0, 9, 0
texture object 2, 1
phy make rigid body dynamic box 2
make object box 3, 2, 2, 2
position object 3, 0, 18, 0
texture object 3, 1
phy make rigid body dynamic box 3
phy make revolute joint 1, 2, 3, 0, 1, 0, 0, 18, 0
make object box 4, 10, 1, 1
position object 4, 6, 18, 0
texture object 4, 1
phy make rigid body dynamic box 4
phy make revolute joint 3, 2, 4, 0, 1, 0, 0, 18, 0
position camera -30, 25, 0
rotate camera 40, 90, 0
Y# = 17
for i = 5 to 20
make object sphere i, 1
position object i, 10, Y#, 0
color object i, rgb ( rnd ( 255 ), rnd ( 255 ), rnd ( 255 ) )
phy make rigid body dynamic sphere i
phy make sphere joint i, i, i - 1, object position x ( i ), object position y ( i ), object position z ( i )
Y# = Y# - 1
next i
CreateCubeStack( 21, 35, 0, 17 )
CreateCubeStack( 36, 50, 0, -15 )
CreateCubeStack( 51, 65, -15, 10 )
CreateCubeStack( 66, 80, -10, -8 )
y#=-1
do
phy set rigid body angular velocity 4,0,y#,0
y# = y# + 1
phy update
sync
loop
function CreateCubeStack( start, ending, x, z )
y = 1
for i = start to ending
make object cube i, 1
position object i, x, y, z
phy make rigid body dynamic box i
texture object i, 2
y = y + 1
next i
endfunction
Before the first CreateCubeStack was called, a object with the number 20 already existed... Therefore the error.
So I changed this bit:
CreateCubeStack( 20, 35, 0, 17 )
CreateCubeStack( 35, 50, 0, -15 )
CreateCubeStack( 50, 65, -15, 10 )
CreateCubeStack( 65, 80, -10, -8 )
To this:
CreateCubeStack( 21, 35, 0, 17 )
CreateCubeStack( 36, 50, 0, -15 )
CreateCubeStack( 51, 65, -15, 10 )
CreateCubeStack( 66, 80, -10, -8 )
When I compile it I can clearly see that it runs... But the camera isn't positioned right I think.
Please note that I have removed the textures from the above code.