Jump to content

Home

Problem with script


Mindtwistah

Recommended Posts

When I compile this script:

 

#include "k_inc_debug"

#include "k_inc_utility"

 

void main()

{

float x = 46.27;

float y = 43.93;

float z = 1.80;

float r = 0.0;

 

vector vCre = Vector(x, y, z);

location lCre = Location(r, vCre);

 

object oCre = CreateObject(OBJECT_TYPE_CREATURE, "g_cheatbot", lCre);

 

ExecuteScript("k_pebo_skybox_old", OBJECT_SELF);

 

}

 

I get this errormessage:

 

k_pebo_skybox.nss(12): Error: Type mismatch in parameter 1 in call to "Location"

 

I am compiling with Kotor tool. The script is for K1. I named the script k_pebo_skybox

 

Can someone please tell me what's wrong?

Link to comment
Share on other sites

When I compile this script:

float r = 0.0;

vector vCre = Vector(x, y, z);

location lCre = Location(r, vCre);

I get this errormessage:

k_pebo_skybox.nss(12): Error: Type mismatch in parameter 1 in call to "Location"

Can someone please tell me what's wrong?

 

Just what the error message says: You are passing a value as parameter to Location() that isn't of the required type. You are trying to pass a float where a vector is required. I.e. you have the parameters in the wrong order, it should be Location(vCre, r);.

 

You also include two files you never use anything from, and have massive variable bloat for such a simple script, but that's technically not an error, it just makes the script bigger than necessary. :) You could just write the same script as:

void main() {
   CreateObject(OBJECT_TYPE_CREATURE, "g_cheatbot", Location([46.27, 43.93, 1.80], 0.0));
   ExecuteScript("k_pebo_skybox_old", OBJECT_SELF);
}

(This would be 127 bytes long when compiled to NCS, while yours would be 918 bytes, even though they do exactly the same thing. But that's just nitpicking. :p)

Link to comment
Share on other sites

Strange... I got it from the Kotor script generator.. Someone should tell the author that a script is wrong.

 

I wouldn't rely to heavily on the script generator. It works fine for some things, but it's still riddled with loads of bugs and inaccuracies. It may save some typing but you should still proof-read the scripts it creates just in case. :)

Link to comment
Share on other sites

  • 2 weeks later...

I tried this script for TSL:

 

void main() {

CreateObject(OBJECT_TYPE_CREATURE, "fake_zaalpup", Location([-10.93033, -62.05868, 11.21854], 0.0));

ExecuteScript("k_351_enter_old", OBJECT_SELF);

}

 

But I get this error message:

 

Error: Syntax error at "_"

 

Why doesn't it work? :(

Link to comment
Share on other sites

I tried this script for TSL:

Location([-10.93033, -62.05868, 11.21854], 0.0)

But I get this error message:

Error: Syntax error at "_"

Why doesn't it work? :(

 

The error is caused by the script compiler's (nwnnsscomp) inability to handle vector constants with negative coordinate values for some curious reason. You'll have to use the Vector() function instead to generate a vector if any of the coordinate values are negative. Like:

 

void main() {
   CreateObject(OBJECT_TYPE_CREATURE, "fake_zaalpup", Location(Vector(-10.93, -62.06, 11.22), 0.0));
   ExecuteScript("k_351_enter_old", OBJECT_SELF);
}

Link to comment
Share on other sites

The error is caused by the script compiler's (nwnnsscomp) inability to handle vector constants with negative coordinate values for some curious reason. You'll have to use the Vector() function instead to generate a vector if any of the coordinate values are negative
Talk about an obscure bug. Good tip stoffe.

I guess there is some merit in writing things out longhand.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...