Parse error regarding = false and multiple characters.

Started by Nicodoll, Sun 25/07/2010 09:51:51

Previous topic - Next topic

Nicodoll

Parse errors are all the rage these days.

The function I am trying to do is not working correctly because of a Parse error. I'm not too sure how to solve this; is it because my function is not correct?

The function is supposed to work like this: If a character is exchanged with another character, all the Mouse cursor functions will only be able to work for the exchanged character.

function aChar1_Talk()
{
 aChar1.Say("I will say something");
  if (player==aChar2)
   aChar2.Say("I'm saying something.");
   aChar1.Say("I will say something"); = false;
}
 
Thank you in advance.  :)

Atelier

#1
Just as a note, a ; ends the current line of code completely (there can never be anything after it), and = false is redundant here anyway, because Char.Say isn't a bool (either true or false), but a String (it can hold any value).

Quote from: Nicodoll on Sun 25/07/2010 09:51:51
The function is supposed to work like this: If a character is exchanged with another character, all the Mouse cursor functions will only be able to work for the exchanged character.

I'm not sure I understand. At the moment your function doesn't show any of this.

Welcome to the forums by the way.

Khris

Yeah, one second here :)

By this line: aChar1.Say("I will say something"); = false;, are you trying to retroactively make AGS not execute the first one?
I don't quite get how the function is supposed to work, but I'll assume you'll simply want a different outcome depending on who is the current player character.

Code: ags
function aChar1_Talk()
{
  if (player == aChar1) Display("Talking to yourself is a sign of madness.");
  else aChar1.Say("I will say something");
}


Note that in order to execute two or more commands depending on the outcome of a condition check, you have to put them in another { }-block.

Code: ags
function aChar1_Talk()
{
  if (player == aChar1) Display("Talking to yourself is a sign of madness.");
  else
  {
    aChar1.Say("Hello.");
    aChar1.Say("How are you?");
  }
}


Nicodoll

Quote from: Khris on Sun 25/07/2010 10:52:26
By this line: aChar1.Say("I will say something"); = false;, are you trying to retroactively make AGS not execute the first one?
I don't quite get how the function is supposed to work, but I'll assume you'll simply want a different outcome depending on who is the current player character.


Yes, this is exactly what I want to do.

The thing is though is that the code requires me to click on the previous character (aChar1) instead of (aChar2) to get the saying out of aChar2.

Sorry if I'm being too demanding, by the way. Thank you.

Khris

That's no problem, it's what this forum's for :)

Still not sure what exactly you're trying to achieve; do you have a team of two characters the player can switch between and you want them to be able to talk to each other? Or is aChar1/aChar2 the same character in terms of game design and supposed to react differently depending on who's addressing him?

Nicodoll

Quote from: Khris on Sun 25/07/2010 11:49:11
That's no problem, it's what this forum's for :)

Still not sure what exactly you're trying to achieve; do you have a team of two characters the player can switch between and you want them to be able to talk to each other? Or is aChar1/aChar2 the same character in terms of game design and supposed to react differently depending on who's addressing him?

I have a team of multiple characters that can switch between different stages.

I want to be able to use the interacting/talking/Looking functions with other characters.

For example:
Character A: Oh look, its a chair
Character A switches to Character B, who is now the player character, while character A is a NPC.
Character B looks at the chair and says:
Hey, a Chair!

Different outcomes for a different character.

Thank you for all the help BTW, it's really kind of you!

SSH

Code: ags

function cFred_Talk () {
  if (player == cFred) {
     player.Say("I wish I had made the player character unclickable when switching, as click on oneself are annoying");
  } else if (player==cBetty) {
     player.Say("Hey, Fred, while Barney's not around lets get it on.");
  } else if (player==cBarney) {
     player.Say("Fred, old pal, if you hit on Betty, I'll kill you");
  }
}


12

Nicodoll

Quote from: SSH on Sun 25/07/2010 12:12:46
Code: ags

function cFred_Talk () {
  if (player == cFred) {
     player.Say("I wish I had made the player character unclickable when switching, as click on oneself are annoying");
  } else if (player==cBetty) {
     player.Say("Hey, Fred, while Barney's not around lets get it on.");
  } else if (player==cBarney) {
     player.Say("Fred, old pal, if you hit on Betty, I'll kill you");
  }
}




This...This was surprisingly helpful.

I guess this code only works for objects and events; that makes sense.

Thanks!  :)

SMF spam blocked by CleanTalk