sorry for the subject, hope my code will be clearer than title.
I give you the code and I think you'll understand which problem i want to solve. Let's go
Code: Select all
define idSpeaker = "player.jpg"
default Var_Globale01 = "fr"
init python:
class clsTest01:
def __init__(self, name=""):
self.name = name
self.dialog = "[Dialogue003]"
class clsTest02:
def __init__(self, id=0, name=""):
self.id = id
self.name = name
self.dialog = "Dialogue_" + "[Var_Globale01]" + "_" + str(self.id).zfill(3)
class clsTest03:
def __init__(self, id=0, name=""):
self.id = id
self.name = name
self.dlg = "Dialogue_" + "[Var_Globale01]" + "_" + str(self.id).zfill(3)
def dialog(self):
return getattr(store, self.dlg)
#--------------------------------------------------------------------------------------------------
# START
#--------------------------------------------------------------------------------------------------
label start:
define speaker = Character("", image = "[PICTURES_CHARACTERS][idSpeaker]")
call loadDialogues
$ listOfclsTest01 = [( clsTest01( name="Name 01"))]
$ listOfclsTest02 = [( clsTest02( id=1, name="Name 02"))]
$ listOfclsTest03 = [( clsTest03( id=1, name="Name 03"))]
# TEST1
$ speaker ( listOfclsTest01[0].dialog ) # OK OF COURSE but so simple
# TEST2
$ test = listOfclsTest02[0].dialog
$ speaker ( listOfclsTest02[0].dialog ) # return "Dialogue_fr_001" (name of variable, not datas)
$ speaker ( "[test]" ) # return "Dialogue_[Var_Globale01]_001"
# TEST3
$ speaker ( listOfclsTest03[0].dialog )
# Exception: Character expects its what argument to be a string, got <bound method clsTest03.dialog of <store.clsTest03 object at 0x000000000a33ba50>>
return
label loadDialogues:
$ Dialogue_fr_001 = "Dialogue001 Dialogue001 Dialogue001 Dialogue001 ...\n{i}- Dialogue001 ? Dialogue001 .{/i}\nDialogue001 Dialogue001 ..."
$ Dialogue003 = "Dialogue003 Dialogue003 Dialogue003 Dialogue003 ...\n{i}- Dialogue003 ? Dialogue003 .{/i}\nDialogue003 Dialogue003 ..."
And of course what I want is assign Dialog attribute the value of my dynamic variable when i declare my class.
An idea, a dream, a cup of tea, a smile, i take all your suggests !!!!!