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.

Scripting a Base Item Check

Page: 1 of 1
 Silveredge9
02-05-2008, 2:54 PM
#1
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. :)
 Darkkender
02-05-2008, 4:10 PM
#2
The process used in the Korriban temple checks for a specific item by either TAG or Template. Most likely by template.
 stoffe
02-06-2008, 7:02 AM
#3
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);
}
}
 Silveredge9
02-09-2008, 8:45 AM
#4
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
Page: 1 of 1