PDA

View Full Version : Scripting help


Darth Cryptic
04-01-2009, 08:30 PM
I'm trying to script something into the game and I'm having a lot of trouble. I want to spawn a Sith monument in one of the small rooms in the Hidden Tomb, in which two items can be retrieved. For now I'm just worrying about getting the monument in place

I have the following information from the WheramI arm band
Beginning whereami output
Module: 711kor
> 56.24788
> 4.06831
> 9.87598
> Xorientation: -0.94244
> Yorientation: 0.33438
> Bearing: 2.80065


Not sure if i need the rest of the whereami, if i do I'll add it later.

I followed Redhawke's scripting for dummies tutorial, and ended up with the following:


void main()
{
float x=4.06831
float y=9.87598
float z=-0.94244
float r=0.33438
vector MyVec=(4.06831,9.87598,-0.94244);
location MyLoc=Location(MyVec,0.33438);
object osithmonument=CreateObject(sithmonument05, MyLoc);
}


When I try opening text editor in the K Tool, I get the following error message:

An unhandled exception has occurred in your application. if you click Continue, the application will ignore the error and attempt to continue.

Could not find file "C\Program Files\LucasArts\SWKotOR2\override\nwscript.nss".


Plug in the script and hit the Compile button, end up with:

Lookup path root set to: C:\Program Files\LucasArts\SWKotOR2\
Loaded nwscript.nss via key file lookup
Compiling Lanoblsk.nss
lanoblsk.nss(4): Error: Syntax error at "Float"
lanoblsk.nss(11): Error: Syntax error at }
Compilation aborted with errors
Total Execution time=41 ms


So... where am I going wrong?

zbyl2
04-02-2009, 03:42 AM
I'll explain one by one:
In script, you must put ";" after every single line of code (okay, there are some exception when using "if" and stuff like that. but in most of cases, you need this ";")
You didn't put it in first few lines, what gave you error. Proper version should look like this:
float x=4.06831;
float y=9.87598;
float z=-0.94244;
float r=0.33438;


Next, you didn't specify what MyVec is. Putting coordinates is not enough, you must also use proper function on there. In this case, it would be vector.
vector MyVec=Vector(4.06831,9.87598,-0.94244);

At least, in CreateObject() line you must "inform" the game what you're spawning - creature, placeable? Whatever. Also, ResRef of your item should be put between quotes marks.
object osithmonument=CreateObject(OBJECT_TYPE_PLACEABLE, "sithmonument05", MyLoc);

And we're getting this: void main()
{
float x=4.06831;
float y=9.87598;
float z=-0.94244;
float r=0.33438;
vector MyVec=Vector(4.06831,9.87598,-0.94244);
location MyLoc=Location(MyVec,0.33438);
object osithmonument=CreateObject(OBJECT_TYPE_PLACEABLE, "sithmonument05", MyLoc);
}

Hope that helps :)

Darth Cryptic
04-02-2009, 09:39 AM
Thank you, zbyl2 it does. The ";" I saw after I typed up the posted version. The rest I wasn't sure if it was just explanation info or if it was needed.