Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: mchammer on Mon 10/04/2006 20:56:12

Title: "Character not in the room" error (SOLVED)
Post by: mchammer on Mon 10/04/2006 20:56:12
Not sure if this is a beginners problem but:
1. I change a NPC to different room.
2. I change the player to the same room.
3. I set the NPC to walk different location.

character[RASTA2].ChangeRoom(4, 199, 24);
character[HARRY].ChangeRoom(4, 199, 28);  //HARRY is the player char.
character[RASTA2].Walk(48, 72,eNoBlock,eWalkableAreas);

When I play and the game runs this script, it crashes and a message something like
"Error: Cant move char. Its not in current room." pops up.
Title: Re: "Character not in the room" error
Post by: DoorKnobHandle on Mon 10/04/2006 20:58:36
That's because the script stays inside the first room until ALL the functions are executed. Just because you move the player character, that doesn't mean the the script moves with him/her.

So, to fix your problem, you'll need to cut the last of your three lines away from the first rooms script and place it into the "player enters room"-space for the second room. This would be one way to do it.

I hope this helps - although you may need to use variables if the user can acces the second room earlier as well.
Title: Re: "Character not in the room" error
Post by: mchammer on Tue 11/04/2006 12:18:06
Thanks for help but the scrpit is in global script at  function repeatedly_execute()
cus i want that character and NPC move everyday in certain time to room 4 and then NPC moves at certain positon in the new room. So its like:

if (time == something) {
character[RASTA2].ChangeRoom(4, 199, 24);
character[HARRY].ChangeRoom(4, 199, 28);  //HARRY is the player char.
character[RASTA2].Walk(48, 72,eNoBlock,eWalkableAreas);
}

Title: Re: "Character not in the room" error
Post by: SSH on Tue 11/04/2006 12:21:07
I recommend using the Character Control System module: http://www.adventuregamestudio.co.uk/yabb/index.php?topic=24489.0
Title: Re: "Character not in the room" error
Post by: mchammer on Tue 11/04/2006 13:11:26
Thanks a lot, this seems to be perfect module to the game (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=25966.0) I'm making.