Execute Scripts stored in attributes

Hello fellow PlayCanvas Developers!

I’ve started developing with PlayCanvas a month ago and am relatively new to it. Now first I have to say it’s a great programm and I enjoy the variety of functions it provides! Now to my question.

I have an AR programm which works with multiple markers, now I would like to always use the same ARMarker,js script for detection etc. but would like to execute different Scripts when a marker becomes active. I thought of adding an attribute where I could add a script asset to it and then run that script. Of course these scripst have to provide a certain skeleton in order to be called in the same way but the execution itself would depend on the script alone.

Also open for suggestions on how to approach this differently. Of course I could just make like 6 copies of the ArMarker and then execute what needs to be done, but it would be really neat to do it dynamically and would also have usage in other scenarios.

EDIT:
Okay I am currently using the workaround of storing an event in an attribute which I’ll then handle for the specific cases.

You might want to just attach multiple scripts to the marker and enable/disable each script for that entity.