Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: alphadalekben on Sun 20/07/2014 12:16:39

Title: Minor issue getting a character to use several dialogues
Post by: alphadalekben on Sun 20/07/2014 12:16:39
I am having an issue getting a character to say different dialogues in different rooms.

Here is what the code looks like at the minute;

Code (ags) Select

function cWiseSage_Talk()
{
  if (player.Room != 2)  dCrystals.Start();

  if (player.Room != 3) dMPTutorial.Start();
}
{/code]

The game will run but bMPTutorial will run in room 2, skipping dCrystals entirely.
Title: Re: Minor issue getting a character to use several dialogues
Post by: monkey424 on Sun 20/07/2014 12:29:02
Quote from: alphadalekben on Sun 20/07/2014 12:16:39
bMPTutorial will run in room 2, skipping dCrystals entirely.

This is correct. The code says if the player isn't in room 2, i.e. player.Room doesn't equal (!=) room 2, then start the dCrystals dialogue.

Conversely, dCrystals will NOT start if the character IS in room 2.
Title: Re: Minor issue getting a character to use several dialogues
Post by: alphadalekben on Sun 20/07/2014 12:41:18
How do I get it so that dCrystals DOES activate in Room 2?
Title: Re: Minor issue getting a character to use several dialogues
Post by: alphadalekben on Sun 20/07/2014 13:04:38
I have changed the code to the following:

Code (ags) Select


function cWiseSage_Talk()
{
  if (player.Room = 2) dCrystals.Start();
  if (player.Room = 3) dMPTutorial.Start();
}

[\code]

I also get the following error.

GlobalScript.asc(535): Error (line 535): Parse error in expr near 'player'

What am I doing wrong here?
Title: Re: Minor issue getting a character to use several dialogues
Post by: Gurok on Sun 20/07/2014 13:07:34
You need == for comparison. Try changing your if statements to:

if (player.Room == 2) dCrystals.Start();
if (player.Room == 3) dMPTutorial.Start();
Title: Re: Minor issue getting a character to use several dialogues
Post by: alphadalekben on Sun 20/07/2014 13:43:01
Cheers. I always seem to have issues with the minor stuff, strangely.
Title: Re: Minor issue getting a character to use several dialogues
Post by: Khris on Sun 20/07/2014 15:36:03
Here's the relevant manual page:
http://www.adventuregamestudio.co.uk/manual/ags46.htm#topic44
Title: Re: Minor issue getting a character to use several dialogues
Post by: Mandle on Sun 20/07/2014 15:54:02
Quote from: Gurok on Sun 20/07/2014 13:07:34
You need == for comparison. Try changing your if statements to:

This was a major step for myself to conquer in understanding how the code worked actually...

I couldn't get used to why you needed a double == when testing conditions and why a simple = was used when setting them.

Then I realized that the easiest way to remember was that when testing the varible in an "if" statement you also use <= or != etc.

So you need two symbols to test the variable condition, but only one to set it ("++" and "--" are shortcuts :P)

So anyway...That's how I got used to the way it works
Title: Re: Minor issue getting a character to use several dialogues
Post by: Mandle on Sun 20/07/2014 15:54:52
Sorry for double post
Title: Re: Minor issue getting a character to use several dialogues
Post by: alphadalekben on Sun 20/07/2014 16:33:52
Ok, I've another issue now. My current code for another character is the following:

Code (ags) Select

Jackson: Excuse me, sir?
MarketStall: G'day, mate.
MarketStall: What can I do ya for?
Jackson: Well, you see.
Jackson: I was wondering if you'd be so kind
Jackson: As to allow me to buy a stick of dynamite?
MarketStall: Hehehe...
Jackson: Yeah, I know.
Jackson: That sort of thing
Jackson: Would only happen in video games.
MarketStall: Hehehe...
MarketStall: I'll tell you what, my good mate.
Jackson: Yes?
MarketStall: As this is only a demo,
MarketStall: I'll let you have one on the house.
  cJackson.AddInventory(iKey);
Jackson: Thank you very much.
[\code]

And this is the function:

[code=ags]
function cMarketStall_Talk()
{
  dMarketDynamite.Start ();
}
[\code]

The issue is when I click the character in Talk mode, the conversation doesn't start.
Title: Re: Minor issue getting a character to use several dialogues
Post by: Cassiebsg on Sun 20/07/2014 18:53:29
I'll go on a limb ans ask if you just typed the function directly in the script, or if you actually use the event panel for the character? If you just type it, you need to click on the character you want to talk to, click on the event button and then on the "talk to character" option.

If that isn't it, you need someone that knows more about AGS than I do. ;)
Title: Re: Minor issue getting a character to use several dialogues
Post by: Khris on Sun 20/07/2014 23:14:08
Is this the entire dialog script? Because I'm not seeing the @S entry point.
There should also be a "stop" command at the end, I guess.
Title: Re: Minor issue getting a character to use several dialogues
Post by: alphadalekben on Mon 21/07/2014 18:36:47
Thanks, Cassie, you fixed it for me. Khris, they are both there. I just didn't paste them in.
Title: Re: Minor issue getting a character to use several dialogues
Post by: Khris on Mon 21/07/2014 20:26:14
Yes, like I told you before (http://www.adventuregamestudio.co.uk/forums/index.php?topic=50722.msg636492780#msg636492780), you can't just type functions into the script and expect them to be called by AGS, you have to link them to the event.
(This is why I assumed something else was the cause here.)
Title: Re: Minor issue getting a character to use several dialogues
Post by: alphadalekben on Tue 22/07/2014 19:16:54
Another minor issue again. I'm trying to get the character to say a different dialogue depending on the player's View and I'm getting this error;
GlobalScript.asc(541): Error (line 541): PE04: parse error at ';'

Here's what my code looks like at the moment;

Code (ags) Select

function cWiseSage_Talk()
{
  if (player.Room == 2) dCrystals.Start();
  if (player.Room == 3) dMPTutorial.Start();
  if (player.Room == 4);
{
   if (player.View == 13) dCaveDynamite.Start();
   if (player.View == 14) dRockDynamite.Start();
}
}


The issue results from the bottom few statements.
Title: Re: Minor issue getting a character to use several dialogues
Post by: Slasher on Tue 22/07/2014 19:52:22
QuoteGlobalScript.asc(541): Error (line 541): PE04: parse error at ';'
For starters if statements do not end with a ; .....this is the error

Title: Re: Minor issue getting a character to use several dialogues
Post by: alphadalekben on Tue 22/07/2014 19:57:50
I get this error when I remove the semicolon;
Dialog 3(20): Error (line 20): expected semicolon after ')'
Title: Re: Minor issue getting a character to use several dialogues
Post by: Slasher on Tue 22/07/2014 20:09:31
you have not given anything to happen after that function, it's blank.

You need to read manual or do a search here for more about adding functions, if, else if and else statements....

This problem is a fairly basic one that crops up all the time.

You should not expect to always get a complete script written for you but rather help and advice and a kick in the right direction and there are some magic scripters here ;)


Title: Re: Minor issue getting a character to use several dialogues
Post by: alphadalekben on Tue 22/07/2014 20:42:54
Thanks. It was a mind-fart on my part anyway. I thought the error referred to the Global Script, not Dialogue 3. My bad.