PDA

View Full Version : "check if has item" help ..


Darth Essence
04-26-2007, 02:18 PM
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, 03:16 PM
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, 08:16 AM
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, 09:25 AM
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, 08:08 AM
That is exactly what i needed .. thank you :)