My idea is to eventually make the code so reuseable, that you just fill out an array with possible options, and their default values. Then parse against that array.
Anyway, the code in its current form is coming here:
Code: Select all
#define dly v0
#define abt v1
#define ShowStats v2
#define DesiredSuccesses v3
#define EndOnTrivial v4
#define FinishedProduct v5
Sub Main
|** DEFAULTS **|
/varset ShowStats 1
/varset EndOnTrivial 0
/varset dly 2
/varset abt 0
/varset FinishedProduct "keep"
/varset DesiredSuccesses 0
|** DEFAULTS **|
/if "$p0"=="" /call ExecError
/if "$p0"=="help" /call ShowHelp
/call ParseArgs "$p0"
/return
Sub ParseArgs
/if "$p0"=="" {
/echo Syntax: /call ParseArgs "space seperated string of arguments"
/endmacro
}
/call CountArgs "$p0"
/for l0 1 to $return
/varset l1 $left($instr("=","$arg($l0,"$p0")"),"$arg($l0,"$p0")")
/varset l2 $right($calc($strlen("$arg($l0,"$p0")")-$instr("=","$arg($l0,"$p0")")-1),$arg($l0,"$p0"))
/if "$l1"=="default" /goto :EndOptions
/if "$l1"=="combines" /varset DesiredSuccesses $int($l2)
/if "$l1"=="delay" /varset dly $int($l2)
/if "$l1"=="end-on-trivial" /varset EndOnTrivial $int($l2)
/if "$l1"=="abort-on-tell" /varset abt $int($l2)
/if "$l1"=="destroy" /if n $l2==1 /varset FinishedProduct "destroy"
/if "$l1"=="show-stats" /varset ShowStats $int($l2)
/varadd l0 1
/if n $l0>7 /goto :EndOptions
/next l0
:EndOptions
/return
Sub CountArgs
/if "$p0"=="" {
/echo Syntax: /call CountArgs "space seperated string of arguments"
/endmacro
}
/varset l0 1
/varset l1 1
:Loop
/if "$mid($int($l1),1,"$p0")"==" " /varadd l0 1
/varadd l1 1
/if n $l1<$strLen("$p0") /goto :Loop
/return $l0
Sub ExecError
/echo Syntax error.
/echo Type the following for more help:
/echo /macro ts "help"
/endmacro
/return
Sub ShowHelp
/echo Syntax: /macro ts <options> <CombinerName> <Component> [Component]...
/echo Example: /macro ts "show-stats=0 destroy=0 abort-on-tell=0 end-on-trivial=0" "Sewing Kit" "Spider Silk" "Spider Silk"
/echo -
/echo Options:
/echo --------
/echo * show-stats
/echo -- Syntax: show-stats=1|0
/echo -- Example: show-stats=0
/echo -- Shows combine statistics.
/echo -- Set to 1 for show showing stats, 0 to leave out the stats.
/echo -- Default set to 1 (show stats).
/echo -
/echo * destroy
/echo -- Syntax: destroy=1|0
/echo -- Example: destroy=1
/echo -- Tells the macro wether end-result is destroyed or kept.
/echo -- Set to 1 for destroying end-result, 1 to keep end-result.
/echo -- Default set to 0 (keep end-result).
/echo -
/echo * abort-on-tell
/echo -- Syntax: abort-on-tell=1|0
/echo -- Example: abort-on-tell=1
/echo -- Tell the macro wether it should /endmacro when recieving a tell.
/echo -- Set to 1 for ending macro on tells, 0 to ignore tells.
/echo -- Default set to 0 (ignore tells).
/echo -
/echo * end-on-trivial
/echo -- Syntax: end-on-trivial=1|0
/echo -- Example: end-on-trivial=1
/echo -- Tell the macro wether it should stop combines when recieving a trivial message.
/echo -- Set to 1 for ending macro on trivial, 0 to ignore trivial.
/echo -- Default set to 0 (ignore trivial).
/echo -
/echo * delay
/echo -- Syntax: delay=#
/echo -- Example: delay=4
/echo -- The delay between mouse commands in the macro.
/echo -- Increase this number to make the macro combine slower, but more safely. Decrease the number to combine faster, but more prone to errors.
/echo -- Default set to 2 (this is as fast as it has been tested to be able to go)
/echo -
/echo * combines
/echo -- Syntax: combine=#
/echo -- Example: combine=100
/echo -- The number of successfull combines you want made (or till no more components are available).
/echo -- Set to 0 for unlimited combines (or till no more components are available), or to the wanted amount.
/echo -- Default set to 0 (unlimited).
/echo -
/echo * default
/echo -- Syntax: default
/echo -- Tell the macro to use all default settings, any other options set will be ignored and defaults will be used.
/endmacro
/return