Interesting. So you basically want to write a script that can write other scripts?
I'm not sure the best way to go about this, I will have to look into it more.
You can define scripts in to ways currently, either as a #response to a #sentence using a #formula, or as a #state machine attached to the #state of #org.pandora.thought.language.Language (this is how Comprehension works, you can browse the structure by looking up #org.pandora.thought.language.Language in the knowledge browser).
I don't think SRAI :star that includes a formula will work, I will look into that. You can construct a #formula yourself in Self just create a new instance of #formula and add word or #equations to it by #word.
For performing commands on Android, I think your best bet would be to use actions. You can define an #action on a response that gets passed to the client XML in the action attribute. Currently the action is used to make the avatar perform actions, but you could have your own Java client that uses it for other things, like #flashlight.