Well I'm not sure exactly what you were trying to accomplish, but judging from you other posts I'm guessing that you will find this useful.
sync on
autocam off
` Constants
#constant SUN 1
#constant EARTH 2
#constant PICKr 3
` Variables
Dist# as float = 300.0
Ang# as float = 0.0
` Make sun
make object sphere SUN, 50
position object SUN, 0.0, 0.0, 0.0
color object SUN, 0xFFFF00
` Make earth
make object sphere EARTH, 2
position object EARTH, 0.0, 0.0, 150.0
color object EARTH, 0x30FF30
` Pick Helper object
make object plain PICKr, 1000.0, 1000.0
xrotate object PICKr, 90.0
position object PICKr, 0.0, 0.0, 0.0
color object PICKr, 0x000000
set object light PICKr, 1
` position camera
position camera 0.0, 450.0, 0.0
point camera 0.0, 0.0, 0.0
ac# = 0.00001 ` angle change.
Do
if pick object( mousex(), mousey(), PICKr, PICKr )=PICKr and mouseclick()=1
pickx# = camera position x() + get pick vector x()
pickz# = camera position z() + get pick vector z()
Ang# = atanfull( pickx#, pickz# )
position object EARTH, 150.0 * sin(Ang#), 0.0, 150.0 * cos(Ang#)
else
Ang# = Ang# + ac#
RotateObjectAroundObject( EARTH, SUN, ac# )
endif
ac# = ac# + mousemovez()/10000.0
Time# = SecondsPerDegrees( Ang# )
text object screen x(EARTH), object screen y(EARTH), TimeFormat( Time# )
sync
loop
function RotateObjectAroundObject( o1 as integer, o2 as integer, ang# as float )
x# = object position x(o2)
y# = object position y(o2)
z# = object position z(o2)
dx# = object position x(o1) - x#
dy# = object position y(o1) - y#
dz# = object position z(o1) - z#
nx# = dx# * cos( -ang# ) - dz# * sin( -ang# )
nz# = dx# * sin( -ang# ) + dz# * cos( -ang# )
nx# = nx# + x#
nz# = nz# + z#
position object o1, nx#, object position y(o1), nz#
endfunction
function SecondsPerDegrees( Degrees# as float )
Time# as float
Time# = Degrees# * 87660.0
endfunction Time#
function MinutesPerDegrees( Degrees# as float )
Time# as float
Time# = (Degrees# * 87660.0) / 60.0
endfunction Time#
function TimeFormat( Time# as float )
SS# = SawTooth( Time#, 60.0 )
MM# = SawTooth( Time#/60.0, 60.0 )
HH# = SawTooth( Time#/3600.0, 24.0 )
DD# = SawTooth( Time#/86400.0, 365.25 )
TimeString$ = (str$(int(DD#))) + ":" + (str$(int(HH#))) + ":" + (str$(int(MM#))) + ":" + (str$(int(SS#)))
endfunction TimeString$
function SawTooth( x# as float, Amplitude# as float )
t# = Amplitude# * ( x#/Amplitude# - floor( x#/Amplitude# ) )
endfunction t#