Jump to content

Home

Scripting question


Recommended Posts

I'm trying to plant a couple items in-game, and I'm having some trouble with the script. This is what I have:

 

void main()

{

float x=0.00f; //295.26.

float y=0.00f; //54.96.

float z=0.00f; //9.00.

float r=0.0f; // 1.

vector MyVec = Vector(x,y,z); //line 1

location MyLoc = lev_m40ad(MyVec, r); //line 2

object oLocker=CreateObject( OBJECT_TYPE_PLACEABLE, "footlker099", MyLoc); //line3

 

CreateItemOnObject("g_w_lghtsbr05", oLocker);

CreateItemOnObject("g_a_mstrrobe01", oLocker);

CreateItemOnObject("g_w_sbrcrstl04", oLocker, 2);

 

}

 

I was using RedHawke's tutorial for how to plant items in-game.

 

Thanks for any help. :D

Link to comment
Share on other sites

Do you mean that it should be like this?

 

void main()

{

float x=0.00f; //295.26.

float y=0.00f; //54.96.

float z=0.00f; //9.00.

float r=0.0f; // 1.

vector MyVec = Vector(x,y,z); //line 1

location MyLoc = lev_m40ad(MyVec, r); //location MyLoc = Location(MyVec, r);

object oLocker=CreateObject( OBJECT_TYPE_PLACEABLE, "footlker099", MyLoc); //line3

 

CreateItemOnObject("g_w_lghtsbr05", oLocker);

CreateItemOnObject("g_a_mstrrobe01", oLocker);

CreateItemOnObject("g_w_sbrcrstl04", oLocker, 2);

 

}

Link to comment
Share on other sites

What did you do to this line?

location MyLoc = lev_m40ad(MyVec, r); //line 2

It should not be touched the only things you need change are the coordinates and the placeable tag.

location MyLoc = Location(MyVec, r);     //line 2

You do not touch this line...

void main()
{
float x=295.26f; 
float y=54.96f; 
float z=9.00f; 
float r=1.0f; 
vector MyVec = Vector(x,y,z); //line 1
location MyLoc = Location(MyVec, r);     //line 2
object oLocker=CreateObject( OBJECT_TYPE_PLACEABLE, "footlker099", MyLoc); //line3

CreateItemOnObject("g_w_lghtsbr05", oLocker);
CreateItemOnObject("g_a_mstrrobe01", oLocker);
CreateItemOnObject("g_w_sbrcrstl04", oLocker, 2);

}

You code should look like this...

 

I hope this helps! :D

Link to comment
Share on other sites

Originally posted by Emperor Devon

But... How would this spawn? The script doesn't seem to mention that I want to spawn it on lev_m40ad (the Leviathan bridge).

 

The game only has one module loaded at a time, and in KotOR there is only one area per module. Thus scripts can only operate on the area the player currently is in. Your script can only spawn things in lev_m40ad if that is the currently active area. :)

 

The locations specify the coordinates and a facing for a spot within the currently loaded area.

Link to comment
Share on other sites

In toerh words, you have to attach your script somewhere in the area where you want to spawn your stuff. You can use the OnEnter event or you can attach the script to a .dlg file (make sure you chose a line that cannot be skipped). There are multiple other places where you can attach your scripts but these are the most commonly used.

 

And when you see // in a script, everything that is written at the right of the // will be ignored. It's used for comments.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...