Here, I´ve fixed the code:
` Normal stuff
sync on
hide mouse
` Load textures
load image "walltex.bmp",1
load image "floortex.bmp",2
` Set up Gun
load object "simplegun.x",2
yrotate object 2,255
position object 2,3,-3.5,7
lock object on 2
` Make bullets for player and turrets
make object sphere 5,0.1
make object sphere 6,0.1
make object sphere 22,0.1
position object 22,-10,-10,-10
` Set up player col sphere
make object sphere 1,5
position object 1,175,0,55
` Set up turret stands
make object box 20,20,18.25,20
position object 20,30,-10.875,160
make object box 21,20,18.25,20
position object 21,90,-10.875,160
` Set up turrets
load object "turret.x",3
load object "turret.x",4
scale object 3,200,200,200
scale object 4,200,200,200
position object 3,30,-1.75,160
position object 4,90,-1.75,160
yrotate object 3,90
yrotate object 4,90
fix object pivot 3
fix object pivot 4
position object 3,-10,-10,-10
position object 4,-10,-10,-10
` Wall code
make object box 8,200,40,10
make object box 9,10,40,120
make object box 10,90,40,10
make object box 11,10,40,150
make object box 12,90,40,10
make object box 13,10,40,120
make object box 14,200,40,10
make object box 15,10,40,370
make object box 16,40,40,10
make object box 17,40,40,10
make object box 18,220,10,370
make object box 19,220,10,370
position object 8,110,0,365
position object 9,215,0,310
position object 10,165,0,255
position object 11,115,0,185
position object 12,165,0,115
position object 13,215,0,60
position object 14,110,0,5
position object 15,5,0,185
position object 16,30,0,185
position object 17,90,0,185
position object 18,110,25,185
position object 19,110,-25,185
` Texture walls
for t=8 to 17
texture object t,1
if t=8 or t=10 or t=12 or t=14 or t=16 or t=17 then scale object texture t,object size x(t)/10,4
if t=9 or t=11 or t=13 or t=15 then scale object texture t,object size z(t)/10,4
next t
` Texture floor and roof
texture object 18,2
texture object 19,2
scale object texture 18,22,15
scale object texture 19,22,15
` Set player col to polygons
set object collision to polygons 1
` Set player initial angle
a#=270
` Set up misc variables
t1s#=0
t2s#=0
ps#=0
life#=100
` Main loop
do
` Get old positions
oldx#=object position x(1)
oldy#=object position y(1)
oldz#=object position z(1)
` Handle player movement
if upkey()=1 then move object 1,2
if downkey()=1 then move object 1,-2
if leftkey()=1 then a#=a#-3
if rightkey()=1 then a#=a#+3
` Get new positions
newx#=object position x(1)
newy#=object position y(1)
newz#=object position z(1)
` Handle collision
if object collision(1,0)>0 then gosub collision
` Keep player angle between 0 and 360
a#=wrapvalue(a#)
` Position and rotate camera and player
position object 1, newx#,newy#,newz#
yrotate object 1,a#
position camera object position x(1),object position y(1), object position z(1)
yrotate camera a#
` Keep turrets pointed at player
point object 3,newx#,-1.75,newz#
point object 4,newx#,-1.75,newz#
` AI
If newx#<110 and newy#<180 then gosub ai
` Update screen
sync
` Go back to start of main loop
loop
collision:
if object collision(1,0)>0
position object 1,oldx#,newy#,newz#
if object collision(1,0)>0
position object 1,newx#,oldy#,newz#
if object collision(1,0)>0
position object 1, newx#,newy#,oldz#
if object collision(1,0)>0
newx#=oldx#
newy#=oldy#
newz#=oldz#
else
newz#=oldz#
endif
else
newy#=oldy#
endif
else
newx#=oldx#
endif
endif
return
ai:
if t1s#=0
t1s#=1
position object 5,object position x(3),object position y(3),object position z(1)
set object to object orientation 5,3
move object 5,1
endif
if t2s#=0
t2s#=1
position object 6,object position x(4),object position y(4), object position z(4)
set object to object orientation 6,4
move object 6,1
endif
if t1s#=1
move object 5,1
endif
if t2s#=1
move object 6,1
endif
if object collision(5,1)>0
life#=life#-10
t1s#=0
endif
if object collision(6,1)>0
life#=life#-10
t2s#=0
endif
if object collision(5,0)>8
position object 5,-10,-10,-10
t1s#=0
endif
if object collision(6,0)>8
position object 6,-10,-10,-10
t2s#=0
endif
return
You simply positioned object 3 and 4 BEFORE you loaded them.
Therefore, they didn´t exist by the time you told the editor to position them.
By the way, it looks good