Aller au contenu

Photo

Check for partial tag name?


  • Veuillez vous connecter pour répondre
6 réponses à ce sujet

#1
Buddywarrior

Buddywarrior
  • Members
  • 256 messages
I need to remove from inventory any item (equiped or not) that has the beggining tag line of 'summoned_'

summoned_water
summoned_bandages

How can I check for partial tag name?

#2
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
object oItem = GetFirstItemInInventory (oPC);
while (GetIsObjectValid (oItem) )
{
if (GetStringLeft(GetTag (oItem),9) == "summoned_") DestroyObject (oItem);
oItem = GetNextItemInInventory(oPC);
}

#3
meaglyn

meaglyn
  • Members
  • 817 messages
Try something like

if (GetStringLeft(sTag, 9) == "summoned_") {
/remove it
}

where sTag is the tag of an item.

#4
GhostOfGod

GhostOfGod
  • Members
  • 863 messages
A simple example:

void main()
{
    object oItem; //however defined
    string sTag = GetTag(oItem);
    string sCheck = GetStringLeft(sTag, 8);

    if (sCheck == "summoned")
    {
        //destroy object
    }
}


Edit: Haha. looks like a few decided to answer at the same time. I'm a little late. :lol:

Modifié par GhostOfGod, 27 mars 2012 - 06:57 .


#5
Buddywarrior

Buddywarrior
  • Members
  • 256 messages
Thanks a ton guys. So glad that you guys still keep these forums alive. Still the best game to date imo.

Modifié par Buddywarrior, 28 mars 2012 - 01:29 .


#6
_Guile

_Guile
  • Members
  • 685 messages

GhostOfGod wrote...

A simple example:

void main()
{
    object oItem; //however defined
    string sTag = GetTag(oItem);
    string sCheck = GetStringLeft(sTag, 8);

    if (sCheck == "summoned")
    {
        //destroy object
    }
}


Edit: Haha. looks like a few decided to answer at the same time. I'm a little late. :lol:


Yes but your code is a complete script, which means you aren't lazy. :D

#7
meaglyn

meaglyn
  • Members
  • 817 messages
Heh, name calling already, you're just upset you didn't get to put your answer in at the same time as the rest of us ;)

And FWIW, GhostOfGod's script isn't really "complete" either, now is it?