Zum Inhalt wechseln


Foto

Error: Symbol <NAME> is not defined in current scope


  • Please log in to reply
22 replies to this topic

#1 timmiej93

timmiej93

    Captain

  • Members
  • 206 Beiträge:
  • Gender:Male
  • Location:Netherlands

Geschrieben 28 Juli 2014 - 03:32

Hey guys,

 

I'm getting above error quite frequently, and I'm just not getting it. 

To me it sounds like the game has trouble assigning a value to the Symbol, because it hasn't been defined.

 

In this case, the error is referring about this part of code:

			if(l1.GetNumActors() > 0)
				Vector FirstPoint = l1.GetActor(0)->GetPosition();

			if(l2.GetNumActors() > 0)
				Vector TurnTo = l2.GetActor(0)->GetPosition();

			Audio::PlaySample3D(SND_TOSTATION, Caller->GetPosition());
			v.PushActionMove(ACTION_NEWLIST, FirstPoint);
			v.PushActionTurnTo(ACTION_APPEND, TurnTo);

The error refers to the line with "v.PushActionMove" bit in it, and says "Symbol FirstPoint is not defined".

 

I really can't understand why, because I found the same bit of code in another script that comes with the mod, and it works fine there. 

 

Could anyone explain it to me?

 

Tim



#2 Chris07

Chris07

    Senior Captain

  • Member
  • 292 Beiträge:
  • Gender:Male
  • Location:Los Angeles, CA, USA
  • Interests:Medicine & Computer Science...what a combo!

Geschrieben 29 Juli 2014 - 08:21

Most likely reason is because of this part:

if(l1.GetNumActors() > 0)
	Vector FirstPoint = l1.GetActor(0)->GetPosition();

If the if() statement returns false, the FirstPoint variable never gets initialized.

 

Explanation:

say l1.GetNumActors() > 0 is false (because l1.GetNumActors() is 0)

 

then the

Vector FirstPoint = l1.GetActor(0)->GetPosition();

line gets skipped over completely and is never defined.

 

You either need to declare and set a default value for FirstPoint outside of the if() statement (somewhere before it), or you need to account for the situation that l1.GetNumActors() == 0 and bail out before it reaches the v.PushActionMove line.



#3 timmiej93

timmiej93

    Captain

  • Members
  • 206 Beiträge:
  • Gender:Male
  • Location:Netherlands

Geschrieben 29 Juli 2014 - 02:22

That indeed is an option, but it shouldn't be possible for l1 to have a number of actors that is lower then 1. It's the same principle as the ToFireStation script.

 

Here, have a look: Click

(bit of code starts at 273).

 


#4 Chris07

Chris07

    Senior Captain

  • Member
  • 292 Beiträge:
  • Gender:Male
  • Location:Los Angeles, CA, USA
  • Interests:Medicine & Computer Science...what a combo!

Geschrieben 29 Juli 2014 - 10:55

Lets debug this a little more. Let's first confirm my suspicion of the cause of the error:

 

Replace:

if(l1.GetNumActors() > 0)
	Vector FirstPoint = l1.GetActor(0)->GetPosition();
if(l2.GetNumActors() > 0)
	Vector TurnTo = l2.GetActor(0)->GetPosition();

Audio::PlaySample3D(SND_TOSTATION, Caller->GetPosition());
v.PushActionMove(ACTION_NEWLIST, FirstPoint);
v.PushActionTurnTo(ACTION_APPEND, TurnTo);

With:

//Debug L1
f(l1.GetNumActors() > 0)
	Game::PlayHint("L1 is good!");
else if(l1.GetNumActors() == 0)
        Game::PlayHint("L1 is equal to 0");
else
        Game::PlayHint("Impossible...this is worse than dividing by 0 (L1)");

//Debug L2
if(l2.GetNumActors() > 0)
	Game::PlayHint("L2 is good!");
else if(l2.GetNumActors() == 0)
        Game::PlayHint("L2 is equal to 0");
else
        Game::PlayHint("Impossible...this is worse than dividing by 0 (L2)");

/*
Audio::PlaySample3D(SND_TOSTATION, Caller->GetPosition());
v.PushActionMove(ACTION_NEWLIST, FirstPoint);
v.PushActionTurnTo(ACTION_APPEND, TurnTo);
*/

Tell me what the game ticker says...or any additional error.



#5 timmiej93

timmiej93

    Captain

  • Members
  • 206 Beiträge:
  • Gender:Male
  • Location:Netherlands

Geschrieben 30 Juli 2014 - 12:55

Well, for some reason, as you expected, L1 equals 0.

 

Here's the log bit:

?(_LAToPoliceStationa83eb): Error: Function PlayHint("L1 is equal to 0") is not defined in current scope 
?(_LAToPoliceStationa83eb):  FILE:mod:/scripts/game/command/LAToPoliceStation.scripta83eb LINE:277
?(_LAToPoliceStationa83eb): Possible candidates are...
?(_LAToPoliceStationa83eb): filename       line:size busy function type and name  
?(_LAToPoliceStationa83eb): 
?(_LAToPoliceStationa83eb): !!!Dictionary position rewound... 
?(_LAToPoliceStationa83eb): !!!Error recovered!!!



#6 Chris07

Chris07

    Senior Captain

  • Member
  • 292 Beiträge:
  • Gender:Male
  • Location:Los Angeles, CA, USA
  • Interests:Medicine & Computer Science...what a combo!

Geschrieben 30 Juli 2014 - 12:59

I made a mistake...It's supposed to be Mission::PlayHint()

//Debug L1
f(l1.GetNumActors() > 0)
	Mission::PlayHint("L1 is good!");
else if(l1.GetNumActors() == 0)
        Mission::PlayHint("L1 is equal to 0");
else
        Mission::PlayHint("Impossible...this is worse than dividing by 0 (L1)");

//Debug L2
if(l2.GetNumActors() > 0)
	Mission::PlayHint("L2 is good!");
else if(l2.GetNumActors() == 0)
        Mission::PlayHint("L2 is equal to 0");
else
        Mission::PlayHint("Impossible...this is worse than dividing by 0 (L2)");

/*
Audio::PlaySample3D(SND_TOSTATION, Caller->GetPosition());
v.PushActionMove(ACTION_NEWLIST, FirstPoint);
v.PushActionTurnTo(ACTION_APPEND, TurnTo);
*/

Anyway...now that my theory is confirmed lets try the obvious. Ensure that your VOs are named properly in the editor and that their names are correct in your script. The error is most likely that your VO is named wrong. that's why it's == 0



#7 timmiej93

timmiej93

    Captain

  • Members
  • 206 Beiträge:
  • Gender:Male
  • Location:Netherlands

Geschrieben 30 Juli 2014 - 01:01

Well, the outcome would be the same, right?

It still gets sent to that point in the script, so it's quite clear L1 is equal to 0, if I'm not mistaking.

I'll get back to you with the results of above script.

 

 

Edit:

L1 is equal to 0, L2 is good.



#8 Chris07

Chris07

    Senior Captain

  • Member
  • 292 Beiträge:
  • Gender:Male
  • Location:Los Angeles, CA, USA
  • Interests:Medicine & Computer Science...what a combo!

Geschrieben 30 Juli 2014 - 01:03

Sorry, I edited my post and added stuff to it. check it out.



#9 timmiej93

timmiej93

    Captain

  • Members
  • 206 Beiträge:
  • Gender:Male
  • Location:Netherlands

Geschrieben 30 Juli 2014 - 01:09

Anyway...now that my theory is confirmed lets try the obvious. Ensure that your VOs are named properly in the editor and that their names are correct in your script. The error is most likely that your VO is named wrong. that's why it's == 0
 

Shouldn't that limit the error to 1 parking space? Unles it's a structural error though.

I'll have a look.



#10 Chris07

Chris07

    Senior Captain

  • Member
  • 292 Beiträge:
  • Gender:Male
  • Location:Los Angeles, CA, USA
  • Interests:Medicine & Computer Science...what a combo!

Geschrieben 30 Juli 2014 - 01:11

True. I'll look at he code again.



#11 timmiej93

timmiej93

    Captain

  • Members
  • 206 Beiträge:
  • Gender:Male
  • Location:Netherlands

Geschrieben 30 Juli 2014 - 01:15

Unfortunatly, this suggestion didn't bring up anything either. All the names are correct.

 

 

It shouldn't matter that I've made the VO's for those parking spaces myself right? It's not like they have to be assigned some value right?



#12 Chris07

Chris07

    Senior Captain

  • Member
  • 292 Beiträge:
  • Gender:Male
  • Location:Los Angeles, CA, USA
  • Interests:Medicine & Computer Science...what a combo!

Geschrieben 30 Juli 2014 - 01:16

To make tracing things easier...which vehicles are you using to test this? OBJ_SUV? OBJ_CRUISER04?

 

Also, as long as the VOs you made are named in the editor it should work.



#13 timmiej93

timmiej93

    Captain

  • Members
  • 206 Beiträge:
  • Gender:Male
  • Location:Netherlands

Geschrieben 30 Juli 2014 - 01:17

I've got another script spawning the vehicles that are assigned to the parking spaces in the correct position. I'm testing it using the VAN, but I believe all other cars give the same result. Let me test

 

------

 

So when using the VAN or SUV, I get the error saying L1 is 0, L2 is good.


While using the CRUISER04 though, I get an error saying: Error: Symbol l97 is not defined in current scope

 

PS. I slightly modified the script, since all L parameters (gameobjectlists) were l99.

New link: Click



#14 Chris07

Chris07

    Senior Captain

  • Member
  • 292 Beiträge:
  • Gender:Male
  • Location:Los Angeles, CA, USA
  • Interests:Medicine & Computer Science...what a combo!

Geschrieben 30 Juli 2014 - 01:28

Lets see if it's even making it into VAN specific portion:

 

Find:

else if(StrCompare(v.GetPrototypeFileName(), OBJ_VAN) == 0)
			{
				GameObjectList l99;
				Game::CollectObstaclesOnVirtualObject(VO_BACK03, l99, ACTOR_VEHICLE);
				if(l99.GetNumObjects() > 0)
				{
					v.PushActionExecuteCommand(ACTION_NEWLIST, CMD_PATROL, Caller, 0, false);
					return;
				} else
				{
					ActorList l1 = Game::GetActors(VO_TT_BACK03);
					ActorList l2 = Game::GetActors(VO_BACK03);
				}
			}

Replace with:

else if(StrCompare(v.GetPrototypeFileName(), OBJ_VAN) == 0)
			{
				GameObjectList l99;
				Game::CollectObstaclesOnVirtualObject(VO_BACK03, l99, ACTOR_VEHICLE);
				if(l99.GetNumObjects() > 0)
				{
					v.PushActionExecuteCommand(ACTION_NEWLIST, CMD_PATROL, Caller, 0, false);
					return;
				} else
				{
					ActorList l1 = Game::GetActors(VO_TT_BACK03);
					ActorList l2 = Game::GetActors(VO_BACK03);
                                         Mission::PlayHint("I MADE IT");
				}
			}

using the van, send it to station. If the Hint plays...its making it and i've hit another dead end. If it doesn't play, it's because the program never reaches that portion of the code



#15 timmiej93

timmiej93

    Captain

  • Members
  • 206 Beiträge:
  • Gender:Male
  • Location:Netherlands

Geschrieben 30 Juli 2014 - 01:34

I'm sorry mate, you've hit a dead end. The I MADE IT hint plays immediately.

I do have to say, I appreciate every bit of effort you put in to this, I wouldn't get any further without you.



#16 Chris07

Chris07

    Senior Captain

  • Member
  • 292 Beiträge:
  • Gender:Male
  • Location:Los Angeles, CA, USA
  • Interests:Medicine & Computer Science...what a combo!

Geschrieben 30 Juli 2014 - 01:41

Oh no....we're going to figure this out. This just got personal. :verweis:



#17 timmiej93

timmiej93

    Captain

  • Members
  • 206 Beiträge:
  • Gender:Male
  • Location:Netherlands

Geschrieben 30 Juli 2014 - 01:46

I truly hope we do, this script is starting to bug me. If you have any ideas / suggestions, let me know, I'll be happy to test it out.

#18 Chris07

Chris07

    Senior Captain

  • Member
  • 292 Beiträge:
  • Gender:Male
  • Location:Los Angeles, CA, USA
  • Interests:Medicine & Computer Science...what a combo!

Geschrieben 30 Juli 2014 - 01:54

I have two more things up my sleeve.
 
Looking at the script before I started adding a bunch of stuff, I just noticed line 249 is missing a semi-colon. Try adding it and see if that fixes things.

GameObjectlist l99;

 

 

Otherwise replace starting at "} else if(StrCompare(v.GetPrototypeFileName(), OBJ_VAN) == 0)" until the end of the childID == 1 statement.

            } else if(StrCompare(v.GetPrototypeFileName(), OBJ_VAN) == 0)
            {
                GameObjectList l99;
                Game::CollectObstaclesOnVirtualObject(VO_BACK03, l99, ACTOR_VEHICLE);
                if(l99.GetNumObjects() > 0)
                {
                    v.PushActionExecuteCommand(ACTION_NEWLIST, CMD_PATROL, Caller, 0, false);
                    return;
                } else
                {
                    ActorList aList1 = Game::GetActors(VO_TT_BACK03);
                    ActorList aList2 = Game::GetActors(VO_BACK03);
                }
            }
            else if(StrCompare(v.GetPrototypeFileName(), OBJ_SUV) == 0)
            {    
                GameObjectList l99;
                Game::CollectObstaclesOnVirtualObject(VO_BACK04, l99, ACTOR_VEHICLE);
                if(l99.GetNumObjects() > 0)
                {
                    v.PushActionExecuteCommand(ACTION_NEWLIST, CMD_PATROL, Caller, 0, false);
                    return;
                } else
                {
                    ActorList aList1 = Game::GetActors(VO_TT_BACK04);
                    ActorList aList2 = Game::GetActors(VO_BACK04);
                }
            }
            else if(StrCompare(v.GetPrototypeFileName(), OBJ_CRUISER04) == 0)
            {
                GameObjectlist l99
                Game::CollectObstaclesOnVirtualObject(VO_BACK01, l99, ACTOR_VEHICLE);
                if(l99.GetNumObjects() > 0)
                {
                    GameObjectlist l99;
                    Game::CollectObstaclesOnVirtualObject(VO_BACK02, l99, ACTOR_VEHICLE);
                    if(l99.GetNumObjects() > 0)
                    {
                        v.PushActionExecuteCommand(ACTION_NEWLIST, CMD_PATROL, Caller, 0, false);
                        return;
                    }
                    else
                    {
                        ActorList aList1 = Game::GetActors(VO_TT_BACK02);
                        ActorList aList2 = Game::GetActors(VO_BACK02);
                    }
                }
                else
                {
                    ActorList aList1 = Game::GetActors(VO_TT_BACK01);
                    ActorList aList2 = Game::GetActors(VO_BACK01);
                }    
            } else
            {
                Mission::PlayHint(HINT_NOTVALID);
                return;
            }
            
            if(aList1.GetNumActors() > 0)
                Vector TurnTo = aList1.GetActor(0)->GetPosition();
            
            if(aList2.GetNumActors() > 0)
                Vector Park = aList2.GetActor(0)->GetPosition();
            
            Audio::PlaySample3D(SND_TOSTATION, Caller->GetPosition());
            v.PushActionMove(ACTION_NEWLIST, Park);
            v.PushActionTurnTo(ACTION_APPEND, TurnTo);
            v.PushActionWait(ACTION_APPEND, 1.0f);
        }

The only other thing i can think of is that the l1 variable is getting overwritten at some point (since its being used elsewhere). This will prevent that.



#19 timmiej93

timmiej93

    Captain

  • Members
  • 206 Beiträge:
  • Gender:Male
  • Location:Netherlands

Geschrieben 30 Juli 2014 - 02:01

Hmm, weird.

I found the one you noticed, and i noticed one missing at 245 too. Added those.

For the VAN and SUV, still the same. L1 == 0, L2 is good.

 

Although, for the CRUISER04 I get a different error now. It states:

 

?(_LAToPoliceStationa8343): Error: Symbol GameObjectlistl97 is not defined in current scope 
?(_LAToPoliceStationa8343):  FILE:mod:/scripts/game/command/LAToPoliceStation.scripta8343 LINE:245
 
Now is this getting weirder with every edit or what?


#20 Chris07

Chris07

    Senior Captain

  • Member
  • 292 Beiträge:
  • Gender:Male
  • Location:Los Angeles, CA, USA
  • Interests:Medicine & Computer Science...what a combo!

Geschrieben 30 Juli 2014 - 02:07

You're reinitializing l99.

 

Delete line 249 and reuse l99 for the second if() statement