It's not as chaotic as it may seem. They are all travelling relatively slowly there is actually a 'loose' set of 'rules'.
They are so predictable that if you spend a day on a scooter in any built up area of Indonesia you soon learn how to get around safely. In my experience (and as Zimtuff has already described) it's when you get out of town that the fun really starts....