Quick scripting help

Started by , Sat 13/11/2004 18:58:47

Previous topic - Next topic

Tuntis

What's wrong with this?

function dialog_request (int 1) {
if (value == 1)
{   
// Takes the reporters away.
    MoveCharacter(BBC,0,0);
    MoveCharacter(BBCTWO,0,0);
  }
The editor is saying this:
Error (line1) PE02: Parse error at "1".
If I remove the 1, it still says something of the dialog_request... Is it because of that I have one another dialog_request in the script?

TheJBurger

Here's your problem.

Where it says :
---------------
function dialog_request (int 1) {
---------------
The 1 should be a variable word such as, talk. So change the code to this.

function dialog_request (int talk) {
if (talk == 1)
   
// Takes the reporters away.
    MoveCharacter(BBC,0,0);
    MoveCharacter(BBCTWO,0,0);
  }

You can put any other word for the variable, talk is just an example.


Edwin Xie

#2
It is not "function dialog_request (int talk)", it is "function dialog_request (int parameter)
Moving at superhigh speed getting to the planet called Earth. But it is boxed in white......thing.....

Radiant

That's not actually true, you can name the parameter whatever you want.

If dialog_request is not defined, then you probably missed a closing brace in the preceding function. If not, look up what the error was exactly.

Edwin Xie

Meh, that was his problem. A closing brace.

function dialog_request (int 1) {
if (value == 1)
{   
// Takes the reporters away.
    MoveCharacter(BBC,0,0);
    MoveCharacter(BBCTWO,0,0);
  }
}//This is the closing brace for the function. You forgot it in your original script
Moving at superhigh speed getting to the planet called Earth. But it is boxed in white......thing.....

TheJBurger

Hmm... sorry for any confusion I caused before.

I think I see your problem right here, it's that you're replacing the wrong items with "talk."

Replace the first INT and VALUE with talk (or any other variable word). So your code should look like this.

function dialog_request (int word) {
if (word == 1)
// rest of code

Edwin Xie

#6
function dialog_request (int runscript) {
if (runscript == 1)
{Ã,  Ã, 
// Takes the reporters away.
Ã,  Ã,  MoveCharacter(BBC,0,0);
Ã,  Ã,  MoveCharacter(BBCTWO,0,0);
Ã,  }
}

Maybe this?
Translation:
If, in your dialog, you choose to run the script #1, it takes the reporters away.

Hmm, now I understand more about the AGS language.
Moving at superhigh speed getting to the planet called Earth. But it is boxed in white......thing.....

Ishmael

#7
If it still don't work, catch me on MSN later today, and I'll see what's wrong... this seems like one of those things again which AGS does not know how to report where the problem is...

----- EDIT -----

Quote from: Tuntis on Sat 13/11/2004 18:58:47Is it because of that I have one another dialog_request in the script?

Yes, could be. Nest all your run-scripts under one dialog_request:

function dialog_request (int data) {
  if (data == 1) {
    // code for run-script 1
  } else if (data == 2) {
    // code for run-script 2
  }
}

and so on...
I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

Ashen

So, like Ishmael says in the post just above yours,
QuoteNest all your run-scripts under one dialog_request

E.g.:
function dialog_request (int runscript) {
  if (runscript == 1) {   
// Takes the reporters away.
    MoveCharacter(BBC,0,0);
    MoveCharacter(BBCTWO,0,0);
  }

  if (runscript == 500) {
    SetGraphicalVariable("Fakestreet 13", 1);
  }
}

Then, any other run-script x commands get added in there as more if (runscript == x) conditions.
I know what you're thinking ... Don't think that.

Proskrito

#9
you cant have 2 different functions in the script with the same name, so you must merge the two functions into one, like:
function dialog_request (int runscript) {
if (runscript == 1)
 {   
// Takes the reporters away.
    MoveCharacter(BBC,0,0);
    MoveCharacter(BBCTWO,0,0);
  }
else if (runscript == 500)
  {
    SetGraphicalVariable("Fakestreet 13", 1);
  }
// more 'else if's for other values of runscript...
}


hope it helps : )

EDIT: d'oh! ashen was quicker : )

Ashen

If you've got the newest release of AGS (2.62), you can use NewRoomNPC (CHARID, ROOM, X, Y),
e.g.
if (runscript == 1) {   // Takes the reporters away.
  NewRoomNPC (BBC, -1, 0, 0);
  NewRoomNPC (BBCTWO, -1, 0, 0);
}

Otherwise, you'll have to change it manually,
e.g.
if (runscript == 1) {   // Takes the reporters away.
  character[BBC].room = -1;
  character[BBCTWO].room = -1;
}

But, I'd recommend NewRoomNPC (), so try that first.
If it doesn't work, you can download AGS v2.62 from here.
I know what you're thinking ... Don't think that.

SMF spam blocked by CleanTalk