Author Topic: Destroy Object w/GetStringLeft issues  (Read 316 times)

Legacy_Fester Pot

  • Hero Member
  • *****
  • Posts: 1698
  • Karma: +0/-0
Destroy Object w/GetStringLeft issues
« on: March 17, 2013, 04:54:25 am »


               Picked this off the Omnibus but it's not working. I'm looking to destroy any item in the inventory of the player that starts with "emma". So one item is tagged "emma512345", another "emma5345", etc. As the player finds torn diary pages, the OnAquired event fires, and removes the mentioned above tagged items with an updated diary book.

Rather than posting the entire OnAquire event, I've just included what I found posted by Jassper and inserted where I require it.


object oRemove = GetFirstItemInInventory(GetFirstPC());

        while(GetIsObjectValid(oRemove))
        {
        if(GetStringLowerCase(GetStringLeft(GetTag(oRemove),4)) == "emma")
        DestroyObject(oRemove);
        oRemove = GetNextItemInInventory();
        }

Everything before and after the loop works when the item is aquired, but the already existing tagged items in the inventory starting with "emma" are not destroyed.

No clue why.

Thanks,

FP!
               
               

               
            

Legacy_MagicalMaster

  • Hero Member
  • *****
  • Posts: 2712
  • Karma: +0/-0
Destroy Object w/GetStringLeft issues
« Reply #1 on: March 17, 2013, 05:07:01 am »


               Shouldn't

oRemove = GetNextItemInInventory();

be

oRemove = GetNextItemInInventory(GetFirstPC());
               
               

               
            

Legacy_Fester Pot

  • Hero Member
  • *****
  • Posts: 1698
  • Karma: +0/-0
Destroy Object w/GetStringLeft issues
« Reply #2 on: March 17, 2013, 05:29:16 am »


               After putting in some debug strings, the while loop does fire now.


object oRemove = GetFirstItemInInventory(GetFirstPC());

          //
        while(GetIsObjectValid(oRemove))
        {
        AssignCommand(oPC, SpeakString("DEBUG: I'M INSIDE THE WHILE!"));
        if(GetStringLowerCase(GetStringLeft(GetTag(oRemove),4)) == "emma")
        DestroyObject(oRemove);
       
        AssignCommand(oPC, SpeakString("DEBUG: I FOUND AN EMMA*.*"));
        oRemove = GetNextItemInInventory(GetFirstPC());
        }
        //


I'll keep this open for now as I need to do more testing just to make sure it's working 100%. I need sleep '<img'>

FP!
               
               

               


                     Modifié par Fester Pot, 17 mars 2013 - 05:40 .