Display speech when attempting to exit room

Started by PightyMirate, Fri 11/06/2021 13:48:49

Previous topic - Next topic

PightyMirate

Aloha  :cool:

I have been readings the tutorials, manual and searching the forums etc but cannot seem to fix this little problem..

I wish for the player to walk to the edge of the room (like the user is attempting to exit one side of the screen) but for the character to display speech saying "I cannot go that way" or similar.

I managed to set this up as a hotspot to show speech when the area is walked on, however this area is also the entrance of the room so the character just loops speech when entering.

Many thanks :)

Crimson Wizard

The common solution is to make the character walk few steps away from the area (or edge).

PightyMirate

Quote from: Crimson Wizard on Fri 11/06/2021 14:05:22
The common solution is to make the character walk few steps away from the area (or edge).

Hey Wizard,

Thanks for the quick response. Sidenote I should of added:

I have tried setting this up as a hotspot where the player interacts with the edge of the screen, however I do not want the 'look at' option to be highlighted in the GUI (I am using the LucasArts template).

I just wish for the character to walk to the edge of the screen and display a message "Nope cannot go that way". Would your solution work this way?

Khris

What you're looking for is a region, and its "player steps onto" event.

Don't use hotspots for special parts of the floor, that's what regions are for.

Cassiebsg

Also, you need an if/else condition to determine if you let the player go past the region and change room, or if he's not ready yet.
There are those who believe that life here began out there...

PightyMirate

Quote from: Khris on Fri 11/06/2021 14:40:51
What you're looking for is a region, and its "player steps onto" event.

Don't use hotspots for special parts of the floor, that's what regions are for.

Perfect, thanks Khris...thats much better!

PightyMirate

Quote from: Cassiebsg on Fri 11/06/2021 15:22:45
Also, you need an if/else condition to determine if you let the player go past the region and change room, or if he's not ready yet.

Thanks Cassie...I am new to coding sorry so learning a little bit each day. I have managed to get things working but when the player tries to exit the room, he steps back and says "I cant go that way" twice. Would an if/else condition fix this?

Here is my code:

Code: ags
// room script file
function room_FirstLoad()
{
  aMusicA1.Play();

}

function room_AfterFadeIn()
{
  player.Walk(200, 143, eBlock);
  if (Game.DoOnceOnly("StartCutscene"))
  {
      player.FaceDirection(eDirectionDown);
    player.Say("I've arrived in Bangkok after an 18 hour flight from New Mexico.");
    player.Say("Dr Layards latest discovery must be important...");
    player.Say("He's asked me to meet with him in Thailand as soon as possible...");
    player.Say("But why hasn't he responded to my emails in the past few days?");
    player.Say("I better find my suitcase and get to the hotel.");
  }
}
function room_Load()
{
player.FaceDirection(eDirectionLeft);
}
function room_LeaveLeft()
{
player.ChangeRoom(4, 100, 50, eDirectionRight);
}
function region1_Standing()
{
    player.Walk(270, 143, eDirectionLeft);
    player.Say("I aint getting on no plane, fool!");
}

PightyMirate

Ok all so I changed the region from 'While Standing On' to 'Walks onto Region' and this worked.

Thanks again!  :cheesy:

Khris

This:
Code: ags
  player.Walk(270, 143, eDirectionLeft);


only works as expected by sheer coincidence. The third parameter of Character.Walk is the blocking parameter and supposed to be either eBlock or eNoBlock. (You want eBlock here.)
As soon as you type the comma after the 143, AGS should show an auto-complete window displaying the two available options. These enums are just ints internally, so this doesn't cause an error, but eBlock is 919 and eDirectionLeft is 6. The line does behave as if you had typed eBlock but again, this is just a happy accident.


As for the "while standing on region" event, the linked function is called 40 times per second. Only code that has to run every frame is supposed to go in there, not one-off stuff like walking back and making a comment.

PightyMirate

Quote from: Khris on Mon 14/06/2021 13:25:41
This:
Code: ags
  player.Walk(270, 143, eDirectionLeft);


only works as expected by sheer coincidence. The third parameter of Character.Walk is the blocking parameter and supposed to be either eBlock or eNoBlock. (You want eBlock here.)
As soon as you type the comma after the 143, AGS should show an auto-complete window displaying the two available options. These enums are just ints internally, so this doesn't cause an error, but eBlock is 919 and eDirectionLeft is 6. The line does behave as if you had typed eBlock but again, this is just a happy accident.


As for the "while standing on region" event, the linked function is called 40 times per second. Only code that has to run every frame is supposed to go in there, not one-off stuff like walking back and making a comment.

Thanks Chris, yes guess it was a lucky accident! And thank you for your technical input, I am not a coder or graphic designer; just have a love of adventure games and have always wanted to create my own so I apologies for the basic questions...I am trying to figure it out as I go along but its very kind of you and others to provide their wisdom!  :cheesy:

SMF spam blocked by CleanTalk