The force of gravity between objects can be done with:
m1 and m2 are the masses of the two objects and r is the distance between them.
G is a constant. It comes from
But since we are not dealing with real world scales we can just fudge it.
You can try the following. Also to get the moon to orbit you just have to have the perpendicular velocity high enough.
Global number a=0
Global number r=0
Global number f=0
For each planet
— set a to angle(moon.x, moon.y, planet.x, planet.y)
— set r to distance(moon.x, moon.y, planet.x, planet.y)
— set f to 100 * moon.physics.mass * planet.physics.mass/r^2
— moon: physics: apply force (f*cos(a), f*sin(a))