General Loot problem with commas in name
Reply
Loot problem with commas in name
I am having an issue where items with commas in the name break my macro. I sort of understand why it is doing it, I just don't know how to fix it. I know the loot coding is ugly and it is a combination of a couple public macros I found. It looks at an ini file to determine whether or not to delete items as it loots them.

This is the loot snippet I am using.
Macro
More +
/loot
   /delay 1s
   /for x 1 to 4
      /itemnotify loot${x} leftmouseup
|      /if !(${Cursor.ID}) /goto :EndLoot
      /delay 3
      /nomodkey   /notify QuantityWnd QTYW_Accept_Button leftmouseup  
      /delay 2
      /nomodkey   /notify ConfirmationDialogBox Yes_Button leftmouseup  
      /delay 1s
      /if (!${Ini[forage.ini,ForageList,${Cursor.Name}].Length}) {
         /ini "Forage.ini" "ForageList" "${Cursor.Name}" "-1"
      } else {
      /if (${Ini[forage.ini,ForageList,${Cursor.Name}]}) {
         /if (${FindItemCount["=${Cursor.Name}"]}>=${Ini[forage.ini,ForageList,${Cursor.Name}]} && ${Ini[forage.ini,ForageList,${Cursor.Name}]}!=-1) /goto :Destroy
      } else {
         :Destroy
         /echo Destroying ${Cursor.Name}
         /destroy
         /next x
         }
      }
      :LootIt
      /echo Keeping ${Cursor.Name}
      /autoinventory
      /if (${Cursor.ID}) /goto :LootIt
   }
   /next x
   /notify LootWnd DoneButton leftmouseup


In the mq2 window I see this debug text when it fails.
Unparseable in Calculation: 't'
macro.mac@100 (Combat) /if (${Ini[forage.ini,ForageList,${Cursor.Name}]}) {
macro.mac@30 (Main): /call Combat
The current macro has ended.
Failed to parse /if condition '(the Master's Burden)', non-numeric encountered.

This was when I was trying to loot the item "Dometrius, the Master's Burden"

I know the comma in the item name is messing it up but I just can't think of how to fix it.
Thu Jun 13, 2013 6:36 am
First of all, I wouldn't use a loot macro that loots everything and checks Forage.ini. I can see bad things happening.

You should be checking items while they are still on the corpse to decide whether or not to loot it or leave or destroy it.

macro.mac@100 (Combat) /if (${Ini[forage.ini,ForageList,${Cursor.Name}]}) {
macro.mac@30 (Main): /call Combat
The current macro has ended.
Failed to parse /if condition '(the Master's Burden)', non-numeric encountered.


MQ2 sees this command:
/if (${Ini[forage.ini,ForageList,Dometrius, the Master's Burden]}) {

The ${Ini} TLO has a specific format. Ini[filename,section,key,default]

A comma in the item name will cause the default section to be input (it's option) and the key to be incorrect. The ${Ini} TLO simply does not work properly if the item name has a comma in it. Looks like you already know this (see below) but this is a reminder to others.

I know the comma in the item name is messing it up but I just can't think of how to fix it.


Quick fix attempt: put quotes around ${Cursor.Name}. Quotes can be used to include spaces when spaces (and the contents after a space) are normally dropped. I don't think this will work, but it's easy to try.

Longer fix attempt:
Strip commas from the item name and use the comma free name with the ${Ini} command.
Thu Jun 13, 2013 4:51 pm
Senior Project Member
Macro
More +
/declare CommaFreeItemName string local
/if (${Cursor.Name.Find[,]}) {
        | hope the item only has 1 comma or else this will also break the macro - you'll need a custom, recursive subroutine in that case
        /varset CommaFreeItemName ${Cursor.Name.Arg[1,,]}${Cursor.Name.Arg[2,,]}
} else {
        /varset CommaFreeItemName ${Cursor.Name}
}
/if (!${Ini[forage.ini,ForageList,${CommaFreeItemName}].Length}) {
        /ini "Forage.ini" "ForageList" "${CommaFreeItemName}" "-1"
} else {
        /if (${Ini[forage.ini,ForageList,${CommaFreeItemName}]}) {
                /if (${FindItemCount["=${CommaFreeItemName}"]} >= ${Ini[forage.ini,ForageList,${CommaFreeItemName}]} && ${Ini[forage.ini,ForageList,${CommaFreeItemName}]}!= -1) /goto :Destroy
        } else {
                :Destroy
                /echo Destroying ${CommaFreeItemName}
                /destroy
                /next x
        }
|
Thu Jun 13, 2013 5:09 pm
Senior Project Member
Thanks a ton. I played with the code a bit and got it to work.
Thu Jun 13, 2013 7:22 pm
General Loot problem with commas in name
Reply