Page 1 of 1

[ERROR] Incorrect # of parameters

Posted: Mon Apr 06, 2009 12:39 pm
by metal_head
Hey, I was wondering what could this mean:
[ERROR] Incorrect # of parameters in command 'DistanceBetweenEntities' in Script 'ObjectivePawn' Order 'execute'
I was trying to edit a script that Juutis and JAy helped me out for. It's for displaying a flipbook, which shows the direction of a pawn on the screen, I now want to make a text instead of a flipbook, but I got this problem, here's the script:

Code: Select all

{

   SCREENX       [0]
   SCREENY       [0]
   TEXT          [lol]

Spawn[ ()
{
   Console(true);
   LowLevel("execute");
} ]

execute[ ()
{
   ThinkTime = 0;

   if(GetEventState("objective1"))
   {
      SCREENX=GetEntityScreenX("ObjectivePawn");
      SCREENY=GetEntityScreenY("ObjectivePawn");
      TEXT=DistanceBetweenEntities("Player", "ObjectivePawn");
      ShowText(0, "", "", TEXT, 6, "", SCREENX, SCREENY, "", 200); 

   }

} ]

}
The script should get the distance between the player and the "ObjectivePawn" entity, which is the pawn, that holds the spcript, but instead of that, when I trigger the trigger "objective1" the game crashes.

Re: [ERROR] Incorrect # of parameters

Posted: Mon Apr 06, 2009 1:36 pm
by QuestOfDreams
There's a bug in the script command. It currently expects 3 parameters (whereas the manual also specifies a version with only 2 parameters). Workaround:
Instead of

Code: Select all

DistanceBetweenEntities("Player", "ObjectivePawn");
use

Code: Select all

DistanceBetweenEntities("Player", "ObjectivePawn", false);
Will be fixed in the next release.

Re: [ERROR] Incorrect # of parameters

Posted: Mon Apr 06, 2009 2:14 pm
by metal_head
Thanks QoD, now there are no errors!
Amm... I now wanna ask about this:

Code: Select all

ShowText(0, "", "", TEXT, 6, "", SCREENX, SCREENY, "", 200); 
Am I using the command correctly, because no text appears when I trigger the "objective1" trigger?

Re: [ERROR] Incorrect # of parameters

Posted: Tue Apr 07, 2009 4:25 pm
by QuestOfDreams
DistanceBetweenEntities returns a (floating point) number but TEXT should be a string. I suppose that's the problem. Try

Code: Select all

TEXT = toString(DistanceBetweenEntities("Player", "ObjectivePawn", false));
and make sure the font you're using is defined in the menu.ini file.

Re: [ERROR] Incorrect # of parameters

Posted: Tue Apr 07, 2009 7:20 pm
by metal_head
Thanks QoD, that helped! I didn't know that the variables can be converted to different types.
Just one more thing: How many texels equals one meter :lol: ? No, really, I need to know it so I can try to convert the texels to meters in the game. Is there something speciffic, or I'll have to let my imagination do it :D

Re: [ERROR] Incorrect # of parameters

Posted: Wed Apr 08, 2009 9:29 am
by QuestOfDreams
There is no fixed factor to convert level units to meters as this strongly depends on the scale of your actors.

Re: [ERROR] Incorrect # of parameters

Posted: Wed Apr 08, 2009 10:43 am
by metal_head
Oh yeah... I should have though of this in first place. THanks QoD, one more thing's done here!