I did not really get what you wanted by your first post, so I tried to write something that might be what you want. but I will go threw it to help you understand it.
so I saw you were using export to be able to load different scenes in the inspector.
@export var Scene1 : PackedScene
the Scene1 var could be filled with any scene
func Setup1s(Num:int=300,args:Array[Array]=[],kargs:Dictionary={})->bool:
is a function that is made to setup a number of Scene1.
so first I thought you might want a place to put all these Scene1 that will be set up.
var N : Node = Node.new()
N.name="S1s"
add_child(N)
var N : Node = Node.new() makes a new node to place all of the new Scene1 to be made N.name=“S1s” renames that node S1 for Scene1 then adds a s to imply their might be more then one Scene1 being organized. add_child(N) adds the organizer to what ever the script is in.
for i in Num:
is a loop that will run threw the intended section Num number of times. if we look up in the func part we see Num should be a int that’s a whole number because it’s hard to go threw a loop a 0.5 amount of times, num could be anything you need but we see the default amount for it to run threw this loop is 300 times a really large amount of times but I don’t know what you are doing. so I just wanted to expand your mind to possibilities and automation.
inside the for loop
var S1 : = Scene1.instantiate()
this makes object of the Scene1
so let’s say you have something that needs to be done with a new Scene1 that can’t really be done in the _ready() of Scene1
so like maybe this func Setup1s is inside of the NPCbaseclass but you have BobNPCclass and a AliceNPCclass that “copy and paste” the code of the func Setup1s from the NPCbaseclass by extends NPCbaseclass
but your Scene1 needs to know if it was made inside Bob or Alice.
func Setup1s( args:Array[Array]=[], kargs:Dictionary={}):
the args and kargs is something that can help you do this.
so say you make all of your Scene1 have a
var NPCName : String= "not known yet"
func setup(args:Array[Array]=[], kargs:Dictionary={}):
NPCName=kargs["NPC_name"]
NPCName=args[0][0]
when running func Setup1s( in bob you can do.
Setup1s ( 10,
[["BobIsMyNameByArgs array"]],
{"NPC_name":"BobIsMyNameByKargs Dictionary"},
)
but it should only go down this rabbit hole if the args or the kargs is not empty.
if args!=[] or kargs!={}:
so != is not equal to
so args default setting is a
and kargs default setting is {}
so if it’s true that args is not the default or kargs is not the default then
S1.setup(args,kargs)
this is S1 the new Scene1 it should run it’s func setup.
and that func set up should be given the args and the kargs that contain the “bob” name.
ok so done setting up the new S1 but it’s floating in space
N.add_child(S1)
adds S1 to the N that is the place to organize the S1 Setup1s is making.
perhaps you need to know when all of the 300 Scene1 are set up and done so you can start working on the Scene2
return true
can do this.
if Setup1s(340,args1,kargs1):
return Setup2s(20,args2,kargs2)
hope this adds to what you can do. bit of a disclaimer I just made the code shortly after you posted and didn’t really run it on anything so their might be a dumb mistake or gotcha that I did not catch, same with the explanation more of to teach the concepts. so not really copy paste able is what I am saying.