@@ -246,11 +246,11 @@ def visitOWID(self, node, scope):
246246 constgen = self .global_varconst if type (child ) == GlobalVar else self .player_varconst
247247 try :
248248 varconst = next (constgen )
249- self .varconsts [child .name ] = Raw (code = varconst )
250249 if type (child ) == GlobalVar :
251250 code = 'Set Global Variable({}, {});\n ' .format (varconst , self .visit (child , scope )) + code
252251 else :
253- code = 'Set Player Variable({}, {}, {});\n ' .format (self .visit (child .player , varconst , self .visit (child , scope ))) + code
252+ code = 'Set Player Variable({}, {}, {});\n ' .format (self .visit (child .player , scope ), varconst , self .visit (child , scope )) + code
253+ self .varconsts [child .name ] = Raw (code = varconst )
254254 except StopIteration :
255255 raise Errors .InvalidParameter ('Exceeded maximum number of chase variables (25) for this type.' , pos = child ._pos )
256256 node .children [index ] = self .varconsts [child .name ]
@@ -447,6 +447,9 @@ def visitUnaryOp(self, node, scope):
447447
448448 def visitGlobalVar (self , node , scope ):
449449 name = node .name
450+ if name in self .varconsts :
451+ varconst = self .visit (self .varconsts .get (name ), scope )
452+ return 'Global Variable({})' .format (varconst )
450453 var = scope .get (name )
451454 if not var :
452455 raise Errors .NameError ('\' {}\' is undefined' .format (node .name [5 :]), pos = node ._pos )
@@ -462,14 +465,18 @@ def visitGlobalVar(self, node, scope):
462465
463466 def visitPlayerVar (self , node , scope ):
464467 name = node .name
468+ player = self .visit (node .player , scope )
469+ if name in self .varconsts :
470+ varconst = self .visit (self .varconsts .get (name ), scope )
471+ return 'Player Variable({}, {})' .format (player , varconst )
465472 var = scope .get (name )
466473 if not var :
467474 raise Errors .NameError ('pvar \' {}\' is undefined' .format (node .name [5 :]), pos = node ._pos )
468475 elif type (var ) != Variable :
469476 return self .visit (var , scope )
470477 elif type (var .value ) == String :
471478 return var .value .value
472- code = 'Value In Array(Player Variable({}, A), {})' .format (self . visit ( node . player , scope ) , var .index )
479+ code = 'Value In Array(Player Variable({}, A), {})' .format (player , var .index )
473480 return code
474481
475482 def visitString (self , node , scope ):
0 commit comments