Algorithmic composition/ shared state on multiple scripts.

I am a Halion 6 newbie who is quite interested in exploring the possibilities of using the scripting engine to generate music.
I would like to have several instruments (slots) and some sort of logic that is controlling them.
This will require a shared context/state (think musical score) with generators for different instruments generating events.
I am trying to work out how to do this within limitations of the scripting language.
After studying the documentation the only way I have worked out to share state across multiple modules is to use the same module for the different slots which then means the will share the same global namespace. The different slots would need to use some sort of context info (e.g. layer name) in order to have different behaviour. Whilst I think this could be made to work it feels a bit clumsy. Have I missed something?

I initially looked at using a single program which sent events to different slots but this does not seem possible with the API?

I am interested to see if anyone else has attempted anything similar.

Paul