Author Topic: Expected (  (Read 385 times)  Share 

FamousAdventurer77

  • Rachel's too lazy to animate it.
    • I can help with play testing
    •  
    • I can help with proof reading
    •  
    • I can help with story design
    •  
    • I can help with translating
    •  
    • I can help with voice acting
    •  
Expected (
« on: 30 May 2011, 20:46 »
Nitpicky detail I'm missing, where would the parentheses go in here? I can't save the room because I keep getting Expected '(' for the oFruit.Visible line.

[code]
function hFruitTree_Interact()
{
  if oFruit.Visible = true; {
  Display("There is no need to climb the tree."); }
  else {
  Display("There is no need to climb the tree. Besides, there isn't any more ripe fruit to pick anyway.");
  }
}[/code]
« Last Edit: 30 May 2011, 21:55 by FamousAdventurer77 »
If you want to know the Bible's contents, just watch Lord of the Rings or listen to the last 8 Blind Guardian albums. It's pretty much the same thing.

Re: Expected (
« Reply #1 on: 30 May 2011, 21:00 »
[code]function hFruitTree_Interact()
{

  if (oFruit.Visible == true) Display("There is no need to climb the tree.");

  else {
  Display("There is no need to climb the tree. Besides, there isn't any more ripe fruit to pick anyway.");
  }
}[/code]

Try this. Also, make sure you use the right amount of equal signs:

= sets, == checks

For example:

[code]if (oFruit.Visible == true) Display("I'm checking whether Fruit is visible with two equal signs");


//player enter room, or whatever

oFruit.Visible = false; //Here I'm setting a variable because it's just one equal sign.[/code]

Notice also in my top code, you can shorten this

[code]if oFruit.Visible = true; {
  Display("There is no need to climb the tree."); }[/code]

into this

[code]if (oFruit.Visible = true) Display("There is no need to climb the tree.");[/code]

Because you don't need the extra { } if there's only one expression after the if statement.
« Last Edit: 30 May 2011, 21:02 by Atelier »

FamousAdventurer77

  • Rachel's too lazy to animate it.
    • I can help with play testing
    •  
    • I can help with proof reading
    •  
    • I can help with story design
    •  
    • I can help with translating
    •  
    • I can help with voice acting
    •  
Re: Expected (
« Reply #2 on: 30 May 2011, 21:22 »
Ah, that's what I was missing....I had a feeling it was more than just a misplaced (. Thanks!
If you want to know the Bible's contents, just watch Lord of the Rings or listen to the last 8 Blind Guardian albums. It's pretty much the same thing.

FamousAdventurer77

  • Rachel's too lazy to animate it.
    • I can help with play testing
    •  
    • I can help with proof reading
    •  
    • I can help with story design
    •  
    • I can help with translating
    •  
    • I can help with voice acting
    •  
Re: Expected (
« Reply #3 on: 30 May 2011, 21:39 »
Er, problem...using this

[code]
function hFruitTree_Interact() {
if (oFruit.Visible == true) Display ("There is no need to climb the tree.");
else {
Display("There is no need to climb the tree. Besides, there isn't any more ripe fruit to pick anyway."); }
}
[/code]

turns the object invisible even though I set it to visible initially.
If you want to know the Bible's contents, just watch Lord of the Rings or listen to the last 8 Blind Guardian albums. It's pretty much the same thing.

Khris

  • Evil Dark Emperor Death-Kill
    • Lifetime Achievement Award Winner
    •  
    • I can help with play testing
    •  
    • I can help with scripting
    •  
    • I can help with translating
    •  
Re: Expected (
« Reply #4 on: 30 May 2011, 22:54 »
No it doesn't.
The problem lies somewhere else.
http://whathaveyoutried.com/

The other day on yahoo answers:
"Can you print colored images with black ink? If so tell me how please Thanx Kimberly"

FamousAdventurer77

  • Rachel's too lazy to animate it.
    • I can help with play testing
    •  
    • I can help with proof reading
    •  
    • I can help with story design
    •  
    • I can help with translating
    •  
    • I can help with voice acting
    •  
Re: Expected (
« Reply #5 on: 31 May 2011, 02:05 »
I'm getting really confused now: I deleted that bit of code and replaced it with the old one (not the one I first posted, just a simple one-line Display message) and made sure that oFruit was initially visible in the Room's objects panel.

It still isn't when I run the test game. What went wrong...?  ???

[code]if (oFruit.Visible = true) Display("There is no need to climb the tree.");[/code]  I got a parse error when I tried this line.
If you want to know the Bible's contents, just watch Lord of the Rings or listen to the last 8 Blind Guardian albums. It's pretty much the same thing.

ddq

  • Let's talk mergers
  • ddq worked on a game that was nominated for an AGS Award!
Re: Expected (
« Reply #6 on: 31 May 2011, 02:24 »
Try this. Also, make sure you use the right amount of equal signs:

= sets, == checks

For example:

[code]if (oFruit.Visible == true) Display("I'm checking whether Fruit is visible with two equal signs");[/code]

You should probably read up on some tutorials for AGS or for C-like programming languages in general.
< uoou> help me obi wan kenobi, I'm stuck on angry birds
...
< uoou> domestic pigs are quite prone to anal prolapse

Calin Leafshade

  • AGS Project Admins
  • Long live King Cat!
    • I can help with AGS tutoring
    •  
    • I can help with voice acting
    •  
  • Calin Leafshade worked on a game that was nominated for an AGS Award!Calin Leafshade worked on a game that won an AGS Award!
Re: Expected (
« Reply #7 on: 31 May 2011, 02:27 »
This isnt even nearly finished but it might help:

http://svn.thethoughtradar.com/AGSScript101/

Leon: You need the sword first before you can get the monkey.

Khris

  • Evil Dark Emperor Death-Kill
    • Lifetime Achievement Award Winner
    •  
    • I can help with play testing
    •  
    • I can help with scripting
    •  
    • I can help with translating
    •  
Re: Expected (
« Reply #8 on: 31 May 2011, 02:56 »
If the object isn't visible, make sure you aren't turning it off somewhere else in the script.
It might also be off-screen or hidden behind a walkbehind.
http://whathaveyoutried.com/

The other day on yahoo answers:
"Can you print colored images with black ink? If so tell me how please Thanx Kimberly"

Re: Expected (
« Reply #9 on: 31 May 2011, 18:26 »
Try this. Also, make sure you use the right amount of equal signs:

= sets, == checks

For example:

[code]if (oFruit.Visible == true) Display("I'm checking whether Fruit is visible with two equal signs");[/code]

You should probably read up on some tutorials for AGS or for C-like programming languages in general.

Me or OP ???

Khris

  • Evil Dark Emperor Death-Kill
    • Lifetime Achievement Award Winner
    •  
    • I can help with play testing
    •  
    • I can help with scripting
    •  
    • I can help with translating
    •  
Re: Expected (
« Reply #10 on: 31 May 2011, 18:54 »
The OP of course, ddq was quoting you to show that you already corrected the mistake.
Seems like you edited your "==" to "=" though which is wrong.

Again, = sets the variable to the left to whatever the result of the right side is.
== is used to compare two values or Strings.
http://whathaveyoutried.com/

The other day on yahoo answers:
"Can you print colored images with black ink? If so tell me how please Thanx Kimberly"

FamousAdventurer77

  • Rachel's too lazy to animate it.
    • I can help with play testing
    •  
    • I can help with proof reading
    •  
    • I can help with story design
    •  
    • I can help with translating
    •  
    • I can help with voice acting
    •  
Re: Expected (
« Reply #11 on: 01 Jun 2011, 01:28 »
The culprit was a walk-behind, code works after I fixed it and plugged it back in.

Yep I could use a scripting lesson or two since I haven't done it in years, the video tutorials are pretty much the best I got right now since I tend to learn the best from being shown the basics by an actual person then figuring out the rest on my own (opposed to strictly out of a book.)

Calin- great link! Looks like the perfect thing for me to read up on.
If you want to know the Bible's contents, just watch Lord of the Rings or listen to the last 8 Blind Guardian albums. It's pretty much the same thing.

McMonsterBrothers

  • Herro!
    • I can help with AGS tutoring
    •  
    • I can help with play testing
    •  
    • I can help with proof reading
    •  
    • I can help with voice acting
    •  
Re: Expected (
« Reply #12 on: 01 Jun 2011, 07:15 »
I'm getting really confused now: I deleted that bit of code and replaced it with the old one (not the one I first posted, just a simple one-line Display message) and made sure that oFruit was initially visible in the Room's objects panel.

It still isn't when I run the test game. What went wrong...?  ???

[code]if (oFruit.Visible = true) Display("There is no need to climb the tree.");[/code]  I got a parse error when I tried this line.

i dont know if this helps but i think that you must put the {}'s in there like this:
[code]if (oFruit.Visible == true); {
 Display ("There is no need to climb the tree.");

}
[/code]

Iceboty V7000a

  • Local Moderator
  • * KILL* * KILL * * KILL *
    • Lifetime Achievement Award Winner
    •  
Re: Expected (
« Reply #13 on: 01 Jun 2011, 07:24 »
No, if there is a single line of code you don't need the braces (though adding them there wouldn't hurt).

Also, your line shouldn't work either, as you've added a semi-colon that shouldn't be there:

if (oFruit.Visible == true); {
  Display ("There is no need to climb the tree.");
}

McMonsterBrothers

  • Herro!
    • I can help with AGS tutoring
    •  
    • I can help with play testing
    •  
    • I can help with proof reading
    •  
    • I can help with voice acting
    •  
Re: Expected (
« Reply #14 on: 01 Jun 2011, 07:26 »
No, if there is a single line of code you don't need the braces (though adding them there wouldn't hurt).

Also, your line shouldn't work either, as you've added a semi-colon that shouldn't be there:

if (oFruit.Visible == true); {
  Display ("There is no need to climb the tree.");
}


oops my bad lol thanks dude  ;D