The current scripting API is powerful but hard to understand. A more user-friendly if...this...then...that API layer would really help here. Should implement #144 first.