If else and active Inventory coding problem

Started by Furwerkstudio, Sat 30/01/2016 02:44:54

Previous topic - Next topic

Furwerkstudio

I am working on a practice game, and there is a scene where the player, Called "thrif" because of a typo but it stuck, stole a bag from someone. I want to display a different message if the player has the bag in the inventory, I tried the if/else statements and the activeinventory codes but when I try testing it there is an error.

What am I doing wrong?

Thanks in advance.

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


Code: ags

function cMystica_Interact()
{
cThrif.Walk(166,166, eBlock, eWalkableAreas);
player.Say("What are you in for?");
cMystica.Say("That some kind of joke?");
cMystica.Say("Why are you chatting when there's many guards here.");
cMystica.Say("You know, the kind ready to catch you.");
cPoo.Say("He's just being polite.");
cMystica.Say("Is it normal for a rouge to chat up prisoners.");
cThrif.Say("Yes.");
cPoo.Say("Yeah.");
cMystica.Say("Look, I don't want to get into anymore trouble. So please don't talk to me.");
{
  if ( player.ActiveInventory = iBag); {
Display("I don't she'll miss this little thing.");
}
  if else { Display("She turns away from me to pout, like a child.);
    Display("I notice the small pouch close to the door, I was curious and rent was due.);
    Display("I took the thing, finding it was some kind of powder. Sleeping powder if I am not mistaken.");
cThrif.AddInventory(iBag);
  }
}

monkey0506

#1
I'll fix your indentation for you, because without it your code is an unreadable mess (I'll be an ass about that).

Code: ags
function cMystica_Interact()
{
  cThrif.Walk(166,166, eBlock, eWalkableAreas);
  player.Say("What are you in for?");
  cMystica.Say("That some kind of joke?");
  cMystica.Say("Why are you chatting when there's many guards here.");
  cMystica.Say("You know, the kind ready to catch you.");
  cPoo.Say("He's just being polite.");
  cMystica.Say("Is it normal for a rouge to chat up prisoners.");
  cThrif.Say("Yes.");
  cPoo.Say("Yeah.");
  cMystica.Say("Look, I don't want to get into anymore trouble. So please don't talk to me.");
  {
    if ( player.ActiveInventory = iBag);
    {
      Display("I don't she'll miss this little thing.");
    }
    if else
    {
      Display("She turns away from me to pout, like a child.);
      Display("I notice the small pouch close to the door, I was curious and rent was due.);
      Display("I took the thing, finding it was some kind of powder. Sleeping powder if I am not mistaken.");
      cThrif.AddInventory(iBag);
    }
  }


I also took the liberty of moving some of your braces, but only the one that was actually inconsistent with the rest.

Things to fix:

* You have unnecessary braces { and }.
* You are using the assignment operator, = in an if statement. AGS doesn't allow that, and it's not what you meant. The equality operator is ==.
* You have a semicolon at the end of your if statement, meaning that the block following it is not conditional.
* You transcribed "if" and "else". else if applies if you have a second condition to test when the first condition of an if statement fails. If you do not have a second condition to test, then you simply use else.
* You are missing closing quotation marks in the first two Display statements in your else block.
* Your code snippet is missing a closing brace, }, but that may be due to the use of extra, unnecessary braces.

Code: ags
function cMystica_Interact()
{
  cThrif.Walk(166,166, eBlock, eWalkableAreas);
  player.Say("What are you in for?");
  cMystica.Say("That some kind of joke?");
  cMystica.Say("Why are you chatting when there's many guards here.");
  cMystica.Say("You know, the kind ready to catch you.");
  cPoo.Say("He's just being polite.");
  cMystica.Say("Is it normal for a rouge to chat up prisoners.");
  cThrif.Say("Yes.");
  cPoo.Say("Yeah.");
  cMystica.Say("Look, I don't want to get into anymore trouble. So please don't talk to me.");
  if ( player.ActiveInventory == iBag)
  {
    Display("I don't she'll miss this little thing.");
  }
  else
  {
    Display("She turns away from me to pout, like a child.");
    Display("I notice the small pouch close to the door, I was curious and rent was due.");
    Display("I took the thing, finding it was some kind of powder. Sleeping powder if I am not mistaken.");
    cThrif.AddInventory(iBag);
  }
}

SMF spam blocked by CleanTalk