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.
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.");
}
}
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.");
}
}
Try this. Also, make sure you use the right amount of equal signs:
= sets, == checks
For example:
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.
Notice also in my top code, you can shorten this
if oFruit.Visible = true; {
Display("There is no need to climb the tree."); }
into this
if (oFruit.Visible = true) Display("There is no need to climb the tree.");
Because you don't need the extra { } if there's only one expression after the if statement.
Ah, that's what I was missing....I had a feeling it was more than just a misplaced (. Thanks!
Er, problem...using this
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."); }
}
turns the object invisible even though I set it to visible initially.
No it doesn't.
The problem lies somewhere else.
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...? ???
if (oFruit.Visible = true) Display("There is no need to climb the tree.");
I got a parse error when I tried this line.
Quote from: Atelier on Mon 30/05/2011 21:00:12
Try this. Also, make sure you use the right amount of equal signs:
= sets, == checks
For example:
if (oFruit.Visible == true) Display("I'm checking whether Fruit is visible with two equal signs");
You should probably read up on some tutorials for AGS or for C-like programming languages in general.
This isnt even nearly finished but it might help:
http://svn.thethoughtradar.com/AGSScript101/
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.
Quote from: ddq on Tue 31/05/2011 02:24:58
Quote from: Atelier on Mon 30/05/2011 21:00:12
Try this. Also, make sure you use the right amount of equal signs:
= sets, == checks
For example:
if (oFruit.Visible == true) Display("I'm checking whether Fruit is visible with two equal signs");
You should probably read up on some tutorials for AGS or for C-like programming languages in general.
Me or OP ???
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.
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.
Quote from: FamousAdventurer77 on Tue 31/05/2011 02:05:48
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...? ???
if (oFruit.Visible = true) Display("There is no need to climb the tree.");
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:
if (oFruit.Visible == true); {
Display ("There is no need to climb the tree.");
}
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.");
}
Quote from: Iceboty V7000a on Wed 01/06/2011 07:24:20
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