Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Last Boy Scout on Mon 16/08/2010 08:12:45

Title: I need help moving a character from one room to the next.
Post by: Last Boy Scout on Mon 16/08/2010 08:12:45
Hi,

I'm just starting out, have 2 rooms built and I want to be able to move the character into the next room. I made the front door a hotspot, but the character can't walk into the next room when he touches it.

Under the edges event list I selected "room_Leave" and still nothing happens when you approach the doors.

I'm really frustrated with this simple problem and can't find any answers on the forum or in the manual for this.

I'm sure someone knows the solution to this. Please help!
Title: Re: I need help moving a character from one room to the next.
Post by: Matti on Mon 16/08/2010 10:41:07
Quote from: Last Boy Scout on Mon 16/08/2010 08:12:45
Under the edges event list I selected "room_Leave" and still nothing happens when you approach the doors.!

There is no "edges event list", that's the room event list and you chose room_leave which is called as soon as the character left the room.

Quote
I'm just starting out, have 2 rooms built and I want to be able to move the character into the next room. I made the front door a hotspot, but the character can't walk into the next room when he touches it.

If you put a character.ChangeRoom() command in the hotspot's interaction event (like 'interact hotspot' or 'any click on hotspot') then it should work just fine.
Title: Re: I need help moving a character from one room to the next.
Post by: Mouth for war on Mon 16/08/2010 10:42:00
BAH! You beat me to it Matti...GRRRR ;)
Title: Re: I need help moving a character from one room to the next.
Post by: Matti on Mon 16/08/2010 10:45:05
 8)
Title: Re: I need help moving a character from one room to the next.
Post by: Khris on Mon 16/08/2010 10:47:15
You'd use a region and its "player steps onto region" event.

Using the edge should work, too: in the room editor, select "Show this room's" edges, then move the line so that the character's feet can cross it.
Title: Re: I need help moving a character from one room to the next.
Post by: Last Boy Scout on Wed 18/08/2010 23:15:17
Thanks guys,

         I tried what all of you said, I feel it's close to working, but when the player tries to interact with the hotspot the game crashes.

         It says this:

         Error: prepare_script: error -18 (no such function in script) trying to run 'cEgo.ChangeRoom()'  (Room 1)

          I'll play around with it a bit more. If anyone still has any suggestions for this problem please let me know.

           :-\

Title: Re: I need help moving a character from one room to the next.
Post by: Khris on Thu 19/08/2010 01:25:46
It doesn't work like that; you don't put the script command ('cEgo.ChangeRoom()') directly into the field.
Remove all text from the field.

What you do is you click on the event text in the table, in this case "Interact hotspot". A small button should appear at the end of the empty field next to it, showing "...".
Click that button.
AGS will put the function name into the field and append the function to the room script. The room script is opened or made the active tab. At the end you should see the newly created function:

function hHotspot1_Interact()
{

}


(My hotspot was still named hHotspot1, it's recommended to rename the hotspot to something appropriate like "hDoor" before clicking the ellipses button.)
If you go back to the hotspot's event list, you can see that in the previously empty field next to the event name it says now "hHotspot1_Interact" (or "hDoor_Interact", or whatever you named the hotspot, with "_Interact" added at the end).

(It's still possible to rename the function to something else; however, the function name and the text in the field must be identical (capitalization included), otherwise you'll get the same error again.)

The final step is to put the script command inside the function's body, i.e. in between the { and }:

function hHotspot1_Interact()
{
  player.ChangeRoom(2);
}


("player" is a substitute for the currently active character.)


Note that all the main parts of my explanation can be found in the tutorial that comes with AGS. Open the helpfile and go to Tutorial -> Starting off -> Tutorial Part 3 - Hotspots and events.
Title: It worked (more or less) thanks!
Post by: Last Boy Scout on Wed 01/09/2010 02:32:08
Khris,

         I think putting the room number inside the parenthesis helped. For some reason the hot spot command didn't quite work, however, when I used this same technique for edges it did! Go figure.

         I was finally able to change rooms and come back to the first room. It took a lot of work but I was able to pull it off with a bit of your help and every one else's. Whew!

         I'll keep you posted if I have any more problems with this. Thanks a lot! That was a big help.



         
Title: Re: I need help moving a character from one room to the next.
Post by: DoorKnobHandle on Wed 01/09/2010 02:35:44
You might be interested in densming's video tutorials (http://www.youtube.com/user/densming#p/c/21DB402CB4DAEAEF), they are well done and explain simple stuff like interactions in a visual and easy to follow manner. Might clear up future issues as well!