I'm dealing with a new circumstance I definitely have to ask about. TLDR this is for my cubic voxel mesh system, where I'm essentially thinking of separating the script that spawns chunks from the script that actually runs on each chunk to generate its mesh or do other chunk specific actions.
So: Let's say I have the usual Node3D in my root scene, we'll call it A and it contains a script called X. The project contains another scene with another Node3D called B, it contains a script called Y. Script X of node A is responsible for adding or removing any number of instances of node B with its script Y: Obviously it maintains a dictionary or array of spawned nodes and can address each instance of scene B directly as "y_nodes[0]" for example.
The basic question here: How can script X tell a given instance of node B to run a specific function in its script with the given parameters? Is there a way in which script Y can define a public function that script X can call on it from its node? Script X would probably have a line of the form "y_nodes[0].call_script_function("my_func", "some_string", 0, false)".
My only other question then is threading: I want the script in every instance of node B to run in its own thread. There may be a lot of nodes spawned so I'm not sure how healthy this is, but IIRC there's no danger to using dozens of threads and you simply don't get a performance benefit once they surpass the number of cores in your CPU. Obviously the thread must be created when the node is spawned then removed once the node is deleted. Functions called by node A's X script must of course be processed by node B's Y script. Each chunk should only work with its own data so a mutex may not be needed at least initially, but a semaphore yes as the script may sleep until node X transmits a function call to its node.