Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Brian925 on Sun 24/12/2017 23:22:37

Title: Dialog being canceled out by global variables?
Post by: Brian925 on Sun 24/12/2017 23:22:37
My entire game seems to be functioning properly except for that my character only "talks" when he interacts with himself(You rub up and down your clothes, Damn I look good). I noticed there are global settings that define those interaction messages. Are there additional game settings that could block a simple Say command if you put it in a room's script? I can get my character to change rooms and add inventory but I can't get the text to show up in a simple Say command. I've checked the manual and I could only imagine there is some block command in the global variables that is causing this, but I have no idea where to start looking.
Title: Re: Dialog being canceled out by global variables?
Post by: Khris on Sun 24/12/2017 23:35:44
Quote from: Brian925 on Sun 24/12/2017 23:22:37Are there additional game settings that could block a simple Say command if you put it in a room's script?
The short answer is "No".

Did you actually link the function to the event?
(http://www.adventuregamestudio.co.uk/manual/acintro3.htm)
Title: Re: Dialog being canceled out by global variables?
Post by: Snarky on Sun 24/12/2017 23:36:28
Show us your code.
Title: Re: Dialog being canceled out by global variables?
Post by: Brian925 on Mon 25/12/2017 00:00:10
Code (ags) Select
// room script file

function Room_AfterFadeIn()
{
  cBob.Say("Hello World!");
}

function hBriRoomToHall_WalkOn()
{
  cBob.ChangeRoom(2, 733, 420);
}


function oController_Interact()
{
  cBob.Walk(hWalkToNES.WalkToX, hWalkToNES.WalkToY, eBlock, eWalkableAreas);
  cBob.LockView(2);
  cBob.Animate(1, 5, eRepeat, eNoBlock, eBackwards);
  WaitMouseKey(GetGameSpeed()*20);
  cBob.UnlockView();


}

function hBed_Interact()
{
  cBob.Say("No, I've slept enough.");
}


Neither the "Hello World" or "No I've slept enough" are showing. "No I've slept enough" is called when you interact with a hotspot in the room called hBed.
Also, this is the first room that loads in the game.
Title: Re: Dialog being canceled out by global variables?
Post by: Snarky on Mon 25/12/2017 00:08:46
Quote from: Khris on Sun 24/12/2017 23:35:44
Did you actually link the function to the event?
(http://www.adventuregamestudio.co.uk/manual/acintro3.htm)

This. If you think you've linked them, test that the functions are actually called by adding a Display() line, like e.g.:

Code (ags) Select
function hBed_Interact()
{
  Display("hBed_Interact() called OK");
  cBob.Say("No, I've slept enough.");
}
Title: Re: Dialog being canceled out by global variables?
Post by: Khris on Mon 25/12/2017 01:42:02
Quote from: Brian925 on Mon 25/12/2017 00:00:10
Code (ags) Select
// room script file

function Room_AfterFadeIn()

AGS calls the function room_AfterFadeIn, which means you most likely typed this yourself, expecting it to work without linking it. It won't.
Title: Re: Dialog being canceled out by global variables?
Post by: Brian925 on Mon 25/12/2017 08:48:25
I didn't type the AfterFadeIn code myself. It was a default script already entered before I started making the game.

As far as linking functions to events, I think I'm missing something major as far as how this is carried out and the logic behind it.
I have a room.
In the room script(room1.asc), I have added this code, as requested.
Code (ags) Select

function hBed_Interact()
{
  Display("hBed_Interact() called OK");
  cBob.Say("No, I've slept enough.");
}


The new display command you requested I add did nothing. I click the hotspot on the bed and nothing happens.
My question is, what do I need to link further? If I create the hotspot in the room and name it hBed, with this code, shouldn't you be able to click on it and have the character say "No, I've slept enough" with the code above? Is there more to linking than that?
The only thing I can possibly imagine is that the hotspot z layer is set lower than the room object, but hotspots don't even have z layer options.
Title: Re: Dialog being canceled out by global variables?
Post by: Matti on Mon 25/12/2017 09:11:06
When you say you added this code to the room script, did you add the function by yourself? That's not how it's done.

When editing the hotspot and clicking the lightning bolt, is there a function name in the properties pane (marked in red)?
(https://i.imgur.com/G4Ry9YB.png)

If not, click the ...-button on the right side to create the function (or link the event to the already created function):
(https://i.imgur.com/GJ1RL1n.png)

It's explained in the link Khris posted.
Title: Re: Dialog being canceled out by global variables?
Post by: Brian925 on Mon 25/12/2017 09:15:37
yes there is. that's how i initially put the code in. Clicked the hotspot. named it hBed. Clicked Interact and next to it hBed_Interact appeared.Clicked lightning bolt, clicked ellipsis, added the code.

I have several other hotspots that take me to other rooms when stepped on and others as WalkTo points. They all work fine. For some reason, only when I call to something that requires my main character (cBob) to say something, it doesn't work.
Title: Re: Dialog being canceled out by global variables?
Post by: Snarky on Mon 25/12/2017 09:26:00
Quote from: Snarky on Mon 25/12/2017 00:08:46
If you think you've linked them, test that the functions are actually called by adding a Display() line, like e.g.:

Code (ags) Select
function hBed_Interact()
{
  Display("hBed_Interact() called OK");
  cBob.Say("No, I've slept enough.");
}

Title: Re: Dialog being canceled out by global variables?
Post by: Brian925 on Mon 25/12/2017 09:32:12
is that different than what you originally wrote? Looks the same, and it didn't do anything. That's in my hotspot code, which is linked.

Update: hello world was fixed by linking it with the AfterFadeIn. But the hotspot is linked and it is still not saying anything.
Title: Re: Dialog being canceled out by global variables?
Post by: Stupot on Mon 25/12/2017 10:23:32
Try deleting it all and resetting the function to blank. Then try it all again. I've had to do that a few times for one reason or another.
Title: Re: Dialog being canceled out by global variables?
Post by: Snarky on Mon 25/12/2017 11:21:08
Quote from: Brian925 on Mon 25/12/2017 09:32:12
is that different than what you originally wrote? Looks the same, and it didn't do anything.

Yes, that's the point: This shows that it's the hBed_Interact() function that isn't being called, not any problem with Say().

QuoteThat's in my hotspot code, which is linked.

No, it's not.
Title: Re: Dialog being canceled out by global variables?
Post by: Khris on Mon 25/12/2017 14:06:42
There's a setting in General Settings where all Display() commands are treated as Say() commands, so maybe this single instance of "nothing happens" actually is a Say() problem. Let's check:

Code (ags) Select
function hBed_Interact()
{
  QuitGame(0);
  cBob.Say("No, I've slept enough.");
}
Title: Re: Dialog being canceled out by global variables?
Post by: Brian925 on Mon 25/12/2017 18:40:42
Khris, plugged that in, still no talking.

Snarky, I went through the process above.
Created a hotspot on the bed. Named the hotspot hBed. Clicked the lightning bolt to create hBed_Interact. Added Say and Display commands, respectively. Is there more to linking than this?

Also deleted and started from scratch. Still nothing.
Title: Re: Dialog being canceled out by global variables?
Post by: Snarky on Mon 25/12/2017 20:26:03
No, there shouldn't be. And with Khris's code the game should exit.

I'm starting to wonder if your game is even building correctly. If you make other changes, do you see them in-game? You might want to delete your Compiled folder to force a full rebuild.
Title: Re: Dialog being canceled out by global variables?
Post by: Brian925 on Tue 26/12/2017 19:10:14
Deleted my compiled folder. I am using the default template.
I made a walk on hotspot that worked fine.
I made an interact hotspot that was linked to the character and it did nothing.
Title: Re: Dialog being canceled out by global variables?
Post by: Cassiebsg on Tue 26/12/2017 19:22:05
Are you changing the mode to the hand to interact? or you just clicking it with the feet?
Title: Re: Dialog being canceled out by global variables?
Post by: Vincent on Tue 26/12/2017 19:34:59
Quote from: Cassiebsg on Tue 26/12/2017 19:22:05
Are you changing the mode to the hand to interact? or you just clicking it with the feet?

Right, maybe that mean the mouse is not to the interact mode to execute the function.
Maybe you could try to do this check just as debug test?
Code (ags) Select

function repeatedly_execute_always()
{
  Hotspot*h = Hotspot.GetAtScreenXY(mouse.x, mouse.y);
  if (h == hotspot[1]) //ID number of the hotspot required
  mouse.Mode = eModeInteract;
}
Title: Re: Dialog being canceled out by global variables?
Post by: Brian925 on Tue 26/12/2017 19:47:02
Quote from: Cassiebsg on Tue 26/12/2017 19:22:05
Are you changing the mode to the hand to interact? or you just clicking it with the feet?

The hand. lol if that was the problem I'd quit forever. haha

Update: The text appears when I replace the hotspot with an object. I guess I'm going to improvise unless I want to undo my entire game and start over.
Title: Re: Dialog being canceled out by global variables?
Post by: Crimson Wizard on Tue 26/12/2017 20:34:52
Quote from: Brian925 on Tue 26/12/2017 19:47:02
I made a walk on hotspot that worked fine.
I made an interact hotspot that was linked to the character and it did nothing.

Hmm, could you elaborate what you mean by "walk on hotspot" and "interact hotspot that was linked to the character"?
Hotspots do not have "walk on" interaction.
Can it be you are painting walkable areas or regions instead of hotspots, or something like that?
Title: Re: Dialog being canceled out by global variables?
Post by: doctorhibert on Tue 26/12/2017 21:18:00
I don't know how much help this is gonna be, but if you're starting over the BASS template is significantly easier since you only have two types of interactions, maybe that'd be more up your alley
Title: Re: Dialog being canceled out by global variables?
Post by: Brian925 on Wed 27/12/2017 00:40:30
Quote from: Crimson Wizard on Tue 26/12/2017 20:34:52
Quote from: Brian925 on Tue 26/12/2017 19:47:02
I made a walk on hotspot that worked fine.
I made an interact hotspot that was linked to the character and it did nothing.

Hmm, could you elaborate what you mean by "walk on hotspot" and "interact hotspot that was linked to the character"?
Hotspots do not have "walk on" interaction.
Can it be you are painting walkable areas or regions instead of hotspots, or something like that?

Hotspots do have walk on interaction. Every single room in my game has walk on hot spots that when the character walks on them, the room changes.
For example, a code like this.
Code (ags) Select

function hBobRoomToHall_WalkOn()
{
  cBob.ChangeRoom(2, 733, 420);
}
Title: Re: Dialog being canceled out by global variables?
Post by: Crimson Wizard on Wed 27/12/2017 00:45:23
Quote from: Brian925 on Wed 27/12/2017 00:40:30
Hotspots do have walk on interaction.
Oh, right, my mistake, it is called "Stands on" in the event list.

Well, I have absolutely no idea at this point, maybe you could just upload your game project, since it is only made from default template?
Title: Re: Dialog being canceled out by global variables?
Post by: Khris on Fri 29/12/2017 15:56:23
Yes, please upload your game. I'll bet all my Bitcoins (0.00) that this is user error.
Title: Re: Dialog being canceled out by global variables?
Post by: Kweepa on Fri 29/12/2017 17:15:36
Could it be you didn't 'fill' the hotspot with a solid colour?
Or perhaps the hotspot is behind another object that is consuming the click?
You could add this code to the room script:

function on_mouse_click(MouseButton button)
{
  Hotspot *h = Hotspot.GetAtScreenXY(mouse.x, mouse.y);
  if (h != null)
  {
    if (h.IsInteractionAvailable(eModeInteract))
    {
      Display("Hotspot %s has interact interaction.", h.Name);
    }
    else
    {
      Display("Hotspot %s has NO interact interaction.", h.Name);
    }
  }
  else
  {
    Display("No hotspot there.");
  }
  Object *ob = Object.GetAtScreenXY(mouse.x, mouse.y);
  if (ob != null)
  {
    Display("Object %s hiding hotspot.", ob.Name);
  }
  Character *c = Character.GetAtScreenXY(mouse.x, mouse.y);
  if (c != null)
  {
    Display("Character %s hiding hotspot.", c.Name);
  }
}