Aller au contenu

Photo

Error: CreateObject after a conditional


1 réponse à ce sujet

#1
georage

georage
  • Members
  • 247 messages
Why does this give me an error?

E: 14:30:52 - trigger_zyyna.nss - trigger_zyyna.nss(98): Incorrect variable state left on stack (while compiling var_constants_h.nss)

if(!IsObjectValid(GetObjectByTag("gelda")))                    
object oGelda=CreateObject(OBJECT_TYPE_CREATURE,R"gelda.utc",GetLocation(GetObjectByTag("wp_ftalk_gelda"))); 


But this does not ...

object oGelda;                
if(!IsObjectValid(GetObjectByTag("gelda")))                    oGelda=CreateObject(OBJECT_TYPE_CREATURE,R"gelda.utc",GetLocation(GetObjectByTag("wp_ftalk_gelda")));


Another annoying change in DAO!

Modifié par georage, 09 décembre 2009 - 07:34 .


#2
DavidSims

DavidSims
  • BioWare Employees
  • 196 messages

georage wrote...

Why does this give me an error?

E: 14:30:52 - trigger_zyyna.nss - trigger_zyyna.nss(98): Incorrect variable state left on stack (while compiling var_constants_h.nss)

if(!IsObjectValid(GetObjectByTag("gelda")))                    
object oGelda=CreateObject(OBJECT_TYPE_CREATURE,R"gelda.utc",GetLocation(GetObjectByTag("wp_ftalk_gelda"))); 


But this does not ...

object oGelda;                
if(!IsObjectValid(GetObjectByTag("gelda")))                    oGelda=CreateObject(OBJECT_TYPE_CREATURE,R"gelda.utc",GetLocation(GetObjectByTag("wp_ftalk_gelda")));


Another annoying change in DAO!


It's a bit odd I guess, but why would you possibly want to declare a variable within an if statement that doesn't have curly brackets? You'd never be able to use the variable anyway.

This works:

if(!IsObjectValid(GetObjectByTag("gelda")))                    
CreateObject(OBJECT_TYPE_CREATURE,R"gelda.utc",GetLocation(GetObjectByTag("wp_ftalk_gelda"))); 


as does this:

if(!IsObjectValid(GetObjectByTag("gelda")))   
{                 
object oGelda=CreateObject(OBJECT_TYPE_CREATURE,R"gelda.utc",GetLocation(GetObjectByTag("wp_ftalk_gelda"))); 
}