- Joined
- Feb 6, 2007
- RedCents
- 1,683¢
I found this macro somewhere and liked that I could limit the number of items I kept, excpet that it didn't work. It either kept the item or destroyed it if the ini file was set to zero. I found the problem in the itemcount command. Here is my corrected version. I also added to the echo command to show how many of the item was on hand and the total to keep.
Rich (BB code):
|yafm.mac
|
|Yet Another Forage Macro
|
|Ini File: yafm.ini
|
| 0 = destroy
| x = keep at most x of this item
|
|New foraged items are added to the ini file automatically and are kept by default.
||||||||||||||||||||
| Main
||||||||||||||||||||
sub Main
/echo forage macro started
/declare DefaultMaxSave int outer
/varset DefaultMaxSave ${Ini[yafm.ini,Default,MaxSave,${NotFound}]}
/if (${DefaultMaxSave}==${NotFound}) {
/ini "yafm.ini" "Default" "MaxSave" "100"
/varset DefaultMaxSave 100
}
/delay 1
| Verify that we have the ability to forage.
/if (${Me.Skill[Forage]}==0) {
/echo You cannot forage, silly person!
/goto :Exit
}
:Forage
| If we can forage then do so.
/if (${Me.AbilityReady[Forage]}) {
| Stand up. Can't forage while sitting.
/if (${Me.State.NotEqual[STAND]}) {
/stand
/delay 5
}
/doability forage
}
| If we successfully foraged something then take care of it.
/if (${Cursor.ID}) {
/call HandleItem
}
/goto :Forage
:Exit
/return
||||||||||||||||||||
| HandleItem
||||||||||||||||||||
sub HandleItem
/declare ItemSetting int local
/declare NotFound int local
/declare ItemsHave int local
/varset NotFound -1
:LootIt
| Look up this item in yafm.ini
/varset ItemSetting ${Ini[yafm.ini,ForageList,${Cursor.Name},${NotFound}]}
/delay 5
| If the item isn't in the .ini file then add it.
/if (${ItemSetting}==${NotFound}) {
/ini "yafm.ini" "ForageList" "${Cursor.Name}" "${DefaultMaxSave}"
/varset ItemSetting ${DefaultMaxSave}
}
/varset ItemsHave ${FindItemCount[=${Cursor.Name}]}
| If we're keeping this item then stash it in our bags.
| Otherwise, just destroy it.
/if (${ItemSetting}>${ItemsHave}) {
/echo Keeping "${Cursor.Name}" only ${ItemsHave} of ${ItemSetting} on hand
/autoinventory
} else {
/echo Destroying "${Cursor.Name}" already have ${ItemsHave} of ${ItemSetting}
/destroy
}
/delay 5
/if (${Cursor.ID}) /goto :LootIt
/return

