Problem with templates

Started by Manuel_man991, Tue 03/01/2006 17:21:12

Previous topic - Next topic

Manuel_man991

Hi, i've a problem with a DOTT's template (and more template with scumm interface). If I open a template with ags 2.71 or 2.7, the ags say: ERROR:

function GoToCharacterEx(int charidwhogoes, int charidtogo, int direction, int xoffset, int yoffset, int NPCfacesplayer, int blocking){
  //Goes to a character staying at the side defined by 'direction': 1 up, 2 right, 3 down, 4 left
  //and it stays at xoffset or yofsset from the character. NPCfacesplayer self-explained. ;)
  // blocking: 0=non-blocking; 1=blocking; 2=semi-blocking.
  // returns 1 if player arrived.
  int playerchar,charidx,charidy,playerx,playery;
  if (charidwhogoes!=GetPlayerCharacter() && blocking==2) blocking=0;//npcs cant perform semi-blocking actions
  playerchar=charidwhogoes;
  charidx=character[charidtogo].x;
  charidy=character[charidtogo].y;
  playerx=character[playerchar].x;
  playery=character[playerchar].y;

The error is in first line, but this template works very good with AGS 2.62, but if i open with ags 2.7 o 2.71 the template doesn't work.

     Thanks.


Ashen

#1
What's the error message, exactly?

I think there's a problem in that template (in one of the templates, anyway) with one of the function imports (i.e. the line in the Script header) having a different number of parameters than when it's created (the code you pasted). Check if it's that, if not post back with the error message.
I know what you're thinking ... Don't think that.

Manuel_man991

This:

The problem was:
In: 'Global script'

Error: Function declaration has wrong number of argument of prototype.

Ashen

#3
Yeah, that's the one.

You should just need to find the line in the script header that imports GotToCharacterEx(....) and make sure that the bit between the brackets is exactly the same as in the function declaration (i.e. (int charidwhogoes, int charidtogo, int direction, int xoffset, int yoffset, int NPCfacesplayer, int blocking)).

(NOTE: If you have any more problems, you might want to have a look at the LEC GUI Help Thread. Can't promise it'll help, but it can't hurt.)
I know what you're thinking ... Don't think that.

Manuel_man991

Nothing. The error it follows there. Some idea?

strazer

??? Nothing what? Have you tried to fix it? What's wrong?

As Ashen said:

Quote from: strazer on Wed 21/12/2005 21:24:40
The error means that the function header in the global script, e.g.
  function GoToCharacterEx(int a, int b, int c) {
does not match the import statement in the script header, e.g.
  import function GoToCharacterEx(); // causes error because parameters are missing
instead of
  import function GoToCharacterEx(int a, int b, int c); // correct

The reason for the error is this (from the manual):
Quote from: Manual
Also, the script editor is now much better at checking your script for errors. You may well find that a script which compiled fine before no longer works on 2.7. Hopefully the error message should direct you towards fixing any problems.

Manuel_man991

thanks, strazer, but said: Expected {

strazer

Maybe missing semi-colon at the end?

// main script header
  import function GoToCharacterEx(int charidwhogoes, int charidtogo, int direction, int xoffset, int yoffset, int NPCfacesplayer, int blocking);

The error message gives you the script line where the error occurs. Please post the entire error message and some script from around that line.

Manuel_man991

The error is: Error line (598): Expected '{'

function MovePlayer(int x, int y){
  //Move the player character to x,y coords, waiting until he/she gets there, but allowing to cancel the action
  //by pressing a mouse button.
return MovePlayerEx(x,y,0);
}

function Abs(int value){
  //used by GoTo functions
  if (value<0) return -value;
  else return value;
}

function Offset(int point1, int point2){
  //used by GoTo functions
  return Abs(point1-point2);
}

function GoToCharacterEx(int charidwhogoes, int charidtogo, int direction, int xoffset, int yoffset, int NPCfacesplayer, int blocking);

  //Goes to a character staying at the side defined by 'direction': 1 up, 2 right, 3 down, 4 left
  //and it stays at xoffset or yofsset from the character. NPCfacesplayer self-explained. ;)
  // blocking: 0=non-blocking; 1=blocking; 2=semi-blocking.
  // returns 1 if player arrived.
  int playerchar,charidx,charidy,playerx,playery;
  if (charidwhogoes!=GetPlayerCharacter() && blocking==2) blocking=0;//npcs cant perform semi-blocking actions
  playerchar=charidwhogoes;
  charidx=character[charidtogo].x;
  charidy=character[charidtogo].y;
  playerx=character[playerchar].x;
  playery=character[playerchar].y;
      int arrived = 1;
      if ((Offset (playerx, charidx) > xoffset) || (Offset (playery, charidy) > yoffset)){
        if (direction==0){ // shortest way.
          if (Offset(charidx,playerx)>=Offset(charidy,playery)){ // left or right
            if (playerx>=charidx) direction=2; //right
            else direction=4; //left
          }
          else{
            if (playery>=charidy) direction=3; //down
            else direction=1;
          }
        }
        // calculate target position
        if (direction==1) charidy-=yoffset;
        else if (direction==2) charidx+=xoffset;
        else if (direction==3) charidy+=yoffset;
        else if (direction==4) charidx-=xoffset;
        // move character
        if (blocking==0){
          MoveCharacter(playerchar,charidx,charidy);
          arrived = 0;
        }
        else if (blocking==1){
          MoveCharacterBlocking(playerchar,charidx,charidy,0);
          arrived = 1;
        }
        else if (blocking==2) arrived = MovePlayer(charidx,charidy);
      }
      if (arrived > 0){
        // characters only face each other after the moving character arrived at the target point
        if (NPCfacesplayer==1)  FaceCharacter(charidtogo, playerchar);
        FaceCharacter(playerchar, charidtogo);
      }
      return arrived;

Colxfile

Try changing this:
Code: ags
function GoToCharacterEx(int charidwhogoes, int charidtogo, int direction, int xoffset, int yoffset, int NPCfacesplayer, int blocking);

to this:
Code: ags
function GoToCharacterEx(int charidwhogoes, int charidtogo, int direction, int xoffset, int yoffset, int NPCfacesplayer, int blocking) {


Change that semi-colon to a curly bracket :)
Always carry a UV marker pen with you. When you go to a shop or a friend's house, if you see something you like, put your name and postcode on it. If it gets stolen and subsequently recovered, the police will get in touch with you so that they can 'return' it.

Manuel_man991

ERROR line (598): Function declaration has wrong number of arguments to prototype.

Ashen

So we're back to the Script Header (Ctrl-H to open).
What's in there? (i.e. What parameters is GoToCharacterEx(...) imported with).
I know what you're thinking ... Don't think that.

Manuel_man991

REPAIRED!!
Other problem: ERROR: Type mismatch: cannot convert 'const string' to 'string'.

NOTE: The problem is:   DefineMode(      WALK,      "Walk to",   9,    0 );

game.dialog_options_y=1;
game.dialog_options_x=1;
game.items_per_line=3;
game.num_inv_displayed=6;
game.text_speed=10;
game.auto_use_walkto_points=0;
ResetModes();

GUIOff(MAPS);
SetTimer(19,1);
////////////////////// MODES SETUP ///////////////////////
//Normal modes:      MODE      "name"       AGS   Extension   
//                     cursor
//                     mode
  DefineMode(      WALK,      "Walk to",   9,    0 );
  DefineMode(      LOOK,      "Look at",   1,   'l');
  DefineMode(      TALK,      "Talk to",   3,   't');
  DefineMode(      PICKUP,      "Pick up",   5,   'p');
  DefineMode(      OPEN,      "Open",      8,   'o');
  DefineMode(      CLOSE,      "Close",   8,   'c');
  DefineMode(      PUSH,      "Push",      8,   's');
  DefineMode(      PULL,      "Pull",      8,   'y');

  DefineMode(      GIVECHRON,   "",      4,    0 );//special mode, do not set this mode manually, it is set in GiveInvChronOJohn function.

//Inventory modes:   MODE   "name"       Prepo-   Only   Can   Extension
//                  sition   inv.   interact
//                        w/ inv
  DefineInvMode(   USE,      "Use",      "with",   0,   1,   'u');
  DefineInvMode(   GIVE,      "Give",      "to",   1,   0,   'g');

//*Only inv:    Means that you can only use that mode followed by an inventory item:
//               USE has 0, because you can USE a hotspot also. However, you can't
//               GIVE a hotspot, you must GIVE an inv. item you already have, therefore
//      GIVE has 1.
//*Can interact   USE has 1, because you could have an inventory item like the
//    with inv:   "navigator's head" in Monkey Island 1, on which if you click 'USE item'
//      then the item performs some action, instead of putting 'USE item WITH'
//      and waiting for the player to select someting to USE the item WITH.
//      An interaction like "GIVE item" on its own, doesn't make sense,
//      (because you must GIVE something _TO someone_) so GIVE has 0.

  SetDefaultMode(WALK); //edit if you want, but dont delete.

Ashen

#13
I don't think that code is particularly relevant - DefineMode(WALK, "Walk to", 9, 0 ); is probably just showing up as the problem as it's the first time DefineMode() is called -  the problem is more likely to be where DefineMode is defined.

Are you using 2.71? The way strings are handled has been changed somewhat. In fact, string has been replaced with String (note capitalisation), and const string.
Long story short - if you're using 2.71, you need to find every function declaration that contains a string (Going on the template version I've got: DefineMode, DefineInvMode, ExtensionEx, RemoveExtension, Translation, ... possibly some I've missed) and change string to const string.

DISCLAIMER:
There may be further problems, though - the LEC style templates where never fully updated to 2.7 AFAIK, nevermind 2.71.
I know what you're thinking ... Don't think that.


subspark

#15
Listen, Manuel_man991,

Apart from being very vague with your explanation of your issue you failed to enlighten the rest of us exactly how you solved it.

Don't you think you could be a little more generous next time someone offers to help you. With all due respect, give a little back will ya buddy.
Some of us have the very same problems you were trying to explain in your first post.

EDIT: My apologies for sounding rather rash, Manuel_man991 but understand, it's about time EVERYBODY stop posting long vague chunks of code that dont provide any clue as to the problem and when it is solved, saying OH NEVER MIND FIXED IT. - Post end is just silly. I'm not pointing fingers to any particular induvidual but this kind of mentality is all too common amongst the forums and it's rather shortsighted and inconvenient. I hate bringing up old posts and asking "So how exactly DID you solve it?" At the end and posting new topics of the same problem just gets tireing for the moderators.

I hope my point is clear.
No worries. Just keep that in mind friend.

SMF spam blocked by CleanTalk