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.

"check if has item" help ..

Page: 1 of 1
 Darth Essence
04-26-2007, 2:18 PM
#1
So ... I'm in deep trouble ... can't figure out how to check if a creature has item on it .. for example a blaster pistol .. and if has .. return TRUE. It's for TSL by the way .... :(
 tk102
04-26-2007, 3:16 PM
#2
If you're looking to determine whether the creature has an item equipped, you can you use the GetItemInSlot function. If you just want to check if the creature has an item in its inventory you can use the GetItemPossessedBy or GetItemPossessor functions.

Example:



// a dialog conditional script to determine
// if player has an item equipped as their
// right or left handed weapon
// where the Tag of the item is a string parameter


int StartingConditional() {
string sItem=GetScriptStringParameter();
object oPC=GetFirstPC();
object oRight = GetItemInSlot(INVENTORY_SLOT_RIGHTWEAPON, oPC);
if (GetIsObjectValid(oRight)) {
if (GetTag(oRight)==sItem) {
return TRUE;
}
}
object oLeft = GetItemInSlot(INVENTORY_SLOT_LEFTWEAPON, oPC);
if (GetIsObjectValid(oLeft)) {
if (GetTag(oLeft)==sItem) {
return TRUE;
}
}
return FALSE;
}

// a dialog conditional script to determine
// if the player has a particular item in their inventory
// where the Tag of the item is a string parameter

int StartingConditional() {
string sItem=GetScriptStringParameter();
object oPC=GetFirstPC();
object oItemPossessed = GetItemPossessedBy(oPC,sItem);
return GetIsObjectValid(oItemPossessed);
}
 Darth Essence
04-27-2007, 8:16 AM
#3
yes ... i saw this in many original scripts .. but i kinda cannot figure out the "GetScriptStringParameter();" thingy ... how does the script know which item i want if i don't even write its tag anywhere in the script ?
 stoffe
04-27-2007, 9:25 AM
#4
yes ... i saw this in many original scripts .. but i kinda cannot figure out the "GetScriptStringParameter();" thingy ... how does the script know which item i want if i don't even write its tag anywhere in the script ?

That function is used in action/conditional scripts fired from nodes in a DLG (conversation) file. There are a series of fields on each dialog node where you can set values the scripts can check for. The String Param field (in tk102's DLG editor) can be set to a value that GetScriptStringParameter() will be able to fetch into the script.

If your scripts are not for use in a DLG file it would be easier to help if you described how/where they would be used.
 Darth Essence
04-29-2007, 8:08 AM
#5
That is exactly what i needed .. thank you :)
Page: 1 of 1