Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: skooperstooper on Thu 15/09/2022 01:57:45

Title: (solved) How to resume dialog after a room switch?
Post by: skooperstooper on Thu 15/09/2022 01:57:45
This may be above the comfort level I'm at with code right now. If so, I can save it for later. I have dialog where the player can agree to look at something. If they refuse, the dialog goes to an exit conversation. If they accept, the game switches to what they're supposed to look at, then goes back to the exit conversation.

Setting up the dialog was fine, but I used a room as the thing they're supposed to look at so they can interact with hotspots within it. How do I tell the game to move on to the exit dialog when it switches back from that room?

Do I have to set up a variable for what just happened, then tell the room to check for it and immediately run the exit dialog if true? The player can look at that thing whenever they want after that without any dialog, so there has to be a way for the game to know to only trigger the exit dialog this one time.

The bigger question would be if there's a simpler way to do that kind of insert without switching to another room, like opening a full screen gui? Like if I want the player to look at a painting and be able to click on different hotspots on it up close to display info, can that be done with a gui or are hotspots only a room thing?

I'm not being specific because I need to learn the concepts so I can apply them to other situations I know will be similar. I don't want that derailed by focusing too much on what I happen to be doing in this one specific instance. Thanks!
Title: Re: How to resume dialog after a room switch? (sierra)
Post by: heltenjon on Thu 15/09/2022 08:27:28
Quote from: skooperstooper on Thu 15/09/2022 01:57:45
Do I have to set up a variable for what just happened, then tell the room to check for it and immediately run the exit dialog if true? The player can look at that thing whenever they want after that without any dialog, so there has to be a way for the game to know to only trigger the exit dialog this one time.
Yes, that should work. If you make a "leave" hotspot, you could check for a bool variable. The extra coding will be to save which room the player is currently in when looking at the painting later on, to make sure he's returned to the correct room. So perhaps you are better off with your other suggestion.

QuoteThe bigger question would be if there's a simpler way to do that kind of insert without switching to another room, like opening a full screen gui? Like if I want the player to look at a painting and be able to click on different hotspots on it up close to display info, can that be done with a gui or are hotspots only a room thing?
You can put clickable buttons on a GUI, which work like hotspots do (like the "quit" and "play" in the quit GUI). This will have the benefit of not having to leave and return to the room, just making the GUI visible or not.

I'm not a very good coder, so I'm sure there are lots of other solutions as well. You could probably solve it by making several objects visible, too. That could be useful if, say, you wanted the painting background, but wanted the player to be able to magically take the apple Eve is holding in the painting.
Title: Re: How to resume dialog after a room switch? (sierra)
Post by: Khris on Thu 15/09/2022 08:52:18
AGS has  player.previousRoom  and  Game.DoOnceOnly  so one way to solve this is putting this inside the "after fadein" event function of the room where you're having the conversation:

Code (ags) Select
  if (player.PreviousRoom == LOOKING_AT_THE_THING_ROOM_NUMBER) {
    if (Game.DoOnceOnly("player finished looking at the thing")) {
      dTheThingExitConvo.Start();
    }
  }


In general, like you said, the way "for the game to know" is a variable. You just need to figure out which kind you need, when you need to set it and when you need to check it.
Title: Re: How to resume dialog after a room switch? (sierra)
Post by: skooperstooper on Thu 15/09/2022 09:56:18
Okay, thanks, both of you! I wasn't sure if a gui would work because doesn't it need graphics for buttons, unlike hotspots where you just draw the area you want to be clickable? So if I went that route, I'd need to make the buttons transparent?

Khris, I'll look into the game once only thing, I've never seen that before. Thanks for the reminder about the previous room character function! That'll help with this and with the other question I posted I think. I'll post back here when I have some code that works or if I need to troubleshoot what I came up with. Will change to solved for now.