I know it works just fine, Ive tested your example, and thats whats so weared. It should work. But for some reason I cant make it to. I can test to make them global as intrigers... if I can figure out how (still a noob).
Ive tried to make it work. Maybe its some other part of the subrutine, Ive both some code to control the "autopilot" and some to make a manual control system. Here it is:
rem The ship
player:
rem Ship model
select stats(1)
case 1 : model$="Leithad (li-fr)" : endcase
case 2 : model$="Deeiran (me-fr)" : endcase
case 3 : model$="Juzzedn (he-fr)" : endcase
endselect
rem The max cargo
if stats(3)>stats(2) then stats(3)=stats(2)
rem Control ship
rem Turn ship to right or left
if leftkey()=1 then factor1=-2.5 : turn=0
if rightkey()=1 then factor1=2.5 : turn=0
if leftkey()=0 and rightkey()=0 then factor1=0
rem Turn ship up or down
if upkey()=1 then factor2=2.5 : turn=0
if downkey()=1 then factor2=-2.5 : turn=0
if upkey()=0 and downkey()=0 then factor2=0
rem Move ship forward
if keystate(50)=1 then moveship=1
if keystate(49)=1 then moveship=0
if moveship=1 then move object 1,0.5
rem Ship angles
angleship#=angleship#+factor1
angleship2#=angleship2#+factor2
rem Angle the ship
yrotate object 1,angleship#
xrotate object 1,angleship2#
rem Click on the planet to select it
if object in screen(2)
if button(posx,object screen x(2)+50,object screen x(2)-50,posy,object screen y(2)+50,object screen y(2)-50)=1
colour("red") : square(object screen x(2)-50,object screen x(2)+50,object screen y(2)-50,object screen y(2)+50) : colour("white")
if mouseclick()=1
turn=1
planet=2
endif
endif
endif
if object in screen(4)
if button(posx,object screen x(4)+50,object screen x(4)-50,posy,object screen y(4)+50,object screen y(4)-50)=1
colour("red") : square(object screen x(4)-50,object screen x(4)+50,object screen y(4)-50,object screen y(4)+50) : colour("white")
if mouseclick()=1
turn=1
planet=4
endif
endif
endif
rem Turn to planet
if turn=1
rem Point the "Guider"
point object 999,object position x(planet),object position y(planet),object position z(planet)
rem Get "Guider" angle
theanglex=int(object angle x(999))
theangley=int(object angle y(999))
rem Get ship angle
shipanglex=int(object angle x(1))
shipangley=int(object angle y(1))
rem Turn ship
if theanglex<shipanglex then dec anx,1
if theanglex>shipanglex then inc anx,1
if theangley<shipangley then dec any,1
if theangley>shipangley then inc any,1
if anx>360 then anx=0
if anx<0 then anx=360
if any>360 then any=0
if any<0 then any=360
rem Rotate the ship
rotate object 1,anx,any,0
rem Move ship
if shipanglex=theanglex and shipangley=shipangley then moveship=1
endif
return
Is there something wrong?
EDIT:
I just found a part that was wrong:
rem Move ship
if shipanglex=theanglex and shipangley=shipangley then moveship=1
should be
rem Move ship
if shipanglex=theanglex and shipangley=theangley then moveship=1
. I fixed it, but it didnt work.