function region1_WalksOnto()
{
if player.ActiveInventory(iMedallion);
player.ChangeRoom(11);{
}
else player.Say("I feel drawn to something in this room")
player.Say("I really want to find out what it is");
I have this code and I keep getting this error message:
room9.asc(87): Error (line 87): expected '('
I've tried for the past few hours to fix this, but I can't, could someone please explain to me why I'm an idiot?
you should put
function region1_WalksOnto()
{
if (player.ActiveInventory==iMedallion){
player.ChangeRoom(11);
}
else {player.Say("I feel drawn to something in this room");
player.Say("I really want to find out what it is");
}
}
After an "if (condition)" you don't put a semicolon but either a single command or several encased in { and }.
The condition must be encased in ( and ) (the reason for the error you got), and player.ActiveInventory isn't a function but a pointer pointing to an inventory item.
None of you use indentation so here's how it is supposed to look:
function region1_WalksOnto()
{
if (player.ActiveInventory == iMedallion)
{
player.ChangeRoom(11);
}
else
{
player.Say("I feel drawn to something in this room");
player.Say("I really want to find out what it is");
}
}
Now you can immediately see what the function body is and what's going to happen depending on the if condition.
I'd suggest to start using indentation now, your original code looked like you were merely guessing at where to put which bracket, so seeing the underlying structure should definitely help.
AGS will also do all the indenting automatically if you hit enter after { or }.
Like I said, the brackets around "player.ChangeRoom(11);" are optional since they contain only one command.
The most important thing though is to get the syntax straight.
check out Densming's video's on youtube, they are very helpful for beginners.
just type in...How to use ags part 1, there are forty something videos, they are light years old but still do the trick.
seems like you are confusing Addinventory with Activeinventory
check out video...how to use ags part 27, that will show you the problem you are having
function region1_WalksOnto()
{
if (player.ActiveInventory == iMedallion) {
player.ChangeRoom(11);
}
else {
player.Say("I feel drawn to something in this room");
player.Say("I really want to find out what it is");
}
}
If you indent you code, you don't run into bracket problems that fast.
Argh, Khris... you're too fast for me!
Abstauber, you still got the ActiveInventory part wrong ;)
Haha, damn ;D
me fixes.
okay what i'm trying to do is if the player has iMedallion in their inventory, then region1 takes them to room 8, but this just runs the same dialog every time i go on it and doesn't take me to room 8, and when the dialog runs background 0 and 1 keep alternating.
I can probably fix the background problem my self but could anyone help me with inventory thing? I blame myself for not explaining to you guys what I was hoping to do.
Switching
if (player.ActiveInventory == iMedallion) {
to
if (player.HasInventory(iMedallion) ) {
should do the trick.
function Button5_OnClick(GUIControl *control, MouseButton button)
{
gSaveGame.Visible = true;
{
if gSaveGame.Visible = true {
gIconbar.Visible = false;
}
}
GlobalScript.asc(600): Error (line 600): expected '('
help please you guys
A condition must be enclosed by (and). Also, in a condition you need to change = to ==.
if (gSaveGame.Visible == true)
Also, you can shorten the whole thing to this:
if (gSaveGame.Visible) gIconbar.Visible = false;
EDIT: You don't even need the condition because the GUI is visible in any case:
function Button5_OnClick(GUIControl *control, MouseButton button)
{
gSaveGame.Visible = true;
gIconbar.Visible = false;
}
function Button5_OnClick(GUIControl *control, MouseButton button)
{
gSaveGame.Visible = true;
if (gSaveGame.Visible)
{
gIconbar.Visible = false;
}
}
Not sure what you're doing there; this code will give the same result:
function Button5_OnClick(GUIControl *control, MouseButton button)
{
gSaveGame.Visible = true;
gIconbar.Visible = false;
}
You're turning gSaveGame visible so of course it's going to be visible one line down in the code.
I suspect what you're trying to do is to turn off gIconbar
whenever gSaveGame is visible, right?
You do things like that in repeatedly_execute.
Also please read what we wrote earlier:
QuoteThe condition must be encased in ( and ) (the reason for the error you got)