Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Puccio on Sun 25/05/2008 10:12:16

Title: How may I have the character to change room?
Post by: Puccio on Sun 25/05/2008 10:12:16
Hello, I have read all the tutorial but it doesn't work! I have created two rooms (room 1 and room 2). In the room 1, I have created the edges. At events, just beside "walks off right edge", I wrote "player.change room(2)".

When I run it, the character moves at my command, and, if he walks off the right edge, I have the error "no such function in script trying to run "player.change room(2) return;".

Which is my mistake?

Thank you very much in advance.
Title: Re: How may I have the character to change room?
Post by: Gilbert on Sun 25/05/2008 11:11:05
player.ChangeRoom(2);
return;

The cases of the function names matter, also there shouldn't be any space in a function name. You need a semi-colon for every complete line of code.
You don't really need the "return;" line unless you want to return a value or skip the lines of codes that follow.

Everything is in the manual, try to use the search feature of it and check it harder.
Title: Re: How may I have the character to change room?
Post by: Puccio on Sun 25/05/2008 12:42:21
Thank you, but I am sorry it still doesn't seem to work.

In facts, I clicked on room1, edit, events.
When, in the left column, there is

Walks off right edge

in the right column for this same line, I wrote

player.ChangeRoom(2);
Title: Re: How may I have the character to change room?
Post by: Puccio on Sun 25/05/2008 12:43:17
In the post above I wrote what I made in Edit room. In the room script for room 1, on the other side, there is still nothing about edges. There is only a display line, that I made before (and that works perfectly).

1// room script file
2
3function hHotspot2_Look(2)
4{Display("!");
5
6}
7
Title: Re: How may I have the character to change room?
Post by: Puccio on Sun 25/05/2008 12:44:39
Now, when I do build, run, if I pass the right edge I can read

Error: prepare_script: error -18 (no such function in script) trying to run 'player.ChangeRoom(2);' (Room 1)
Title: Re: How may I have the character to change room?
Post by: Puccio on Sun 25/05/2008 12:46:03
The manual only says about Character.ChangeRoom(int room_number, optional int x, optional int y), that's what I did, but it doesn't seem to say anything about writing edges lines in the script.

Sorry for the inconvenient, thank you again.
Title: Re: How may I have the character to change room?
Post by: Gilbert on Sun 25/05/2008 13:15:47
Please edit your posts instead of posting 4 at a roll. :P

Can you post your whole room script here?
Title: Re: How may I have the character to change room?
Post by: Puccio on Sun 25/05/2008 13:18:59
Hello, I am sorry but my internet connection does not allow uploads of more than six lines at each time...
The whole room script is the seven lines I posted at 12:43, there is nothing else in.
Maybe this is exactly the problem...
Title: Re: How may I have the character to change room?
Post by: Khris on Sun 25/05/2008 16:03:56
Remove all text from the field next to "walks off right edge".
Then click on "walks off right edge", then click the little ...-button.

This will open the room script and add this function to its end:
function room_LeaveRight()
{

}


Now put the line (player.ChangeRoom(2, ...); ) in between { and }.
Title: Re: How may I have the character to change room?
Post by: Puccio on Sun 25/05/2008 16:52:54
Perfect!!! Thank you very much!!!