Moderator: MacroQuest Developers

Code: Select all
|----------------------------
| Forager with ini file support and
| statistic gathering and reporting
| version 2.1
| Set this define to the desired .ini file
| Requires a blank .ini file to start. The marco will
| populate the .ini file automatically for any zone
| and default to keeping the item. Then just change
| the values in the .ini file to 0 for an item to be
| automatically destroyed (requires FastItemDestroy
| be turned on in the options window)
#define IniFile "forage.ini"
#Event ZoneChange "Loading please wait"
#turbo
Sub Main
/declare ForageDelay global
/declare EnableShowStats global
/declare EnableWriteLog global
/declare EnableClear global
| ##### User set variables #####
/varset ForageDelay 1010 | The delay between forage attempts
/varset EnableShowStats 1 | Set to 1 to show foraging statistics
/varset EnableWriteLog 1 | Set to 1 to write statistics to MQLog
/varset EnableClear 0 | Set to 1 to clear before writing stats
| ##### User set variables #####
/declare ForageAttempts global
/declare ForageSuccess global
/declare ForageFailure global
/declare ForageKeeps global
/declare ForageDestroys global
/declare NumItem global
/declare Index global
/declare ItemArray array2
/varset ForageAttempts 0
/varset ForageSuccess 0
/varset ForageFailure 0
/varset ForageKeeps 0
/varset ForageDestroys 0
/varset NumItem 0
/call LoadFromIni
:Continue
/doevents
/varset Index 0
/if $char(state)==SIT {
/stand
/delay 3
}
/if n $char(ability,"Forage")>0 {
/doability Forage
/varadd ForageAttempts 1
/delay 15
/if "$cursor(name)"=="NULL" {
/varadd ForageFailure 1
} else {
/varadd ForageSuccess 1
/call CheckItem
/call HandleItem
| /beep
}
}
/if @EnableWriteLog==1 /call LogStats
/if @EnableShowStats==1 /call ShowStats
/delay @ForageDelay
/goto :Continue
/return
| ########## Subroutines ##########
Sub Event_ZOneChange
/delay 1m
/call LoadFromIni
/return
Sub LoadFromIni
/varset NumItem 0
/declare IniPosition local
/declare IniList local
/declare tmpItem local
/varset IniList $ini(IniFile,"Global")
/if "@IniList"!="NOTFOUND||" {
/varset IniPosition 0
:CheckGlobalForage
/varadd IniPosition 1
/varadd NumItem 1
/varset ItemArray(0,@NumItem) "$arg($int(@IniPosition),"@IniList",|)"
/varset ItemArray(1,@NumItem) $ini(IniFile,"Global","@ItemArray(0,@NumItem)")
| Setting the second column to 0 in the array at zoneout/in. Originally wasn't getting set and would cause stats to bail.
/varset ItemArray(2,@NumItem) 0
/if "$arg($int($calc(@IniPosition+1)),"@IniList",|)"!="" /goto :CheckGlobalForage
}
/varset IniList "$ini(IniFile,"$zone")"
/if "@IniList"!="NOTFOUND||" {
/varset IniPosition 0
:CheckZoneForage
/varadd IniPosition 1
/varadd NumItem 1
/varset ItemArray(0,@NumItem) "$arg($int(@IniPosition),"@IniList",|)"
/varset ItemArray(1,@NumItem) $ini(IniFile,"$zone","@ItemArray(0,@NumItem)")
/varset ItemArray(2,@NumItem) 0
/if "$arg($int($calc(@IniPosition+1)),"@IniList",|)"!="" /goto :CheckZoneForage
}
/return
Sub LogStats
/declare xy local
/if @EnableClear==1 /mqlog clear
/mqlog #############################################
/mqlog For Zone: $zone
/mqlog Attempts = $int(@ForageAttempts)
/mqlog Success = $int(@ForageSuccess) [$int($calc(@ForageSuccess/@ForageAttempts*100))%]
/mqlog Failures = $int(@ForageFailure) [$int($calc(@ForageFailure/@ForageAttempts*100))%]
/mqlog Keeps = $int(@ForageKeeps) [$int($calc(@ForageKeeps/@ForageAttempts*100))%]
/mqlog Destroys = $int(@ForageDestroys) [$int($calc(@ForageDestroys/@ForageAttempts*100))%]
/mqlog [Idx] [Item] [Keep] [Qty] [%]
/mqlog -------------------------------------------
/if n @NumItem>0 {
/for xy 1 to @NumItem
/mqlog [$int(@xy)] [@ItemArray(0,@xy)] [$int(@ItemArray(1,@xy))] [$int(@ItemArray(2,@xy))] [$int($calc(@ItemArray(2,@xy)/@ForageAttempts*100))%]
/next xy
}
/return
Sub ShowStats
/declare xy local
/if @EnableClear==1 /clear
/echo #############################################
/echo For Zone: $zone
/echo Attempts = $int(@ForageAttempts)
/echo Success = $int(@ForageSuccess) [$int($calc(@ForageSuccess/@ForageAttempts*100))%]
/echo Failures = $int(@ForageFailure) [$int($calc(@ForageFailure/@ForageAttempts*100))%]
/echo Keeps = $int(@ForageKeeps) [$int($calc(@ForageKeeps/@ForageAttempts*100))%]
/echo Destroys = $int(@ForageDestroys) [$int($calc(@ForageDestroys/@ForageAttempts*100))%]
/echo [Idx] [Item] [Keep] [Qty] [%]
/echo -------------------------------------------
/if n @NumItem>0 {
/for xy 1 to @NumItem
/echo [$int(@xy)] [@ItemArray(0,@xy)] [$int(@ItemArray(1,@xy))] [$int(@ItemArray(2,@xy))] [$int($calc(@ItemArray(2,@xy)/@ForageAttempts*100))%]
/next xy
}
/return
Sub CheckItem
/declare xy local
/if @NumItem==0 {
/varset NumItem 1
/call AddToArray
/varset Index 1
} else {
/for xy 1 to @NumItem
/if "@ItemArray(0,@xy)"=="$cursor(name)" /varset Index @xy
/next xy
/if @Index==0 {
/varadd NumItem 1
/call AddToArray
} else {
/varadd ItemArray(2,@Index) 1
}
}
/return
Sub AddToArray
/varset ItemArray(0,@NumItem) "$cursor(name)"
/varset ItemArray(1,@NumItem) $ini("IniFile","$zone","$cursor(name)")
/if "@ItemArray(1,@NumItem)"=="NOTFOUND" {
/varset ItemArray(1,@NumItem) 1
/ini "IniFile" "$zone" "$cursor(name)" 1
}
/varset ItemArray(2,@NumItem) 1
/return
Sub HandleItem
/if @ItemArray(1,@Index)==0 {
/varadd ForageDestroys 1
/echo $cursor(name) should be destroyed.
/destroy
} else {
/varadd ForageKeeps 1
/autoinv
}
/return

Code: Select all
| old code here
new code here
Code: Select all
|----------------------------
| Forager with ini file support and
| statistic gathering and reporting
| version 2.1
| Set this define to the desired .ini file
| Requires a blank .ini file to start. The marco will
| populate the .ini file automatically for any zone
| and default to keeping the item. Then just change
| the values in the .ini file to 0 for an item to be
| automatically destroyed (requires FastItemDestroy
| be turned on in the options window)
#define IniFile "forage.ini"
#Event ZoneChange "Loading please wait"
#turbo
Sub Main
/declare ForageDelay global
/declare EnableShowStats global
/declare EnableWriteLog global
/declare EnableClear global
| ##### User set variables #####
/varset ForageDelay 1010 | The delay between forage attempts
/varset EnableShowStats 1 | Set to 1 to show foraging statistics
/varset EnableWriteLog 1 | Set to 1 to write statistics to MQLog
/varset EnableClear 0 | Set to 1 to clear before writing stats
| ##### User set variables #####
/declare ForageAttempts global
/declare ForageSuccess global
/declare ForageFailure global
/declare ForageKeeps global
/declare ForageDestroys global
/declare NumItem global
/declare Index global
/declare ItemArray array2
/varset ForageAttempts 0
/varset ForageSuccess 0
/varset ForageFailure 0
/varset ForageKeeps 0
/varset ForageDestroys 0
/varset NumItem 0
/call LoadFromIni
:Continue
/doevents
/varset Index 0
|/if n $char(ability,"Forage")>0 {
/newif ${charachter.AbilityReady["Forage"]} {
/doability Forage
/varadd ForageAttempts 1
/delay 15
|/if "$cursor(name)"=="NULL" {
/newif ${Cursor.Name}=="NULL"{
/varadd ForageFailure 1
} else {
/varadd ForageSuccess 1
/call CheckItem
/call HandleItem
| /beep
}
}
|/if @EnableWriteLog==1 /call LogStats
|/if @EnableShowStats==1 /call ShowStats
/newif @EnableWriteLog==1 /call LogStats
/newif @EnableShowStats==1 /call ShowStats
/delay @ForageDelay
/goto :Continue
/return
| ########## Subroutines ##########
Sub Event_ZOneChange
/delay 1m
/call LoadFromIni
/return
Sub LoadFromIni
/varset NumItem 0
/declare IniPosition local
/declare IniList local
/declare tmpItem local
|/varset IniList $ini(IniFile,"Global")
/varset IniList ${Ini[IniFile,"Global"]}
|/if "@IniList"!="NOTFOUND||" {
/newif "@IniList"!="NOTFOUND||" {
/varset IniPosition 0
:CheckGlobalForage
/varadd IniPosition 1
/varadd NumItem 1
|/varset ItemArray(0,@NumItem) "$arg($int(@IniPosition),"@IniList",|)"
/varset ItemArray(0,@NumItem) ${String[@IniList].Arg[${Int[@IniPosition]},|]}
|/varset ItemArray(1,@NumItem) $ini(IniFile,"Global","@ItemArray(0,@NumItem)")
/varset ItemArray(1,@NumItem) ${Ini[IniFile,"Global","@ItemArray(0,@NumItem)"]}
| Setting the second column to 0 in the array at zoneout/in. Originally wasn't getting set and would cause stats to bail.
/varset ItemArray(2,@NumItem) 0
|/if "$arg($int($calc(@IniPosition+1)),"@IniList",|)"!="" /goto :CheckGlobalForage
/newif ${String[@IniList].Arg[${Int[${Calc[@IniPosition+1]}]},|]}!=${String[""]} /goto :CheckGlobalForage
}
|/varset IniList "$ini(IniFile,"$zone")"
/varset IniList ${Ini[IniFile,${currentZone.Name}]}
|/if "@IniList"!="NOTFOUND||" {
/newif "@IniList"!="NOTFOUND||" {
/varset IniPosition 0
:CheckZoneForage
/varadd IniPosition 1
/varadd NumItem 1
|/varset ItemArray(0,@NumItem) "$arg($int(@IniPosition),"@IniList",|)"
/varset ItemArray(0,@NumItem) ${String[@IniList].Arg[${Int[@IniPosition]},|]}
|/varset ItemArray(1,@NumItem) $ini(IniFile,"$zone","@ItemArray(0,@NumItem)")
/varset ItemArray(1,@NumItem) ${Ini[IniFile,${currentZone.Name},@ItemArray(0,@NumItem)]}
/varset ItemArray(2,@NumItem) 0
|/if "$arg($int($calc(@IniPosition+1)),"@IniList",|)"!="" /goto :CheckZoneForage
/newif ${String[@IniList].Arg[${Int[${Calc[@IniPosition+1]}]},|]}
}
/return
Sub LogStats
/declare xy local
/if @EnableClear==1 /mqlog clear
/mqlog #############################################
/mqlog For Zone: $zone
/mqlog Attempts = $int(@ForageAttempts)
/mqlog Success = $int(@ForageSuccess) [$int($calc(@ForageSuccess/@ForageAttempts*100))%]
/mqlog Failures = $int(@ForageFailure) [$int($calc(@ForageFailure/@ForageAttempts*100))%]
/mqlog Keeps = $int(@ForageKeeps) [$int($calc(@ForageKeeps/@ForageAttempts*100))%]
/mqlog Destroys = $int(@ForageDestroys) [$int($calc(@ForageDestroys/@ForageAttempts*100))%]
/mqlog [Idx] [Item] [Keep] [Qty] [%]
/mqlog -------------------------------------------
/if n @NumItem>0 {
/for xy 1 to @NumItem
/mqlog [$int(@xy)] [@ItemArray(0,@xy)] [$int(@ItemArray(1,@xy))] [$int(@ItemArray(2,@xy))] [$int($calc(@ItemArray(2,@xy)/@ForageAttempts*100))%]
/next xy
}
/return
Sub ShowStats
/declare xy local
/if @EnableClear==1 /clear
/echo #############################################
/echo For Zone: $zone
/echo Attempts = $int(@ForageAttempts)
/echo Success = $int(@ForageSuccess) [$int($calc(@ForageSuccess/@ForageAttempts*100))%]
/echo Failures = $int(@ForageFailure) [$int($calc(@ForageFailure/@ForageAttempts*100))%]
/echo Keeps = $int(@ForageKeeps) [$int($calc(@ForageKeeps/@ForageAttempts*100))%]
/echo Destroys = $int(@ForageDestroys) [$int($calc(@ForageDestroys/@ForageAttempts*100))%]
/echo [Idx] [Item] [Keep] [Qty] [%]
/echo -------------------------------------------
/if n @NumItem>0 {
/for xy 1 to @NumItem
/echo [$int(@xy)] [@ItemArray(0,@xy)] [$int(@ItemArray(1,@xy))] [$int(@ItemArray(2,@xy))] [$int($calc(@ItemArray(2,@xy)/@ForageAttempts*100))%]
/next xy
}
/return
Sub CheckItem
/declare xy local
|/if @NumItem==0 {
/newif @NumItem==0 {
/varset NumItem 1
/call AddToArray
/varset Index 1
} else {
/for xy 1 to @NumItem
|/if "@ItemArray(0,@xy)"=="$cursor(name)" /varset Index @xy
/newif @ItemArray(0,@xy)==${Cursor.Name} /varset Index @xy
/next xy
/if @Index==0 {
/varadd NumItem 1
/call AddToArray
} else {
/varadd ItemArray(2,@Index) 1
}
}
/return
Sub AddToArray
/varset ItemArray(0,@NumItem) ${Cursor.Name}
|/varset ItemArray(1,@NumItem) $ini("IniFile","$zone","$cursor(name)")
/varset ItemArray(1,@NumItem) ${Ini["IniFile",${currentZone.Name},${Cursor.Name}]}
|/if "@ItemArray(1,@NumItem)"=="NOTFOUND" {
/newif @ItemArray(1,@NumItem)=="NOTFOUND" {
/varset ItemArray(1,@NumItem) 1
|/ini "IniFile" "$zone" "$cursor(name)" 1
/ini "IniFile" ${currentZone.Name} ${Cursor.Name} 1
}
/varset ItemArray(2,@NumItem) 1
/return
Sub HandleItem
|/if @ItemArray(1,@Index)==0 {
/newif @ItemArray(1,@Index)==0 {
/varadd ForageDestroys 1
|/echo $cursor(name) should be destroyed.
/echo ${Cursor.Name} should be destroyed.
/destroy
} else {
/varadd ForageKeeps 1
/autoinv
}
/return
In answer to your direct question, no. /if and /newif do the same damn thing now.Ketamine wrote:Ok, really new to this and trying to figure this out... If I go through the whole macro and change all "/if" to "/newif" should that fix it? or do I need to tell it that everywhere it sees a "/if" to use "/newif". If thats the case how do I do that? Thanks

Code: Select all
|----------------------------
| Forager v2.21
|
| Changes in 2.21:
|
| Only changes for compatability purposes
| This macro is NOT working correctyl yet
#define INIFile "Forage.ini"
| Set the above define to the desired .ini file
| Requires a blank .ini file to start. The marco will
| populate the .ini file automatically for any zone
| and default to keeping the item. Then just change
| the values in the .ini file to 0 for an item to be
| automatically destroyed (requires FastItemDestroy
| be turned on in the options window)
Sub Main
/declare EnableShowStats global
/declare EnableWriteLog global
/declare EnableClear global
| ##### User set variables #####
/varset EnableShowStats 1 | Set to 1 to show foraging statistics
/varset EnableWriteLog 0 | Set to 1 to write statistics to MQLog
/varset EnableClear 0 | Set to 1 to clear before writing stats
| ##### User set variables #####
/declare ForageAttempts global
/declare ForageSuccess global
/declare ForageFailure global
/declare ForageKeeps global
/declare ForageDestroys global
/declare NumItem global
/declare Index global
/declare ItemArray array2
/varset ForageAttempts 0
/varset ForageSuccess 0
/varset ForageFailure 0
/varset ForageKeeps 0
/varset ForageDestroys 0
/varset NumItem 0
:Continue
/delay 5
/varset Index 0
/if (${Me.State.NotEqual[STAND]}) {
/stand
/delay 5
}
/if (${Me.AbilityReady[Forage]}) {
/doability Forage
/delay 5
/varadd ForageAttempts 1
|/if (${cursor}=="NULL") {
/if (${Cursor.ID}) {
/Echo Forage Success!
/varadd ForageSuccess 1
/call CheckItem
/call HandleItem
} else {
/Echo Forage Failure
/varadd ForageFailure 1
}
}
/if (@EnableShowStats==1) {
/call ShowStats
}
/if (@EnableWriteLog==1) {
/call LogStats
}
}
/goto :Continue
/return
| ########## Subroutines ##########
Sub LogStats
/declare xy local
/if @EnableClear==1 /mqlog clear
/mqlog #############################################
/mqlog Attempts: $int(@ForageAttempts), Success: $int(@ForageSuccess) [$int($calc(@ForageSuccess/@ForageAttempts*100))%] Failures: $int(@ForageFailure) [$int($calc(@ForageFailure/@ForageAttempts*100))%]
/mqlog Keeps: $int(@ForageKeeps) [$int($calc(@ForageKeeps/@ForageAttempts*100))%] Destroys: $int(@ForageDestroys) [$int($calc(@ForageDestroys/@ForageAttempts*100))%]
/mqlog [Idx] [Item] [Keep] [Qty] [%]
/mqlog -------------------------------------------
/if (n @NumItem>0) {
/for xy 1 to @NumItem
/mqlog [$int(@xy)] [@ItemArray(0,@xy)] [$int(@ItemArray(1,@xy))] [$int(@ItemArray(2,@xy))] [$int($calc(@ItemArray(2,@xy)/@ForageAttempts*100))%]
/next xy
}
/return
Sub ShowStats
/declare xy local
| /if (@EnableClear==1) /clear {
/echo #############################################
/echo For Zone: ${Zone}
/echo Attempts = $int(@ForageAttempts)
/echo Success = $Int(@ForageSuccess) [$int($calc(@ForageSuccess/@ForageAttempts*100))%]
/echo Failures = $int(@ForageFailure) [$int($calc(@ForageFailure/@ForageAttempts*100))%]
/echo Keeps = $int(@ForageKeeps) [$int($calc(@ForageKeeps/@ForageAttempts*100))%]
/echo Destroys = $int(@ForageDestroys) [$int($calc(@ForageDestroys/@ForageAttempts*100))%]
/echo [Idx] [Item] [Keep] [Qty] [%]
/echo -------------------------------------------
/for xy 1 to @NumItem
/echo [$int(@xy)] [@ItemArray(0,@xy)] [$int(@ItemArray(1,@xy))] [$int(@ItemArray(2,@xy))] [$int($calc(@ItemArray(2,@xy)/@ForageAttempts*100))%]
/next xy
}
/return
Sub CheckItem
/Echo CheckItem
/declare xy local
/if (@NumItem==0) {
/varset NumItem 1
/call AddToArray
/varset Index 1
} else {
/for xy 1 to @NumItem
/if @ItemArray(0,@xy)==${cursor} /varset Index @xy {
/next xy
/if @Index==0 {
/varadd NumItem 1
/call AddToArray
} else {
/varadd ItemArray(2,@Index) 1
}
}
}
/return
Sub AddToArray
/Echo AddToArray
/varset ItemArray(0,@NumItem) ${Cursor}
/echo @NumItem
/echo @ItemArray(0,@NumItem)
/varset ItemArray(1,@NumItem)
$ini("INIFile","${zone.name}","$(cursor.name)")
|/if (@ItemArray[1,@NumItem]==NOTFOUND) {
/newif (!${Ini[forage.ini,${Zone.Name},${Cursor}].Length}) {
/varset ItemArray(1,@NumItem) 1
/ini "INIFile" "${Zone.Name}" "${Cursor}" 1
}
/varset ItemArray(2,@NumItem) 1
/return
Sub HandleItem
/Echo HandleItem
/if (@ItemArray(1,@Index)==0) {
/varadd ForageDestroys 1
/destroy
} else {
/varadd ForageKeeps 1
/autoinv
}
/return