Note: LucasForums Archive Project
The content here was reconstructed by scraping the Wayback Machine in an effort to restore some of what was lost when LF went down. The LucasForums Archive Project claims no ownership over the content or assets that were archived on archive.org.

This project is meant for research purposes only.

Script problem(s)...

Page: 1 of 1
 Ferc Kast
08-18-2008, 8:35 PM
#1
I'm trying to do a simple script to change the on-enter script of a module, but it doesn't seem to work.

void main() {
object oItem = GetObjectByTag("item_tag");
object oPC = GetFirstPC();
GiveItem(oItem, oPC);
AssignCommand(oPC, ActionEquipItem(oItem, 2, FALSE));
ExecuteScript("old_k_pend_area01", OBJECT_SELF);
}

1) The old on-enter script refuses to run after my new script begins.
2) The Item doesn't want to equip...

Any suggestions on how to fix this?

EDIT: If it helps to know what I'm trying to accomplish, I'll tell you. I'm trying to equip clothes on Revan when (s)/he is on the bed as the game starts.
 Stream
08-19-2008, 3:48 AM
#2
I think the reason why the old script wouldn't fire is because the name is too long, I'm sure I read somewhere that the name of a script can only be up to 16 characters long.

As for the item not equipping try this script;

void main() {
object oPC = GetFirstPC();
object oItem = GetObjectByTag("Item_Tag", 0);
ActionEquipItem(oItem, 1, 0);
ExecuteScript("2_k_pend_area01", OBJECT_SELF);
}

--Stream
 stoffe
08-19-2008, 5:26 AM
#3
I'm trying to do a simple script to change the on-enter script of a module, but it doesn't seem to work.

2) The Item doesn't want to equip...


You need to assign the equip action to the player, otherwise you're telling the module to equip the item onto itself. :) You also want to get the item possessed by the player rather than by tag, in case there happens to be more than one item with the same tag in the active area.

Also, if this is for the module's OnLoad script the player hasn't been spawned into the area yet when it is run. If it's the area's OnEnter script you need to check who is entering, since the script runs whenever any creature is spawned into the area (the player, other party members, NPCs etc). You probably also want to ensure it's only done once, or it would happen every time the player enters the area.


void main() {
object oEnter = GetEnteringObject();

if ((oEnter == GetFirstPC()) && !GetLocalBoolean(OBJECT_SELF, 2)) {
object oItem = GetItemPossessedBy(oEnter, "Item_Tag");
DelayCommand(0.5, AssignCommand(oEnter, ActionEquipItem(oItem, INVENTORY_SLOT_BODY, TRUE)));
SetLocalBoolean(OBJECT_SELF, 2, TRUE);
}

ExecuteScript("2_k_pend_area01", OBJECT_SELF);
}



(And as said above the names of scripts and other game resource files can't exceed 16 characters in length, which likely is why your renamed standard script won't be run.)
 Ferc Kast
08-19-2008, 7:52 AM
#4
The only problem is that the PC can't equip said item because (s)/he don't have it when they start the module. The old on-enter script now runs perfectly, though. :^:
 stoffe
08-20-2008, 4:57 AM
#5
The only problem is that the PC can't equip said item because (s)/he don't have it when they start the module.

You'll need to create the item on the player, then, then? Like:

void main() {
object oEnter = GetEnteringObject();

if ((oEnter == GetFirstPC()) && !GetLocalBoolean(OBJECT_SELF, 2)) {
object oItem = CreateItemOnObject("UTI filename", oEnter);
DelayCommand(0.5, AssignCommand(oEnter, ActionEquipItem(oItem, INVENTORY_SLOT_BODY, TRUE)));
SetLocalBoolean(OBJECT_SELF, 2, TRUE);
}

ExecuteScript("2_k_pend_area01", OBJECT_SELF);
}


(Replace UTI filename with the name of the UTI file containing the template for the item, without the .uti suffix.)
Page: 1 of 1