Dialog being canceled out by global variables?

Started by Brian925, Sun 24/12/2017 23:22:37

Previous topic - Next topic

Brian925

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.

Khris

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)

Snarky


Brian925

#3
Code: ags
// 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.

Snarky

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
function hBed_Interact()
{
  Display("hBed_Interact() called OK");
  cBob.Say("No, I've slept enough.");
}

Khris

Quote from: Brian925 on Mon 25/12/2017 00:00:10
Code: ags
// 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.

Brian925

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

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.

Matti

#7
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)?


If not, click the ...-button on the right side to create the function (or link the event to the already created function):


It's explained in the link Khris posted.

Brian925

#8
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.

Snarky

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
function hBed_Interact()
{
  Display("hBed_Interact() called OK");
  cBob.Say("No, I've slept enough.");
}


Brian925

#10
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.

Stupot

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.

Snarky

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.

Khris

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
function hBed_Interact()
{
  QuitGame(0);
  cBob.Say("No, I've slept enough.");
}

Brian925

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.

Snarky

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.

Brian925

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.

Cassiebsg

Are you changing the mode to the hand to interact? or you just clicking it with the feet?
There are those who believe that life here began out there...

Vincent

#18
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

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;
}

Brian925

#19
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.

SMF spam blocked by CleanTalk