I just had a look at your code. The main problem is that ALL child objects of a parent need to be updated when a parent is orbited.
I didn't have time to setup a GDK project, so I just prototyped something in DBpro real quick. It doesn't use types or recursive functions, but it works and should be enough to give you an idea of what you need to do. I hope this helps!
sync on
sync rate 60
`Sun
make object sphere 1,5
`Planet
make object sphere 2,1
position object 2,10,0,0
`moon
make object sphere 3,0.25
position object 3,12,0,0
position camera 0,50,-25
point camera 0,0,0
do
UpdateSun()
UpdatePlanet()
UpdateMoon()
sync
loop
function UpdateSun()
`Handle Sun
`NOTHING TO REALLY DO HERE!
endfunction
function UpdatePlanet()
`Setup Reference Axis
RefPositionX# = Object Position X(1)
RefPositionY# = Object Position Y(1)
RefPositionZ# = Object Position Z(1)
RefAxisX# = Object Position X(1)
RefAxisY# = Object Position Y(1)+1.0
RefAxisZ# = Object Position Z(1)
`Update Planet to orbit around sun
EZro_SetEuler Object Angle X(2),Object Angle Y(2),Object Angle Z(2)
EZro_SetPos Object Position X(2),Object Position Y(2),Object Position Z(2)
RotSpeed as float = 0.5
EZro_Orbit 1, RefPositionX#,RefPositionY#,RefPositionZ#, RefAxisX#,RefAxisY#,RefAxisZ#, RotSpeed
EZro_FindEuler
Position Object 2,EZro_GetPosX(),EZro_GetPosY(),EZro_GetPosZ()
Rotate Object 2, EZro_GetEulerX(),EZro_GetEulerY(),EZro_GetEulerZ()
`Update Moon to also orbit around sun since it is a child of the planet
EZro_SetEuler Object Angle X(3),Object Angle Y(3),Object Angle Z(3)
EZro_SetPos Object Position X(3),Object Position Y(3),Object Position Z(3)
RotSpeed as float = 0.5
EZro_Orbit 1, RefPositionX#,RefPositionY#,RefPositionZ#, RefAxisX#,RefAxisY#,RefAxisZ#, RotSpeed
EZro_FindEuler
Position Object 3,EZro_GetPosX(),EZro_GetPosY(),EZro_GetPosZ()
Rotate Object 3, EZro_GetEulerX(),EZro_GetEulerY(),EZro_GetEulerZ()
endfunction
function UpdateMoon()
`Setup Reference Axis
RefPositionX# = Object Position X(2)
RefPositionY# = Object Position Y(2)
RefPositionZ# = Object Position Z(2)
RefAxisX# = Object Position X(2)
RefAxisY# = Object Position Y(2)+1.0
RefAxisZ# = Object Position Z(2)
`Update Moon to orbit around the planet
EZro_SetEuler Object Angle X(3),Object Angle Y(3),Object Angle Z(3)
EZro_SetPos Object Position X(3),Object Position Y(3),Object Position Z(3)
RotSpeed as float = 2.0
EZro_Orbit 1, RefPositionX#,RefPositionY#,RefPositionZ#, RefAxisX#,RefAxisY#,RefAxisZ#, RotSpeed
EZro_FindEuler
Position Object 3,EZro_GetPosX(),EZro_GetPosY(),EZro_GetPosZ()
Rotate Object 3, EZro_GetEulerX(),EZro_GetEulerY(),EZro_GetEulerZ()
endfunction
a.k.a WOLF!