I have a component with a property which decides how many of the same scripts it will run at the same time. So if i set it to 4 i will have Script1, Script2, Script3, Script4.
The scripts will all listen to the same string signal, which is on the format “SciptThatShouldlIsten, Information1, Information2…”. This means that i want to retrieve the script name from inside the script on some sort of function similar to getComponent().
comp.findBehavioursByType or comp.findBehaviour doesn’t really give me much, since the index of the specific script has to be found for itself.
I wouldn’t know of a way on how to retrieve the name of the current script.
What I do is, I always use one signal behaviour for each script.
So in your example it would be Script1, Script1Signal, Script2, Script2Signal, etc…
Hope that helps.
To find the name of the script that you are in right now you can use this:
if you want to add a signal to the script you are in right now you can use:
currentScript = comp.findBehaviour(__file__.split("::"))
signal = comp.findBehaviour("someSignal")
if not currentScript in signal.Connections:
connections = signal.Connections
I hope this helps, if not, let me know!
Yes, that’s true, it was a lazy copy-paste action from my script haha!
Normally instead of print I define it as a variable (and without .Name)