You can embed a scripting language such as lua. See here and here . I don't know too much about this, but it is used in many scripting applications, just like your needs.
I am not 100% sure how to integrate it, or if the scripts can be loaded, but this will probably work.
Note:
I'm not sure that Apple will let you download and run arbitrary scripts, but it's worth it.
source share