PDA

View Full Version : (TSL) Script question


Malxados
05-31-2009, 06:01 PM
ugh, too long since I scripted from scratch... Anywho, could someone give me a script setting a global boolean, string, and warping you somewhere else?

Thanks,
Malxados

R2-X2
06-01-2009, 01:21 AM
Setting GLobal: (by glovemaster)

void main(){
SetGlobalNumber("MY_NEW_GLOBAL", Stage);
}

Star Admiral
06-01-2009, 11:40 AM
For booleans, just change the number to boolean, like in the following script:

void main() {
SetGlobalBoolean( string "MY_NEW_GLOBAL", int "STAGE" );
}

To warp to another module, where the last two parameters are optional:

void main() {
StartNewModule( string "MODULE_NAME", string "WAYPOINT_NAME", string "MOVIE_TO_PLAY" );
}

To warp to another location within the same module:

void main() {
ActionJumpToLocation( location "LOCATION_NAME" );
}

- Star Admiral

glovemaster
06-02-2009, 03:55 AM
I recommend using this script for warping to another vector in the same module. (You have X,Y & Z coordinates)
void main() {
object oJump = GetFirstPC();
// Presumably you want to jump the PC, otherwise replace this with:
// object oJump = GetObjectByTag("tag_of_npc");

vector vJump;
vJump.x = 0.0; // X Coord
vJump.y = 0.0; // Y Coord
vJump.z = 0.0; // Z Coord
float fFacing = 90.0; // 0 degrees is East, 90 is North and follows counter-clockwise respectively.
location lJump = Location(vJump, fFacing);

AssignCommand(oJump, ActionJumpToLocation(lJump));
}

Alternatively if you want to jump to a Waypoint (.utw template) you can use this.
void main() {
object oJump = GetFirstPC();
// Presumably you want to jump the PC, otherwise replace this with:
// object oJump = GetObjectByTag("tag_of_npc");
object oJumpto = GetWaypointByTag("tag_of_waypoint");

location lJump = GetLocation(oJumpto);

AssignCommand(oJump, ActionJumpToLocation(lJump));
}

Hope that helps. ;)

Star Admiral
06-02-2009, 10:41 AM
Yours is more detailed. Should have done the same for mine. Thanks glovemaster.

BTW, just for my own knowledge, we are allowed to assign commands to the PC with a script? I thought that the AssignCommand() function only works for NPCs.

- Star Admiral

glovemaster
06-02-2009, 10:47 AM
I'm pretty sure you can, considering the PC is used in some scripted dialogues; other than that, it's always worked for me.

stoffe
06-02-2009, 12:01 PM
BTW, just for my own knowledge, we are allowed to assign commands to the PC with a script? I thought that the AssignCommand() function only works for NPCs.

You can; though unless you do it in a cutscene or otherwise have locked out player controls any actions assigned to the player character could be overridden by the player if they clear or manipulate their action queue (the little box where attacks, feats and power uses to be performed are listed).

glovemaster
06-02-2009, 12:44 PM
You can; though unless you do it in a cutscene or otherwise have locked out player controls any actions assigned to the player character could be overridden by the player if they clear or manipulate their action queue (the little box where attacks, feats and power uses to be performed are listed).

Yes, I found that just moving clears the action queue - I'm unsure if there is any function to temporarily stop control of the PC short of NoClicks() which doesn't stop movement.

What I did was to stop the player from moving at the same time, off the top of my head I think it was EffectEntangle() or decreasing the PC's movement speed by 100%.

R2-X2
06-02-2009, 01:57 PM
You can stop the player by using

" ClearAllActions "

" ActionDoCommand(SetCommandable(FALSE,oNPC)); "

to make the PC unable to control " oNPC "and

" object oNPC=GetFirstPC; "

to varify oNPC.