Rotate game object in collection to absolute north (SOLVED)

Hi. With the help of collective hive mind that is the Defold engine devs I came to the following solution that should work:

function update(self, dt)
	msg.post(".", "update_rotation")
end

function on_message(self, message_id, message, sender)
	if message_id == hash("update_rotation") then
		local quat_to_north = vmath.quat_rotation_z(math.rad(0)) -- the rotation around z to rotate to due north
		local parent_quat = go.get_world_rotation("parent") -- the parents world rotation
		go.set_rotation(vmath.conj(parent_quat) * quat_to_north) -- inverse parent rotation * rotation to north = local rotation
	end
end

The msg.post() in update might look strange but since we need the world rotation of the parent we must wait until all objects have had their positions updated before doing any calculations.