How to do something after leaving a closeup? [solved]

Started by HandsFree, Sun 24/04/2011 23:20:27

Previous topic - Next topic

HandsFree

Hi again,

I have a letter in inventory and when you look at it you'll see a closeup. To do this I created a new room with the closeup of the letter and ShowPlayerCharacter set to false.
To 'leave' that screen I used ChangeRoom(character.PreviousRoom) because you can be anywhere when you look at the letter.

Now I want the character to comment after reading the letter, but if I put it in Room_Leave it will display while still in the closeup, and that looks messy.
So to display the comment after leaving the closeup, it looks like I have to put that code in every room (if character.PreviousRoom == CloseUp).
But I'm hoping there is an easier way to do that...

thanks

Matti

Create a global variable (bool JustRead for example). Set the variable to true in the closeup room. Then put

Code: ags

if (JustRead){
  JustRead = false;
  player.Say ("Interesting...");
}


in the repeatedly execute function in the global script.

monkey0506

Actually, you don't even need a global variable for this. You could just use a script-wide variable (global within the scope of a given script, but local to that script, not accessible from other scripts). I'm thinking something along the lines of the global "after fade-in" event workaround that I concocted:

Code: ags
// GlobalScript.asc

bool JustRead = false;
// no need to export this, we're not using it in other scripts, only here!

function on_event(EventType event, int data)
{
  if (event == eEventEnterRoomBeforeFadein)
  {
    if (player.PreviousRoom == LETTER_CLOSEUP_ROOM) JustRead = true;
  }
}

function repeatedly_execute()
{
  if ((JustRead) && (!IsGamePaused()) && (IsInterfaceEnabled()))
  {
    Display("Wow, what an interesting letter!");
    JustRead = false;
  }
}

Sephiroth

#3
Hello,

I don't know if there's a reason for using changeroom but I think you could use a gui the size of the screen, and use a button to display the letter or any other close up on it, so you just have something like:

Code: ags

//Global String CloseupDescription 

function CloseUp(int sprite, String desc)
{
  PauseGame();
  CloseupDescription = desc;
  Button.NormalGraphic = sprite;
  CloseupGui.Visible = true;
}

//when a close up occurs

  CloseUp(10, "That letter was really intresting indeed.");

//when a close up is skipped

  UnPauseGame();
  CloseupGui.Visible = false;
  Display(CloseupDescription);
 


This could help if you're using more than one in the game and would simplify the Changeroom process. This is just an idea.

HandsFree

I tried Matti's suggestion and it works. Thanks.
Monkey_05_06's code looks more complex at first sight. Is there a reason to do that? Will performance improve or something like that?

I'm just learning how AGS works and I'm using the RON template so I thought creating a GUI was a bit out of scope for now.
I used the changeroom because it says in the tutorial that ShowPlayerCharacter when checked (that should be 'when false' I assume) is "Useful for close-up displays of control panels and so forth".
How is using a GUI easier than ChangeRoom?

thanks

Sephiroth

Will you have one room for each close up?

I don't know how the ron template works but the whole process of changing room and then having to split the code inside after_fadein etc is harder than actually creating a gui and a button which takes 3 clicks to accomplish.

I'm just suggesting what I think would be easier, if you get things working that's what counts ;)

HandsFree

Yes, I thought I should have one room for each closeup. But I don't know how many closeups there will be or how many need a comment.
I'm not following an exact plan or anything, for now I'm just seeing how everything works.
When I'm more comfortable with the basics I'll probably look into the GUI thing.

thanks

SMF spam blocked by CleanTalk