Author Topic: Dialog being canceled out by global variables?  (Read 866 times)

Dialog being canceled out by global variables?
« on: 24 Dec 2017, 23:22 »
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

    • Lifetime Achievement Award Winner
    •  
    • I can help with play testing
    •  
    • I can help with scripting
    •  
    • I can help with translating
    •  
    • Khris worked on a game that was nominated for an AGS Award!
Re: Dialog being canceled out by global variables?
« Reply #1 on: 24 Dec 2017, 23:35 »
Are 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

  • Global Moderator
  • Mittens Earl
  • Private Insultant
    • I can help with proof reading
    •  
    • I can help with translating
    •  
Re: Dialog being canceled out by global variables?
« Reply #2 on: 24 Dec 2017, 23:36 »
Show us your code.

Re: Dialog being canceled out by global variables?
« Reply #3 on: 25 Dec 2017, 00:00 »
Code: Adventure Game Studio
  1. // room script file
  2.  
  3. function Room_AfterFadeIn()
  4. {
  5.   cBob.Say("Hello World!");
  6. }
  7.  
  8. function hBriRoomToHall_WalkOn()
  9. {
  10.   cBob.ChangeRoom(2, 733, 420);
  11. }
  12.  
  13.  
  14. function oController_Interact()
  15. {
  16.   cBob.Walk(hWalkToNES.WalkToX, hWalkToNES.WalkToY, eBlock, eWalkableAreas);
  17.   cBob.LockView(2);
  18.   cBob.Animate(1, 5, eRepeat, eNoBlock, eBackwards);
  19.   WaitMouseKey(GetGameSpeed()*20);
  20.   cBob.UnlockView();
  21.  
  22.  
  23. }
  24.  
  25. function hBed_Interact()
  26. {
  27.   cBob.Say("No, I've slept enough.");
  28. }

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.
« Last Edit: 25 Dec 2017, 00:05 by Brian925 »

Snarky

  • Global Moderator
  • Mittens Earl
  • Private Insultant
    • I can help with proof reading
    •  
    • I can help with translating
    •  
Re: Dialog being canceled out by global variables?
« Reply #4 on: 25 Dec 2017, 00:08 »
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: Adventure Game Studio
  1. function hBed_Interact()
  2. {
  3.   Display("hBed_Interact() called OK");
  4.   cBob.Say("No, I've slept enough.");
  5. }

Khris

    • Lifetime Achievement Award Winner
    •  
    • I can help with play testing
    •  
    • I can help with scripting
    •  
    • I can help with translating
    •  
    • Khris worked on a game that was nominated for an AGS Award!
Re: Dialog being canceled out by global variables?
« Reply #5 on: 25 Dec 2017, 01:42 »
Code: Adventure Game Studio
  1. // room script file
  2.  
  3. 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.

Re: Dialog being canceled out by global variables?
« Reply #6 on: 25 Dec 2017, 08:48 »
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: Adventure Game Studio
  1. function hBed_Interact()
  2. {
  3.   Display("hBed_Interact() called OK");
  4.   cBob.Say("No, I've slept enough.");
  5. }

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.

Re: Dialog being canceled out by global variables?
« Reply #7 on: 25 Dec 2017, 09:11 »
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.
« Last Edit: 25 Dec 2017, 09:14 by Matti »

Re: Dialog being canceled out by global variables?
« Reply #8 on: 25 Dec 2017, 09:15 »
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.
« Last Edit: 25 Dec 2017, 09:24 by Brian925 »

Snarky

  • Global Moderator
  • Mittens Earl
  • Private Insultant
    • I can help with proof reading
    •  
    • I can help with translating
    •  
Re: Dialog being canceled out by global variables?
« Reply #9 on: 25 Dec 2017, 09:26 »
If you think you've linked them, test that the functions are actually called by adding a Display() line, like e.g.:

Code: Adventure Game Studio
  1. function hBed_Interact()
  2. {
  3.   Display("hBed_Interact() called OK");
  4.   cBob.Say("No, I've slept enough.");
  5. }

Re: Dialog being canceled out by global variables?
« Reply #10 on: 25 Dec 2017, 09:32 »
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.
« Last Edit: 25 Dec 2017, 09:43 by Brian925 »

Stupot

    • I can help with play testing
    •  
    • I can help with proof reading
    •  
    • I can help with story design
    •  
    • I can help with voice acting
    •  
Re: Dialog being canceled out by global variables?
« Reply #11 on: 25 Dec 2017, 10:23 »
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

  • Global Moderator
  • Mittens Earl
  • Private Insultant
    • I can help with proof reading
    •  
    • I can help with translating
    •  
Re: Dialog being canceled out by global variables?
« Reply #12 on: 25 Dec 2017, 11:21 »
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().

Quote
That's in my hotspot code, which is linked.

No, it's not.

Khris

    • Lifetime Achievement Award Winner
    •  
    • I can help with play testing
    •  
    • I can help with scripting
    •  
    • I can help with translating
    •  
    • Khris worked on a game that was nominated for an AGS Award!
Re: Dialog being canceled out by global variables?
« Reply #13 on: 25 Dec 2017, 14:06 »
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: Adventure Game Studio
  1. function hBed_Interact()
  2. {
  3.   QuitGame(0);
  4.   cBob.Say("No, I've slept enough.");
  5. }

Re: Dialog being canceled out by global variables?
« Reply #14 on: 25 Dec 2017, 18:40 »
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

  • Global Moderator
  • Mittens Earl
  • Private Insultant
    • I can help with proof reading
    •  
    • I can help with translating
    •  
Re: Dialog being canceled out by global variables?
« Reply #15 on: 25 Dec 2017, 20:26 »
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.

Re: Dialog being canceled out by global variables?
« Reply #16 on: 26 Dec 2017, 19:10 »
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

  • Cavefish
  • Fleeing the Cylon tyrrany...
    • Cassiebsg worked on a game that was nominated for an AGS Award!
Re: Dialog being canceled out by global variables?
« Reply #17 on: 26 Dec 2017, 19:22 »
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

  • "That is not a good reason"
    • I can help with play testing
    •  
    • I can help with scripting
    •  
    • I can help with translating
    •  
Re: Dialog being canceled out by global variables?
« Reply #18 on: 26 Dec 2017, 19:34 »
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: Adventure Game Studio
  1. function repeatedly_execute_always()
  2. {
  3.   Hotspot*h = Hotspot.GetAtScreenXY(mouse.x, mouse.y);
  4.   if (h == hotspot[1]) //ID number of the hotspot required
  5.   mouse.Mode = eModeInteract;
  6. }
  7.  
« Last Edit: 26 Dec 2017, 19:37 by Vincent »

Re: Dialog being canceled out by global variables?
« Reply #19 on: 26 Dec 2017, 19:47 »
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.
« Last Edit: 26 Dec 2017, 20:16 by Brian925 »