PDA

View Full Version : Problem with script


Mindtwistah
07-25-2007, 08:52 PM
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?

stoffe
07-25-2007, 09:00 PM
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)

Mindtwistah
07-25-2007, 09:07 PM
Strange... I got it from the Kotor script generator.. Someone should tell the author that a script is wrong.

But thanks Stoffe :P
A scripting genious as always :)

stoffe
07-25-2007, 09:09 PM
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. :)

Mindtwistah
08-03-2007, 12:36 PM
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? :(

stoffe
08-03-2007, 01:23 PM
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);
}

tk102
08-03-2007, 04:30 PM
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 negativeTalk about an obscure bug. Good tip stoffe.
I guess there is some merit in writing things out longhand.