Minor issue getting a character to use several dialogues

Started by alphadalekben, Sun 20/07/2014 12:16:39

Previous topic - Next topic

alphadalekben

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

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.

monkey424

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.
    

alphadalekben

How do I get it so that dCrystals DOES activate in Room 2?

alphadalekben

I have changed the code to the following:

Code: ags


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?

Gurok

You need == for comparison. Try changing your if statements to:

Code: ags
if (player.Room == 2) dCrystals.Start();
if (player.Room == 3) dMPTutorial.Start();
[img]http://7d4iqnx.gif;rWRLUuw.gi

alphadalekben

Cheers. I always seem to have issues with the minor stuff, strangely.


Mandle

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

Mandle

Sorry for double post

alphadalekben

Ok, I've another issue now. My current code for another character is the following:

Code: ags

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.

Cassiebsg

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. ;)
There are those who believe that life here began out there...

Khris

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.

alphadalekben

Thanks, Cassie, you fixed it for me. Khris, they are both there. I just didn't paste them in.

Khris

Yes, like I told you before, 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.)

alphadalekben

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

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.

Slasher

QuoteGlobalScript.asc(541): Error (line 541): PE04: parse error at ';'
For starters if statements do not end with a ; .....this is the error


alphadalekben

I get this error when I remove the semicolon;
Dialog 3(20): Error (line 20): expected semicolon after ')'

Slasher

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



alphadalekben

Thanks. It was a mind-fart on my part anyway. I thought the error referred to the Global Script, not Dialogue 3. My bad.

SMF spam blocked by CleanTalk