Why do I keep getting a nestling error in this code? I am trying to get a straffing turning player hovercraft to work. Can anyone help please?
rem STRAFFING, TURNING HOVERCRAFT
rem ==========================================
rem This is an attempt to make a hovercraft which turns,
rem goes foward and backward and straffes, to be a basis for a hovertank
rem ------------------------------------------
rem updated by Vampyre(Ian George)
autocam off
hide mouse
sync on
rem load flying object
load object "Hover1.X",2
rem Rotate and fix data so character faces right way
xrotate object 2,0
yrotate object 2,180
zrotate object 2,0
fix object pivot 2
Rem texture matrix
Load image "grass09.bmp",1
Prepare matrix texture 1,1,1,1
Fill matrix 1,0,1
rem Scale your object to double its width and depth, but not height
scale object 2,1200,1200,1200
rem Make drone to mark a back position
make object sphere 3,10
rem Set camera range
set camera range 1,10000
rem Main loop
do
rem movement
if joystick left()=1 then turn object left 2,5
if joystick right()=1 then turn object right 2,5
rem up
IF joystick slider a()= 1
X# = NEWXVALUE(X#,WRAPVALUE(aY#),1)
Z# = NEWZVALUE(Z#,WRAPVALUE(aY#),1)
ENDIF
rem down
IF joystick slider a() = 1
X# = NEWXVALUE(X#,WRAPVALUE(aY#-180),1)
Z# = NEWZVALUE(Z#,WRAPVALUE(aY#-180),1)
ENDIF
rem left
IF joystick twist z() = 1
X# = NEWXVALUE(X#,WRAPVALUE(aY#-90),1)
Z# = NEWZVALUE(Z#,WRAPVALUE(aY#-90),1)
ENDIF
rem right
IF joystick twist z() = 1
X# = NEWXVALUE(X#,WRAPVALUE(aY#-270),1)
Z# = NEWZVALUE(Z#,WRAPVALUE(aY#-270),1)
ENDIF
oX# = OBJECT POSITION X(1)
oZ# = OBJECT POSITION Z(1)
hover# = (hover#+hovinc#)
IF hover#>0.6
hovinc# = -0.03
ENDIF
IF hover#<0.1
hovinc# = 0.03
ENDIF
POSITION OBJECT 1,X#,(Y#+3+(hover#)),Z#
IF OBJECT COLLISION(1,0)>6
POSITION OBJECT 1,oX#,(Y#+3+(hover#)),oZ#
ENDIF
if X#<0 then X#=0
if X#>200 then X#=200
if Z#<13 then Z#=13
if Z#>200 then Z#=200
POSITION OBJECT 1,X#,(Y#+3+(hover#)),Z#
rem HAT control
jhat=joystick hat angle(0)
rem text 320,160,"HAT signal: "+str$(jhat)
rem **** use these lines below if you want the view to be immediate
rem **** and rem out the other lines that aren't needed
rem **** integrity checks for code alterations are included
rem turnview=0
rem if jhat=27000 or jhat=31500 then turnview=-90
rem if jhat=9000 or jhat=4500 then turnview=90
rem if jhat=18000 or jhat=13500 or jhat=22500 then turnview=180
rem horizontal view position
if turnview>0 and turnview<180 then turnview=turnview-2:if turnview<0 then turnview=0
if turnview>179 then turnview=turnview+2:if turnview>359 then turnview=0
if jhat=27000 or jhat=31500 or jhat=22500 then turnview=wrapvalue(turnview-4):if turnview>180 and turnview<220 then turnview=220
if jhat=9000 or jhat=4500 or jhat=13500 then turnview=wrapvalue(turnview+4):if turnview<180 and turnview>140 then turnview=140
rem vertical view position
if pitchview>0 and pitchview<180 then pitchview=pitchview-2:if pitchview<0 then pitchview=0
if pitchview>179 then pitchview=pitchview+2:if pitchview>359 then pitchview=0
if jhat=18000 or jhat=13500 or jhat=22500 then pitchview=wrapvalue(pitchview-4):if pitchview>180 and pitchview<280 then pitchview=280
if jhat=0 or jhat=4500 or jhat=31500 then pitchview=wrapvalue(pitchview+4):if pitchview<180 and pitchview>80 then pitchview=80
If InKey$() = "1" And cammode = 0 Then cammode = 1 : `Set the camera mode to third person
If InKey$() = "2" And cammode = 1 Then cammode = 0 : `Set the camera mode to first person
If cammode = 0
rem Place camera and set orientation to object
position camera object position x(2),object position y(2),object position z(2)
set camera to object orientation 2
EndIf
If cammode = 1
rem Place camera and set orientation to object
POSITION CAMERA -10,2,25
POINT CAMERA 0,0,0
POSITION OBJECT 1,0,(Y#+3+(hover#)),0
rem camerapositions
cX# = NEWXVALUE(X#,(aY#-180),15)
cZ# = NEWZVALUE(Z#,(aY#-180),15)
oY# = OBJECT POSITION Y(1)
POSITION CAMERA cX#,9.3,cZ#
POINT CAMERA X#,9.3,Z#
rem Get back position of object for camera
pitch object down 2,11
move object 2,-150
position object 3,object position x(2),object position y(2),object position z(2)
move object 2,150
pitch object up 2,11
hide object 3
rem variables
X# = OBJECT POSITION X(1)
Z# = OBJECT POSITION Z(1)
Y# = GET GROUND HEIGHT(1,X#,Z#)
cX# = CAMERA POSITION X()
cY# = CAMERA POSITION Y()
cZ# = CAMERA POSITION Z()
b1X# = OBJECT POSITION X(2)
b1Z# = OBJECT POSITION Z(2)
b2X# = OBJECT POSITION X(3)
b2Z# = OBJECT POSITION Z(3)
e1X# = OBJECT POSITION X(7)
e1Z# = OBJECT POSITION Z(7)
e1Y# = GET GROUND HEIGHT(1,e1X#,e1Z#)
POSITION OBJECT 7,e1X#,(e1Y#+3.6),e1Z#
rem now set turnview as needed for HAT control
turn camera right turnview
pitch camera up pitchview
rem and reset the camera view back to normal to center everything
turn camera left turnview
sync
loop