I've been trying to create a conditional script that would perform an action when the right type of item has been added by the player to the inventory of the item the script is attached to. Like in one of the Korriban Tombs where you have to put a grenade into the Pillar.
Through my own research I've come up with the script below. It doesn't compile, but I feel it's at least close to what I'm wanting to acheive.
void main(){
int iBaseItem = "BASE_ITEM_FRAGMENTATION_GRENADES";
object oTran=GetObjectByTag("msp_tran1");
object oGrenade = GetFirstItemInInventory(oTran);
if (GetBaseItemType(oGrenade) == iBaseItem);
{
}
}
Thanks in advance for any help. :)
The process used in the Korriban temple checks for a specific item by either TAG or Template. Most likely by template.
I've been trying to create a conditional script that would perform an action when the right type of item has been added by the player to the inventory of the item the script is attached to. Like in one of the Korriban Tombs where you have to put a grenade into the Pillar.
Through my own research I've come up with the script below. It doesn't compile, but I feel it's at least close to what I'm wanting to acheive.
There are a few problems with your script. You try to assign a string constant to an integer variable, you only check the first item (which is usually enough but to be safe it's best to check all of them until a match is found), and you terminate the if statement check before the following block is executed. Try this variant of your script:
void main(){
if (GetLocalBoolean(OBJECT_SELF, 40))
return;
object oTran=GetObjectByTag("msp_tran1");
object oGrenade = GetFirstItemInInventory(oTran);
while (GetIsObjectValid(oGrenade)) {
if (GetBaseItemType(oGrenade) == BASE_ITEM_FRAGMENTATION_GRENADES) {
// ST: GRENADE! Do what is supposed to be done here.
SetLocalBoolean(OBJECT_SELF, 40, TRUE);
break;
}
oGrenade = GetNextItemInInventory(oTran);
}
}
Thanks, that pretty much worked.
And I was aware there was many many problems with my initial script, but I was right that it was something close to what I needed. :P