— To Potota
in galaxie.orbitals.id[self.Etoile_nb], it’s the id of the instance I want to put as child of the object where this script is (this ID is given by the line just before.
I tried hash, but I have “string expected, got table” as answer.
I tried the value alone, and I have “url expected, got table”
I tried tostring, and I have “go.set_parent can only access instances within the same collection”
---- To Britzl
They are in the Init function.
-
Main collection has a few objects, like Camera.go, curseur.go and galaxie.go
All’s good.
-
Galaxie.go has three component : galaxie.script and two collectionfactory
All’s good
-
In galaxie.go, there is a call (in INIT) for one collectionfactory, which create an instance of another collection, StarSystem.collection
-
works like a charm
galaxie.etoiles.id[i] = collectionfactory.create("#StarSystem", nil, nil, props , nil)
-
StarSystem.collection has one Object, StarSystem.go with a child object (for the label) put as child directly in the Tab outline (it’s not in the StarSystem.go itself, just added as a child in the collection).
-
No problem here.
-
StarSystem.go has components like collisionobject, two sprites and a script
-
Works well
-
In the StarSystem.script, I have a call (in INIT) for the second collectionfactory, Orbital.collection, with one object, Orbital.go, with components like sprite, collision, script.
galaxie.orbitals.id[self.Etoile_nb] = collectionfactory.create("/Galaxy#Orbital", nil, nil, props , nil)
Well, it’s working apparently, since some print() in Orbital.script answers.
At the end, I have two instance “groups” : One of StarSystems, and one of Orbitals.
But when, in StarSystem.script, the line AFTER the call for collectionfactory on Orbital :
props[hash("/Orbital")] = {etoile = self.Etoile_nb, orbite = i}
galaxie.orbitals.id[self.Etoile_nb] = collectionfactory.create("/Galaxy#Orbital", nil, nil, props , nil)
I have :
go.set_parent can only access instances within the same collection.
pprint(galaxie.orbitals.id[self.Etoile_nb]) (the ID of the instance just created) give me :
{ --[[0x7f297821eb70]]
hash: [/Orbital] = hash: [/collection1/Orbital]
}```