Snippet: Destroy While Crafting

Amadeus

The Maestro
Staff member
Problem: While grinding up my Sage, I make a ton of Apprentice IV shit that isn't worth messing with.

Solution: This snippet basically runs in the background and any time an item is created, it checks to see if it contains the phrase "(Apprentice IV)" in it. If so, it destroys it.

Notes: This is pretty safe script as it comes. You can adjust this easily to destroy, move, or whatever you want particular items as they're created...simply modify the "ItemCreated" function to suit your needs.

Once you start this snippet in your scripts (which you should do before crafting), it will run until you unload isxeq2 or until you manually end the script.

Code:
function ItemCreated(string Line, string itemname)
{
   wait 8
   
   ;Destroy any item that has just been crafted that contains "(Apprentice IV)" in the name
   if (${itemname.Find[(Apprentice IV)]} > 0)
   {
      if ${Me.Inventory[${itemname}](exists)}
      {
         Me.Inventory[${itemname}]:Destroy
         echo ${itemname} created -> destroyed.
      }
   }
}
function main()
{
    AddTrigger ItemCreated "Announcement::You [EMAIL="created@*@:@itemname@\\\/a"]created@*@:@itemname@\\\/a[/EMAIL]."
    echo "Script [DestroyCrafted] now active."
    
    do
    {
       waitframe
       ExecuteQueued
    }
    while ${ISXEQ2(exists)}
    
    echo "Script [DestroyCrafted] ended."
    
}
 

utadaishot

Well-Known Member
Thank you, sir, this is exactly what I was looking for. I'm working on my tailoring and none of that nonsense stacks!
 

Sethric

Active Member
I can get this to work if I hardcode the item name into the script or if I use a one word name for the item.
I keep trying but, I haven't figured out how to get it to work with a multi part name.

run destroy Lead Bracelet
run destroy "Lead Bracelet"
run destroy "(Lead Bracelet)"

None of these work. What's the correct syntax supposed to be?
 

Kannkor

Ogre
I can get this to work if I hardcode the item name into the script or if I use a one word name for the item.
I keep trying but, I haven't figured out how to get it to work with a multi part name.

run destroy Lead Bracelet
run destroy "Lead Bracelet"
run destroy "(Lead Bracelet)"

None of these work. What's the correct syntax supposed to be?
Code:
function main()
As you can see, it does not accept any parameters.
So in all 3 of your examples are identical to "run destroy" with no parameters
 

Sethric

Active Member
oh geez! Now that you even suggest that there's something other than the answer I was expecting, I took another closer look at things I had not be focusing on, and for the first time I realized that the main function isn't the top one!
It never even occurred to me that you can do that.

Now, it's plain as day that he doesn't pass any params in the main, he has it hardcoded as well!

Thank you so much for helping me understand that.

I wanted to 'improve' it, to allow for passing a name, or, better yet, a 2 word item name when it's run.
Spent the past hour trying to do that without success tho.

But thanks very much for helping me see that I wasn't doing it wrong, it just don't do that.
 
Top Bottom