[SOLVED] Object.Setview inside a Dialog

Started by san.daniele, Wed 24/04/2013 10:05:07

Previous topic - Next topic

san.daniele

How can I set the view of an object at the end of a dialog? The simple workarounds I tried don't work.

Here's the situation. When the player opens a door a dialog starts right away. Once the dialog is done, the door should close again.
I set the view for the open door in the oDoor_Interact(). dMail1 starts. Now if I change the view back to the closed door inside the oDoor_Interact it won't wait for the dialog to be done, but changes right away (obvious). I was hoping Wait(1) would do the trick, but as you probably already know it didn't.

If I put the oDoor.Setview into the dialog it tells me it's an "Undefined token" (makes sense).

Is there a simple way to pause the interact function when a dialog starts? Or to address the object from inside a dialog?
One workaround I could think of is creating a global variable and use it in the RepExec of the room to set the view.

(while I have not much programming/scripting experience, I kinda don't like the idea to use RepExec if it's avoidable. Feels strange to have a piece of code basically flodding over the game all the time).

Crimson Wizard

If the dialog is supposed to be run from one room only, you may use "object" array:
Code: ags

 object[N].SetView();

where N is the index of your object in that room.

If the dialog may be called from different rooms, you may set global variable and initialize object state in room's "Before Fade-in" handler.

Sort of-
in dialog script:
Code: ags

  if (player.Room == NNN)
    object[N].SetView();
  else
    Must_Set_View_For_My_Object = true;

where NNN is a number of room where object is located.

in room script:
Code: ags

function room_Load()
{
  if (Must_Set_View_For_My_Object)
  {
    oDoor.SetView();
    Must_Set_View_For_My_Object = false;
  }
}

san.daniele

#2
Quote from: Crimson Wizard on Wed 24/04/2013 10:20:24
If the dialog is supposed to be run from one room only, you may use "object" array:
Code: ags

 object[N].SetView();

where N is the index of your object in that room.

Ah, wonderful. I knew there had to be a very simple solution. Thank you so much! I think this will help me on several other occasions later on as well.

edit: if i get it right, that simple line in the dialog could be even used to trigger events in several rooms (as long as all those objects in question look the same and I place them with the same Object-ID).

Crimson Wizard

Quote from: san.daniele on Wed 24/04/2013 10:32:12
edit: if i get it right, that simple line in the dialog could be even used to trigger events in several rooms (as long as all those objects in question look the same and I place them with the same Object-ID).
Well, yes, although I find such practice a bit unsafe, because if you call this dialog from room which does not have object N, this will cause game to crash.

For safer way, you may check CallRoomScript function.

SMF spam blocked by CleanTalk