Darth_HaHa Posted December 9, 2007 Share Posted December 9, 2007 Okay, I'm pretty much a complete noob at modding. Scripting is the hardest part for me, and I'm trying to figure it out! So I wrote this script for K1 and each time I try to compile it, I get a "Syntax Error at 'string constant' " on lines 15 and 17 Here's my script using a recruited Darth Bandon as an example: void main() { object oEntering = GetEnteringObject(); object oPC=GetFirstPC(); if (GetIsPC(oEntering)) GiveXPToCreature(GetFirstPC(), 2500); AddMultiClass(3, GetObjectByTag("p_bandon")); object me = GetFirstPC(); CreateItemOnObject("g_a_mstrrobe01", me); CreateItemOnObject("g_w_lghtsbr03", me); CreateItemOnObject("g_w_dblsbr003", me); AssignCommand (GetFirstPC(), ActionEquipItem (o"g_a_mstrrobe01", nINVENTORY_SLOT_BODY=1); AssignCommand (GetFirstPC(), ActionEquipItem (o"g_w_dblsbr003", nINVENTORY_SLOT_LEFTWEAPON=5); } Can anyone help me fix this? Link to comment Share on other sites More sharing options...
Darth InSidious Posted December 10, 2007 Share Posted December 10, 2007 Try this: void main() { object oEntering = GetEnteringObject(); object oPC=GetFirstPC(); if (GetIsPC(oEntering)) GiveXPToCreature(GetFirstPC(), 2500); AddMultiClass(3, GetObjectByTag("p_bandon")); object me = GetFirstPC(); CreateItemOnObject("g_a_mstrrobe01", me); CreateItemOnObject("g_w_lghtsbr03", me); CreateItemOnObject("g_w_dblsbr003", me); AssignCommand(GetFirstPC(), ActionEquipItem("g_a_mstrrobe01", nINVENTORY_SLOT_BODY=1); AssignCommand(GetFirstPC(), ActionEquipItem("g_w_dblsbr003", nINVENTORY_SLOT_LEFTWEAPON=5); } Hope that helps. Link to comment Share on other sites More sharing options...
DarthJebus05 Posted December 10, 2007 Share Posted December 10, 2007 Will that script work for the Janitor on Taris? Link to comment Share on other sites More sharing options...
Darth InSidious Posted December 10, 2007 Share Posted December 10, 2007 Provided you changed the tag in the GetObjectByTag() function call, it should do. Link to comment Share on other sites More sharing options...
DarthJebus05 Posted December 10, 2007 Share Posted December 10, 2007 Cool. Every time I tried to make the Janitor recruitable, he just wont join my party. Would I be able to use your script, Darth_HaHa? And of course if I use it for my mod, you will get full credit for it. Link to comment Share on other sites More sharing options...
stoffe Posted December 10, 2007 Share Posted December 10, 2007 So I wrote this script for K1 and each time I try to compile it, I get a "Syntax Error at 'string constant' " on lines 15 and 17 The problem on those lines are that you are providing an undeclared variable followed by a string constant where the script expects an object reference, and are assigning a value to an undeclared variable where it expects an integer value to be provided. You are also missing closing parenthesises for your AssignCommand() function calls. Further, the if (GetIsPC(oEntering)) line only affects the next statement directly following it (the one giving XP), making the rest of the script run regardless whether the object triggering the OnEnter event (which I assume you run yoru script from) is the player or someone else since you have no block delimiters. Finally, it seems like you're trying to equip a two-handed weapon in the off-hand weapon slot, whereas twohanded weapons only can be wielded in the right hand weapon slot. Here is an example variant of your script with those problems fixed. void main() { object oPC = GetFirstPC(); if (oPC == GetEnteringObject()) { GiveXPToCreature(oPC, 2500); AddMultiClass(CLASS_TYPE_JEDIGUARDIAN, GetObjectByTag("p_bandon")); CreateItemOnObject("g_w_lghtsbr03", oPC); AssignCommand(oPC, ActionEquipItem( CreateItemOnObject("g_a_mstrrobe01", oPC), INVENTORY_SLOT_BODY)); AssignCommand(oPC, ActionEquipItem( CreateItemOnObject("g_w_dblsbr003", oPC), INVENTORY_SLOT_RIGHTWEAPON)); } } Depending on where the script is run from you may also need to add some cutoff condition to ensure it is only run once, otherwise the XP and items will be given any time the player triggers the OnEnter event of the object this script is assigned to. Link to comment Share on other sites More sharing options...
Darth Xander Posted December 10, 2007 Share Posted December 10, 2007 Could someone explain to me what GetEnteringObject does? Oh and welcome to LucasForums Darth_HaHa. Link to comment Share on other sites More sharing options...
stoffe Posted December 10, 2007 Share Posted December 10, 2007 Could someone explain to me what GetEnteringObject does? When used in a script triggered from an OnEnter event (belonging to an object such as an area, persistent AoE or a trigger), it returns an object reference to the player or NPC who was responsible for triggering the event. In the case of an area's OnEnter event, it triggers every time the player transitions into an area, loads a savegame into an area or an NPC or party member is spawned into the area. So for example if you transition into an area with Bastila and Carth in the party, that area's OnEnter event script is triggered three times, where the GetEnteringObject() function returns an object reference to the player character, Carth and Bastila respectively. This is why you often check if the entering object is the player in Area OnEnter scripts when you only want something done once when the player enters. (If, for example, you spawn an NPC into the area in the Area OnEnter script and have no checks for who is entering the area would be flooded with copies of that NPC. This is since spawning the NPC triggers the area's OnEnter script for that NPC, which in turn would spawn another NPC, triggering the script again etc.) In the case of a persistent AoE or a trigger the script runs whenever an player or NPC moves into the "hot zone" of the trigger/AoE and the function returns an object reference to the player/npc in question. It shouldn't be used in scripts which aren't run by an OnEnter event, since the return value will be unreliable/invalid. Link to comment Share on other sites More sharing options...
Darth_HaHa Posted December 10, 2007 Author Share Posted December 10, 2007 Thanks! I'll try it out and see if it works! Link to comment Share on other sites More sharing options...
Darth_HaHa Posted December 10, 2007 Author Share Posted December 10, 2007 And go right ahead DarthJebus05. Of course, you might not want to use mine.... Give the other guys credit for the script. They wrote it! Thanks again everyone! Link to comment Share on other sites More sharing options...
Qui-Gon Glenn Posted December 12, 2007 Share Posted December 12, 2007 Give the other guys credit for the script. They wrote it! Thanks again everyone! You gave it a real good shot though. You deserve a mention at least Back to studying the Lexicon.... Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.