Ferc Kast Posted August 19, 2008 Share Posted August 19, 2008 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. Link to comment Share on other sites More sharing options...
Stream Posted August 19, 2008 Share Posted August 19, 2008 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 Link to comment Share on other sites More sharing options...
stoffe Posted August 19, 2008 Share Posted August 19, 2008 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, "[color=Yellow]Item_Tag[/color]"); 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.) Link to comment Share on other sites More sharing options...
Ferc Kast Posted August 19, 2008 Author Share Posted August 19, 2008 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. Link to comment Share on other sites More sharing options...
stoffe Posted August 20, 2008 Share Posted August 20, 2008 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("[color=Yellow]UTI filename[/color]", 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.) Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.