Author Topic: Check for partial tag name?  (Read 348 times)

Legacy_Buddywarrior

  • Hero Member
  • *****
  • Posts: 512
  • Karma: +0/-0
Check for partial tag name?
« on: March 27, 2012, 06:54:12 pm »


               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?
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Check for partial tag name?
« Reply #1 on: March 27, 2012, 07:47:23 pm »


               object oItem = GetFirstItemInInventory (oPC);
while (GetIsObjectValid (oItem) )
      {
        if (GetStringLeft(GetTag (oItem),9) == "summoned_") DestroyObject  (oItem);            
        oItem = GetNextItemInInventory(oPC);
       }
               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
Check for partial tag name?
« Reply #2 on: March 27, 2012, 07:47:58 pm »


               Try something like

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

where sTag is the tag of an item.
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Check for partial tag name?
« Reply #3 on: March 27, 2012, 07:56:12 pm »


               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 .
                     
                  


            

Legacy_Buddywarrior

  • Hero Member
  • *****
  • Posts: 512
  • Karma: +0/-0
Check for partial tag name?
« Reply #4 on: March 28, 2012, 02:29:14 am »


               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 .
                     
                  


            

Legacy__Guile

  • Hero Member
  • *****
  • Posts: 1308
  • Karma: +0/-0
Check for partial tag name?
« Reply #5 on: March 30, 2012, 04:09:04 am »


               

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. '<img'>
               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
Check for partial tag name?
« Reply #6 on: March 30, 2012, 08:35:50 pm »


               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 '<img'>

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