Salut, j'ai réussi avec une liste, merci
!
(c'est un post que j'avais mis sur le forum de Construct Classic, c'est la solution)
Hey !
I found a way myself, I don't know if it's the best one but it's working !
First, to import the class, do :
Start of layout, python script :
CODE: SELECT ALL
import sys, os, random
class GNPC():
def __init__(self):
# npcList
self.npcList = []
self.npcListMov = []
def addNpc(self, npcObject, npcObjectRTS):
self.npcList.append(npcObject)
self.npcListMov.append(npcObjectRTS)
npcManager = GNPC()
Then, when you spawn NPCs (for each npcs etc..) do :
CODE: SELECT ALL
npcManager.addNpc(SOL.entity, SOL.entityRTS)
Finally, to call event from your object : (for example : every X seconds -> for each object -> do this code)
CODE: SELECT ALL
npcManager.npcList[0].SetValue("test", 500) # This is to call events from the object
npcManager.npcListMov[0].MoveTo(random.randint(1,7
000),
random.randint(1,4000)) # This is to call events from the RTS Behavior (of the object)
EDIT Btw, I don't know how to add python variables to objects in a list :/