Changing room - problem with script

Started by lepetitcaporal, Tue 22/03/2016 19:15:51

Previous topic - Next topic

lepetitcaporal

Hello guys,
firts of all, please forgive my mistakes, English isn't my mother language.
It seems as silly question, but I REALLY can't make my character changing room.
I've read all the posts, wikia and so on, but can't figure out what am I doing wrong.
I created hotspot (the door) and I imagine, that clickin on it will move my char to the other room.

Code: ags
function hDoor_Interact()
{
cKiniol.ChangeRoom(2, 440,  470);
}


The second room is created of course.

After interacting with the door, I get:
Quote---------------------------
Adventure Game Studio
---------------------------
An internal error has occurred. Please note down the following information.
If the problem persists, post the details on the AGS Technical Forum.
(ACI version 3.3.4.2)

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

---------------------------
OK   
---------------------------

Any as plain as day ideas and advices?

Thank you guys
MichaŠ‚

Danvzare

Hmm... I'm not sure what the problem is. The code you gave definitely works.
Just to clarify, you are using the hand icon on the door aren't you?
You've got this code in the interaction function of the door, so you need to actually interact with the door.

If that isn't the problem, can you confirm that "hDoor_Interact()" is in the "Interact object" field on the object in the room editor?

lepetitcaporal

#2
Yes, I'm using the hand icon ingame that causes interaction.
In my door's hotspot, under InteractHotspot in Events tab appears "hDoor_Interact".

Cassiebsg

Could you just delete the function and the link from the events page, and then create the link again? Maybe there's something odd in the name that isn't obvious, then just type your code. or just type
Code: ags

Display("This is door interaction");


If you get the display, then try and add the changeroom code afterwards.
There are those who believe that life here began out there...

Danvzare

I think I might know what the problem is.
It's got nothing to do with the door, the problem is when you leave the room.
In the "Leave room" field in the Events tab of the room, is something that's pointing to a function called "room_Leave" which apparently doesn't exist.
So just take out that call to "room_Leave" and you should be good to go.

lepetitcaporal

Danvzar! Thanks!
I added code written below and it works like a charm. Is this properly written? I'm noob at programming.
Code: ags
function hDoor_Interact()
{
cKiniol.ChangeRoom(2, 440,  470);
}

function room_Leave()
{

}


But when i enter to the next room, my character is big as hell (scaling out of room no.1 is still available instead of character scaling setting in room no 2) and I can't move regardless of the fact i created walkable areas.

Danvzare

Yep, that code is written perfectly. :-D

As for why you can't move your character and the scaling not working. I'm guessing your character isn't in a walkable area. You might want to try changing the coordinates that the character goes to when you change to that room.

lepetitcaporal

Thanks, You were right again. I just made the whole background walkable area and problem is solved. Thank you, I owe you one. 8-)8-)8-)

Khris

Just FYI: never delete functions from the script unless you have also removed them from the associated event.

Instead of adding an empty room_Leave(), just go to the room's events and clear the field.

SMF spam blocked by CleanTalk