What is going wrong with this script? SOLVED

Started by Eggie, Sun 27/01/2008 12:16:10

Previous topic - Next topic

Eggie

function TableExamination() {
  tableresponse = Random(4);
  if (tableresponse==0){
  cDom.Say("A table is a form of furniture composed of a surface supported by a base, usually four legs. ";
cDom.Say("It is often used to hold objects or food at a convenient or comfortable height when sitting.");
cDom.Say("Generic tables are typically meant for combined use with chairs. Unlike many earlier table designs, today's tables usually do not have drawers.");
cDom.Say("A table specifically intended for working is a desk.");
cDom.Say("Some tables have hinged extensions of the table top called drop leaves, while others can be extended with removable sections called leaves.");
cDom.Say("I'm so glad I looked that up.");
} if (tableresponse==1){
  cDom.Say("Table, Table, Table. I made you out of...");
  cDom.Say("...Wood.");
  } if (tableresponse==2){
    cDom.Say("I see this table uses Orwellian design principles.");
    cDom.Say("Four legs good. Two legs fucking stupid.");
    } if (tableresponse==3){
      cDom.Say("I encounter tables periodically.");   //line 69
      } if (tableresponse==4){
        cDom.Say("It's a table, must be a truth table.");
        cDom.Say("Because...tables don't lie...because...");
        cDom.Say("Okay... William Miracle's not allowed to write any more dialouge for this game.");
        }
}

What's wrong with this script? It's driving me crazy...I've been through it over and over and I just can't see it.

The error is:
GlobalScript.asc(69): Error (line 69): buffer exceeded: you probably have a missing closing bracket on a previous line

OneDollar

#1
Missing a closing bracket on the end of the
cDom.Say("A table is a form of furniture composed of a surface supported by a base, usually four legs. ";
line.

Edit: And do you need }else if{ instead of just }if{?

Edit again: No, you probably don't actually


paolo

#3
A couple of tips for future reference when writing code and posting it here that will make it easier to read and help people to help you. (Apologies in advance if you already know this.)

* Use the "code" tags [ code] and [ /code] around any code you post to the forum (without the spaces after the "["s).

* Indent your code correctly. Indent by an extra tab (or a fixed number of spaces) after an opening brace ("{") and come back by one tab on the line with the closing brace, like this:

Code: ags

a_function()
{ //open brace on the line *after* the function name
	some code inside braces
	some more code inside braces
} //close brace that lines up with open brace


AGS tries to do this for you, but often gets in a mess (in v2.71, at least).

* Line up the closing brace with the corresponding opening brace. AGS does not do this.

* Don't put more than one statement on a line.

In this case, it's not the braces but the round brackets. The problem is that you've forgotten to close the bracket in this line:

Code: ags

cDom.Say("A table is a form of furniture composed of a surface supported by a base, usually four legs. ";


There should be a closing bracket before the semicolon. The error comes out at line 69 rather than on this line because the parser keeps on going, looking for the close bracket, and eventually runs out of buffer space several lines later.

Dualnames

The script looks that it should be working. Telling us what version of AGS you're using could help us out(unless you already said it and i missed it)..

Wondering:
is tableresponse correctly declared?
There's no line in that script that declares it.

But that would get you a msg like undefined whatevery.
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

SMF spam blocked by CleanTalk