Manipulating an object from dialogue

Started by Rofl_Mao, Wed 08/08/2012 16:02:50

Previous topic - Next topic

Rofl_Mao

My case is that the player character had a conversation with an NPC. Then the NPC is shocked and dropped something from his hands. The NPC then ran away.

However I can't manipulate the object since I was scripting inside the dialog. Must I break from the dialogue, play the dropped object animation, then go back to the dialogue or is there another way?

NickyNyce

#1
You can script things from the dialog...just add two spaces like this before the code, and you must use object ID numbers instead of their names.

Character: Say whatever text you want...
   object[3].Visible=true;
   object[3].SetView(130);
   etc.

All scripting commands will work if you have two spaces before the line of code inside the dialog.

Rofl_Mao

Quote from: NickyNyce on Wed 08/08/2012 16:20:56
You can script things from the dialog...just add two spaces like this before the code, and you must use object ID numbers instead of their names.

Character: Say whatever text you want...
   object[3].Visible=true;
   object[3].SetView(130);
   etc.

All scripting commands will work if you have two spaces before the line of code inside the dialog.

Hmm maybe I worded it wrong. I know I can script from the dialogue, I just can't access the object.
I got an error since the object wasn't recognized. Specifically, my object was oCup and the error is:
Code: AGS
Dialog 7(60): Error (line 60): Undefined token 'oCup' 

NickyNyce

Use the objects ID number instead of the name. Click on the object and see what number object it is.

object[?].Visible=true;

Crimson Wizard

#4
Quote from: NickyNyce on Wed 08/08/2012 17:26:35
Use the objects ID number instead of the name. Click on the object and see what number object it is.

object[?].Visible=true;

I have a feeling that's not really good way to do that, althought it may work in certain cases.
Problem is that the objects array is filled with the objects from current Room. If you start that dialog in different Room, objects will be different.
Ofcourse you may use this method if you are completely sure that character this dialog involves will never leave his Room, but in general this is a bad practice.

Probably using this is safer:
http://www.adventuregamestudio.co.uk/wiki/?title=Game_/_Global_functions#CallRoomScript
Or maybe there are other ways, which I am not aware of.

Rofl_Mao

Thanks for the replies. I'll try both solutions.

Khris

In order to address CW's remark:
If the dialog is only going to happen in one room, using object[] to access an object in the same room is perfectly fine and exactly what I'd recommend, too.

SMF spam blocked by CleanTalk