Tfzmacros

Several people have requested I combine ALL the supporting routines for my systems into one easy to load file. Tada. This includes some previously posted material: CmdParse, NoteRead, NoteWrite, PPNotice, and some I may have forgotten.
THERE IS MUCH NEW IN THIS FILE. EDIT IT TO MATCH YOUR REQUIREMENTS.
Look through the code for things you would want to change and to acquaint yourself with what is being done. THIS CAN NOT BE STRESSED enough.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;                                     ZMACROS.TF                        ;;;;
;;;;                                     ZORBO ON 3k                       ;;;;
;;;;                                 MISCELLANOUS MACROS                   ;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; March 07, 2010     changed writevars to include proper masks for maxstash and mobs matrix
;

/loaded z::macros.tf
/require -q zalias.tf
/require -q zhelp.tf

;;; ZMACROS FILE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; see /zhelp zmacros for further info
;
/test zhelp_add("zmacros","This is a collection of macros written by, or stolen by Zorbo on 3k. It contains commonly used /def's. Type /zhelp zmacros all for further information and be sure to check out the zmacros.tf file.")

;;;CmdParse = Command Parser with Repeat ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; DO NOT USE FOR COMMANDS WITH %* You can use $[] however
;
; syntax:
;/CmdParse [-s"<CmdSeperator>"][-n"<NumSeperator>] \ ;[n<NumSeperator>]<cmd><CmdSeperator>[n<NumSeperator>]<cmd><CmdSeperator>....
;    <CmdSeperator> defaults to "/"
;    <NumSeperator> defaults to "-"
;    and <cmd> is any string
;
; Examples:
;    /CmdParse 21-n/3-ne/s/enter
;        will do n 21 times then ne 3 times then s then enter
;
;    /CmdParse #give preservation/absorb
;        will do #give preservation then absorb
;
;    /CmdParse -s"~" qtrance #give preservation/absorb~woo
;        will do qtrance #give preservation/absorb then the woo soul
;
;    /CmdParse keep all/retrieve/open chest/take $[item]/put $[item] in chest\
;        /close chest/deliver/drop all/unkeep all
;            will pick up item and puts it in chest
;
/def CmdParse = \
    /let opt_s=/%; \
    /let opt_n=-%; \
    /if (!getopts("s:n:")) /return 0%; /endif %; \
    /let TotalLine=%{*}%; \
    /let Start=0%; \
    /let SepCmd=0%; \
    /while (SepCmd > -1) \
        /let SepCmd=$[strchr(TotalLine,opt_s,Start)]%; \
        /if (SepCmd > 0) \
            /let ThisCmd=$[substr(TotalLine,Start,SepCmd)]%; \
        /else \
            /let ThisCmd=$[TotalLine]%; \
        /endif%; \
        /let TotalLine=$[substr(TotalLine,SepCmd+1)]%; \
        /let SepNum=$[strchr(ThisCmd,opt_n)]%; \
        /if (SepNum > 0) \
            /let ThisRpt=$[0 + (substr(ThisCmd,0))]%; \
            /let ThisCmd=$[substr(ThisCmd,SepNum+1)]%; \
            /while (--ThisRpt >= 0) \
                /eval /send $[ThisCmd]%; \
            /done%; \
        /else \
            /eval /send $[ThisCmd]%; \
        /endif%; \
    /done
/test zhelp_add("zmacros_cmdparse","Sends several strings to the mud. ie /CmdParse 21-n/3-ne/s/enter will do n 21 times then ne 3 times then s then enter.")

;;; code_attr ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; syntax: code_attr(<string>,<attribut_string>)
; example /test dummy:=$[code_attr(sillystringvariable,"BCcyan")]
;    returns the string "@{BCcyan}sillystringvariable@{n}"
;
/def code_attr = \
    /let code_line=%1%; \
    /let code_attr=%2%; \
    /result strcat("@{",code_attr,"}",code_line,"@{n}")

;;; bag ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; syntax: /bag <itemininventory>
;
/def bag = \
    /let item=%*%; \
    /if (item !~ "all") \
        /send put %* in bag $[AutoBagCurrent]%; \
    /else \
        /test ppnotice(3, "I WILL NOT PUT ALL IN BAG - AGAIN")%; \
    /endif
/test zhelp_add("zmacros_bag","Puts item in AutoBagCurrent. syntax: /bag <itemininventory>")

;;; bagall ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; syntax: /bagall
; gathers everything on ground and puts it in bags
;
/def bagall =\
    /set TryBag=0%; \
    /CmdParse keep all/take all/put all in bag $[AutoBagCurrent]/drop all/unkeep all/hp
/test zhelp_add("zmacros_bagall","Gathers everything on ground and puts it in AutoBagCurrent ie /bagall")

/def bagall1 =\
    /set TryBag=0%; \
    /CmdParse keep all/take all%; \
    /let cnt=$[AutoBagCurrent-1]%; \
    /while (++cnt <= AutoBagMax) \
        /send put all in bag $[cnt]%; \
    /done%; \
    /CmdParse drop all/unkeep all/hp

;;; bagdall ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; donates from bag(s)
;    NOTE: tied into to bagcounter trigger so 'i' will count bags and set AutoBagMax
;
/def bagdall = \
    /if (AutoBagMax==0) \
        /test PPNotice(4, "Bags not counted yet")%; \
        /return -1%; \
    /elseif (AutoBagMax >0) \
        /let cnt=0%; \
        /while (++cnt <= AutoBagMax) \
            /CmdParse donate all from bag $[cnt]%; \
        /done%; \
        /set AutoBagCurrent=1%; \
    /endif
/test zhelp_add("zmacros_bagdall","Donates from all bags. Tied into to a bagcounter trigger so 'i' will count bags and set MaxBag. ie /bagdall")

;;; bagdon ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; syntax: /bagdon <bag>
; example: /bagdon 1
;
/def bagdon = /let item=%*%; /CmdParse donate all from bag $[item]
/test zhelp_add("zmacros_bagdon","Donate all from bag <num>. ie /bagdon 2")

;;; bagit ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; takes an item off the ground and puts it in bag
;
/def bagit = \
    /let item=%*%; \
    /CmdParse keep all/take $[item]/put $[item] in bag $[AutoBagCurrent]/drop all/unkeep all
/test zhelp_add("zmacros_bagit","Takes an item off the ground and puts it in AutoBagCurrent. ie /bagit sword")

;;; bagfull ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; increments AutoBagCurrent unless out of bags
;
/def bagfull = \
;    /CmdParse drop bag $[MaxBag]/take bag
    /if (++AutoBagCurrent>AutoBagMax) \
        /Set AutoBagCurrent=1%; \
        /test PPNotice(3,"AutoBag: Bags full - Turning off AutoBag")%; \
        /set AutoBag=0%; \
    /else \
        /test PPNotice(3,"AutoBag: Bag Full - Changing current bag to $[AutoBagCurrent]")%; \
    /endif
/test zhelp_add("zmacros_bagfull","Tied into to ztrigger_bagcounter. Increments AutoBagCurrent")

;;; baglook ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; syntax: /baglook looks at all bags
;
/def baglook = \
    /if (AutoBagMax==0) \
        /test PPNotice(4, "Bags not counted yet")%; \
        /return -1%; \
    /else \
        /let cnt=0%; \
        /while (++cnt <= AutoBagMax) \
            /send look at bag $[cnt]%; \
        /done%; \
    /endif
/test zhelp_add("zmacros_baglook","Looks at all bags. See '/zhelp ztrigger bagcounter'. ie /bagsellall")

;;; bagsell ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; syntax /bagsell <bag#>
;
/def bagsell = /let item=%*%; /CmdParse sell all from bag $[item]
/test zhelp_add("zmacros_bagsell","Sell all from bag #. ie /bagsell 2")

;;; bagssellall ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; sells everything in every bag (do 'i' beforehand to count bags)
;
/def bagsellall = \
    /if (AutoBagMax==0) \
        /test PPNotice(4, "Bags not counted yet")%; \
        /return -1%; \
    /elseif (AutoBagMax>0) \
        /let cnt=0%; \
        /while (++cnt <= AutoBagMax) \
            /CmdParse sell all from bag $[cnt]%; \
        /done%; \
        /set AutoBagCurrent=1%; \
    /endif
/test zhelp_add("zmacros_bagsellall","Sell all from all bags. See '/zhelp ztrigger bagcounter'. ie /bagsellall")

;;; boxc = Box Corpse  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; /boxc [start] [end]
;
/def boxc = \
    /let start=%{1}%; \
    /let end=%{2}%; \
    /if (end !~ "") /let count=$[end-start+1]%; /endif%; \
    /if (start =~ "") \
        /send put preservation in box%; \
    /elseif ((start != "") & (count =~ "")) \
        /send put preservation $[start] in box%; \
    /elseif ((start != "") & (count != "")) \
        /let i=0%; \
        /while (++i <= count) \
            /send put preservation $[start] in box%; \
        /done%; \
    /endif%; \
    /send hp
/test zhelp_add("zmacros_boxc","Puts corpses in box. ie /boxc <start> <end> /boxc 2 8 will put corpses 2 to 8 in the box.")

;;; chall ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; gathers all and puts it in the chest
;
/def chall = \
    /CmdParse keep all/retrieve/open chest/take all/put all in chest/close chest\
        /deliver/drop all/unkeep all
/test zhelp_add("zmacros_chall","Takes everything on ground an puts it in chest. ie /chall")

;;; chdon ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; donates everything it can from the chest
;
/def chdon = /CmdParse keep all/retrieve/open chest\
        /take all from chest/donate all\
        /take all from chest/donate all\
        /take all from chest/donate all\
        /take all from chest/donate all\
        /close chest/deliver/unkeep all
/test zhelp_add("zmacros_chdon","Donates all from chest 4 times . ie /chdon")

;;; chit ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; takes item from ground and puts it in chest
;
/def chit = \
    /let item=%*%; \
    /CmdParse keep all/retrieve/open chest/take $[item]/put $[item] in chest\
        /close chest/deliver/drop all/unkeep all
/test zhelp_add("zmacros_chit","Takes item from ground and puts it in chest. ie /chit sword")

;;; chit2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; carried item - puts it in chest
;
/def chit2 = \
    /let item=%*%; \
    /CmdParse retrieve/open chest/put $[item] in chest\
        /close chest/deliver/
/test zhelp_add("zmacros_chit2","puts item in chest. ie /chit2 sword")

;;; chlook ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; looks at chest
;
/def chlook = /CmdParse retrieve/open chest/look at chest/close chest/deliver
/test zhelp_add("zmacros_chlook","Looks at your chest. ie /chlook")

;;; chsell ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; sells all it can from chest
;
/def chsell = /CmdParse keep all/retrieve/open chest/take all from chest/sell all\
        /close chest/deliver/unkeep all
/test zhelp_add("zmacros_chsell","Sells all from chest. ie /chsell")

;;; da ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; looks at then searchs something
;
/def da = /let item=%*%; /CmdParse look at $[item]/search $[item]
/test zhelp_add("zmacros_da","Short for Do All, this looks at <obj> and then searches <obj>. ie /da <obj> /da sword")

;;; dcf Drop Corpse follower ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; /dcf [start] [end]
; /dcf
;     drop corpse
;
; /dcf 4
;    drop corpse 4
;
; /dcf 5 7
;    drop corpses 5 through 7
;
; use alias icf to get numbered list of corpses
;
/def dcf = \
    /let start=%{1}%; \
    /let end=%{2}%; \
    /if (end !~ "") /let count=$[end-start+1]%; /endif%; \
    /if (start =~ "") \
        /send #drop preservation%; \
    /elseif ((start != "") & (count =~ "")) \
        /send #drop preservation $[start]%; \
    /elseif ((start != "") & (count != "")) \
        /let i=0%; \
        /while (++i <= count) \
            /send #drop preservation $[start]%; \
        /done%; \
    /endif%; \
    /send hp
/test zhelp_add("zmacros_dcf","Drop Corpse Follower from <start> to <end>. Must have zalias system. ie /dcf 2 8 causes follower to drop corpses 2 through 8.")

;;; dcm = Drop Corpse Me ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; syntax dcm [start] [end]
; see dcf
; use icc to get numbered list of corpses carried
;
/def dcm = \
    /let start=%{1}%; \
    /let end=%{2}%; \
    /if (end !~ "") /let count=$[end-start+1]%; /endif%; \
    /if (start =~ "") \
        /send drop preservation%; \
    /elseif ((start != "") & (count =~ "")) \
        /send drop preservation $[start]%; \
    /elseif ((start != "") & (count != "")) \
        /let i=0%; \
        /while (++i <= count) \
            /send drop preservation $[start]%; \
        /done%; \
    /endif%; \
    /send hp
/test zhelp_add("zmacros_dcm","Drop Corpse from <start> to <end>. Must have zalias system. ie /dcm 2 8 drops corpses 2 through 8.")

;;; freco = Follower Re-arrange Corpse ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; /freco start end
;
/def freco = \
    /let start=%{1}%; \
    /let end=%{2}%; \
    /if (end !~ "") /let count=$[end-start+1]%; /endif%; \
    /if ((start =~ "") | (count =~"")) \
        /test ppnotice(2, "Syntax is @{B}/freco <start> <end>@{n}")%; \
        /return 0%; \
    /endif%; \
    /let i=0%; \
    /while (++i <= count) \
        /send #drop preservation $[start]%; \
    /done%; \
    /let i=0%; \
    /while (++i <= count) \
        /send #get preservation%; \
    /done%; \
    /send hp
/test zhelp_add("zmacros_freco","Follower Re-arrange Corpse <start> <end>. Follower drops selected corpses then picks them up. Used to group corpses at top of inventory. ie /freco 2 8.")

;;; ga = gather all ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; /ga
;
/def ga = \
    /if (AutoBag) /bagall1%; /endif%; \
    /if (AutoChest) /chall%; /endif
/test zhelp_add("zmacros_ga","Gather all. Part of the ZFKAuto System, this will take everything off the ground and put it either in the chest(AutoChest) or a bag(AutoBag). ie /ga")

;;; gcf = Give Corpse follower ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; /gcf [start] [end]
;
/def gcf = \
    /let start=%{1}%; \
    /let end=%{2}%; \
    /if (end !~ "") /let count=$[end-start+1]%; /endif%; \
    /if (start =~ "") \
        /send give preservation to $[AutoFollowerName]%; \
    /elseif ((start != "") & (count =~ "")) \
        /send give preservation $[start] to $[AutoFollowerName]%; \
    /elseif ((start != "") & (count != "")) \
        /let i=0%; \
        /while (++i <= count) \
            /send give preservation $[start] to $[AutoFollowerName]%; \
        /done%; \
    /endif%; \
    /send hp
/test zhelp_add("zmacros_gcf","Give Corpse to Follower <start> <end>. ie /gcf 2 8")

;;; gcm = Give Corpse Me ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; /gcm [start] [end]
;
/def gcm = \
    /let start=%{1}%; \
    /let end=%{2}%; \
    /if (end !~ "") /let count=$[end-start+1]%; /endif%; \
    /if (start =~ "") \
        /send #give preservation%; \
    /elseif ((start != "") & (count =~ "")) \
        /send #give preservation $[start]%; \
    /elseif ((start != "") & (count != "")) \
        /let i=0%; \
        /while (++i <= count) \
            /send #give preservation $[start]%; \
        /done%; \
    /endif%; \
    /send hp
/test zhelp_add("zmacros_gcm","Give Corpse to Me <start> <end>. ie /gcm 2 8")

;;; K(ill) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; The kill command
;
/def k = \
    /set Killtarget=%*%; \
;    /ZBattle_CombatReport_init%; \
    /if (AutoParty==0) \
        /send kill $[Killtarget]%; \
    /elseif ((AutoParty==1) & (Killtarget=~"")) \
        /send passist%; \
    /elseif ((AutoParty==1) & (Killtarget!~"")) \
        /send kill $[Killtarget]%; \
        /send ptell Attacking $[Killtarget]%; \
    /endif%; \
    /if (AutoCall = 1) \
        /send call%; \
    /endif%; \
    /if (AutoScythe = 1) \
        /CmdParse scythe/con 10%; \
    /endif
/test zhelp_add("zmacros_k","Kill. Part of ZFKAuto system. Honors AutoParty, AutoCall, AutoScythe. ie /k <target>.")

;;; ka ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; ka = Adaptive invoke kill
;    Should be same as battle funcion key
;
/def ka = \
    /AdaptiveInvoke%; \
    /k %*
/test zhelp_add("zmacros_ka","Kill using AdaptiveInvoke of ZFKBattle. ie /ka <target>")

;;; kt ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; kt = Kill Target
;    attempts to kill $[KT_target]
;    as set in MobTrigger (in Ztriggers.tf)
;    See /k also
;
/def kt = \
    /if (AutoTarget==0) \
        /test ppnotice(3, "Auto Trigger NOT enabled")%; \
        /return -1%; \
    /endif%; \
    /if (KT_target=~"") \
        /test ppnotice(3, "No Target Aquired")%; \
        /return -1%; \
    /endif%; \
    /k %KT_target
/test zhelp_add("zmacros_kt","Kill Target. Part of Ztarget System. ie /kt")

;;; NameFollower ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; set AutoFollowername
;
/def NameFollower = \
    /set AutoFollowerName=%*%; \
    /test PPNotice(2,"AutoFollowerName set to $[AutoFollowerName]")
/test zhelp_add("zmacros_namefollower","Sets AutoNameFollower. ie /namefollower Cordless")

;;; Makefollower ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; makes the undead follower named AutoFolName
;
/def makefollower = /CmdParse -s"~" qtrance drop preservation\
    /animate dead\
    /chant\
    /#name $[AutoFollowerName]\
    /#setmin has no cords\
    /#setmout looks for cords\
    /#lead\
    /hp
/test zhelp_add("zmacros_makefollower","Make a undead follower named $[AutoFollowerName]. Use /NameFollower to set. You need a corpse in inventory. ie /makefollower")

;;; Must ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; These are commands where you MUST do something
; /MustAC
; /MustAP
; /MustRT
;
/def MustAC = \
    /CmdParse -s"~" qtrance #give preservation/smuggle remove preservation/unwrap/absorb/hp
/test zhelp_add("zmacros_mustac","Must AC. Pulls corpses from every where to absorb one. ie /mustac")

/def MustAP = \
    /CmdParse -s"~" qtrance #give preservation/smuggle remove preservation/unwrap/absorb prime/hp
/test zhelp_add("zmacros_mustap","Must AP. Pulls corpses from every where to absorb PRIME one. ie /mustap")

/def MustRT = \
    /CmdParse -s"~" qtrance #give preservation/smuggle remove all/unwrap/absorb\
        /#give preservation/unwrap/absorb/#give preservation/unwrap/absorb prime\
        /rope trick/con 100/hp
/test zhelp_add("zmacros_mustrt","Must ROPE TRICK. Massive healing from everywhere followed by a rope trick. ie /mustRT")

;;; notewrite/noteread ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; /notewrite [-f<filename>] <text>
;    writes color coded <date> <time> <text> to <filename> or defalts to 'notes'
; /notewrite <text>
;    writes color coded <date> <time> <text> to file 'notes'
; /notewrite -flevel advanced @{BCred}int@{n}
;    writes colorcoded <date> <time> advanced int to file 'level'
;    Note you can embed display attrs
;
; /noteread [-f<filename>]
;    outputs contents of <filename> or 'notes' to the screen (output stream)
; /noteread
;     outputs contents of file named 'notes' to the screen (output stream)
; /noteread -flevel
;    outputs contents of file named 'level' to the screen (output stream)
;
/set Noteslocation=Notefiles/

/def notewrite = \
    /let opt_f=notes%; \
    /if (!getopts("f:")) /return 0%; /endif %; \
    /let TotalLine=%{*}%; \
    /let text=$[strcat("@{Cgreen}",ftime('%Y-%m-%d')," ",ftime('%H:%M:%S'),"@{n}"," ",TotalLine)] %; \
    /let totalfile=$[strcat(Noteslocation,opt_f)]%; \
    /eval /set notefile=$[tfopen({totalfile},'a')]%; \
    /test tfwrite({notefile},{text})%; \
    /test tfclose({notefile})%; \
    /test PPNotice(1,"Notes written to $[opt_f]")
/test zhelp_add("zmacros_notewrite","Writes a note to note file(default) or optional file. ie /notewrite -f<filename> or /notewrite -fcoffin Donated 16 corpses and still no coffin expansion!")

/def noteread = \
    /let opt_f=notes%; \
    /if (!getopts("f:")) /return 0%; /endif %; \
    /test PPNotice(1,"Reading $[opt_f]")%; \
    /let totalfile=$[strcat(Noteslocation,opt_f)]%; \
    /eval /set notefile=$[tfopen({totalfile},'r')]%; \
    /let line=%; \
    /while (tfread({notefile}, line) >= 0) \
        /let line=$[decode_attr(line)]%; \
        /test tfwrite("o", line)%; \
    /done%; \
    /test tfclose({notefile})
/test zhelp_add("zmacros_noteread","Reads a note from note file(default) or optional file. ie /noteread or /noteread -f<filename>")

;;; Zonoff ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
/def zonoff = \
    /let on=ON%; \
    /let off=OFF%; \
    /if ({1}==1) \
        /return on%; \
    /else \
        /return off%; \
    /endif

;;; PPNotice ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; /test PPNotice(<level>, <text>[, <attr1>, <attr2>])
; just formats a pretty player notice
; <level>=1 to 7 for blue, green, yellow, cyan, magenta, red and realred highlights
; <level>=0 to provide alternate attrs to the line
;
; examples:
;     /test PPNotice(6,"DREAM COUNT LOW")
;
;    /test PPNotice({colornotice}, \
;        "@{xCgreen}HP@{n}:$[dif_chp] @{xCmagenta}SP@{n}:$[dif_csp] \
;        @{xCyellow}NP@{n}:$[dif_cnp]")%;\
;
;    /test PPNotice(0,"You have been Snarfed","BCcyan","BCgreen")
;
/def PPNotice = \
    /let level=%1%; \
    /let notice=%2%; \
    /if (level==1) \
        /let h1=@{Cblue}%; \
        /let h2=@{BCblue}%; \
    /elseif (level==2) \
        /let h1=@{Cgreen}%; \
        /let h2=@{BCgreen}%; \
    /elseif (level==3) \
        /let h1=@{Cyellow}%; \
        /let h2=@{BCyellow}%; \
    /elseif (level==4) \
        /let h1=@{Ccyan}%; \
        /let h2=@{BCcyan}%; \
    /elseif (level==5) \
        /let h1=@{Cmagenta}%; \
        /let h2=@{BCmagenta}%; \
    /elseif (level==6) \
        /let h1=@{Cred}%; \
        /let h2=@{BCred}%; \
    /elseif (level==7) \
        /let h1=@{BCred}%; \
        /let h2=@{BCred}%; \
    /elseif (level==0) \
        /let h1=$[strcat("@{",{3},"}")]%; \
        /let h2=$[strcat("@{",{4},"}")]%; \
    /else \
        /test ppnotice(2, "Syntax for PPNotice is PPNotice(<1...7>, <text>)")%; \
        /return -1%; \
    /endif%; \
    /let x=@{n}%; \
    /let LeftArrow=$[strcat(h1,">",x,h2,">",x)]%; \
    /let RightArrow=$[strcat(h1,"<",x,h2,"<",x)]%; \
    /let LenNotice=$[strlen(decode_attr(notice))]%; \
    /let tempv=$[((76-LenNotice)/4)]%; \
    /let LeftSide=$[strrep({LeftArrow}, tempv)]%; \
    /let RightSide=$[strrep({RightArrow}, tempv)]%; \
    /eval /echo -p -- %LeftSide %h2%notice%x %RightSide
/test zhelp_add("zmacros_ppnotice","Pretty Player Notice. Use in codes to format a message to the screen. See Zmacro.tf for usage.")

;;; zpurgevars ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; /zpurge_vars <variable mask>
;  example:
;    /Zpurgevars sb*
;        purges(unsets) all variables starting with sb
;
/def Zpurgevars = \
        /let purge_vars=$(/listvar -s %{*})%;\
        /let off=$[strchr(purge_vars," ")]%;\
        /while (off>-1) \
           /unset $[substr(purge_vars,0,off)]%;\
           /let purge_vars=$[substr(purge_vars,off+1)]%;\
           /let off=$[strchr(purge_vars," ")]%;\
        /done%;\
        /unset %purge_vars
/test zhelp_add("zmacros_zpurgevars","SYNTAX /zpurgevars <mask>. Purges(unsets) all variables matching <mask> ie /zpurgevars sb* purges all variables starting with sb. Be carefull!")

;;; ReadVars ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Reads in the file Zvars.tfrc that was written by WriteVars
;
/def ReadVars = /load ~/tf/Zvars.tfrc
/test zhelp_add("zmacros_readvars","Reads in the file Zvars.tfrc that was written by writevars. Used to store states of several systems.")

;;; reco = Re-arrange Corpse ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; /reco start end
;
/def reco = \
    /let start=%{1}%; \
    /let end=%{2}%; \
    /if (end !~ "") /let count=$[end-start+1]%; /endif%; \
    /if ((start =~ "") | (count =~"")) \
        /test ppnotice(2, "Syntax is @{B}/reco <start> <count>@{n}")%; \
        /return 0%; \
    /endif%; \
    /let i=0%; \
    /while (++i <= count) \
        /send drop preservation $[start]%; \
    /done%; \
    /let i=0%; \
    /while (++i <= count) \
        /send take preservation%; \
    /done%; \
    /send hp
/test zhelp_add("zmacros_reco","Re-arrange Corpse. Drop then pick up corspes from <start> to <end>. ei /reco 2 8")

;;; report ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; /report [say|lt|tell|chat|emote]
;
/def report = \
    /let mode=%{1}%; \
    /if (mode=~"say") \
        /eval /send say \
            HP[%{SB_chp}(%{SB_fhp})/%{SB_mhp}|%{SB_php}% |%{SB_dhp}] \
            SP[%{SB_csp}(%{SB_fsp})/%{SB_msp}] NP[%{SB_cnp}/%{SB_mnp}|%{SB_icc}]%; \
    /elseif (mode=~"lt") \
        /eval /send talke acts like a jugger and reports: \
            HP[%{SB_chp}(%{SB_fhp})/%{SB_mhp}|%{SB_php}% |%{SB_dhp}] \
            SP[%{SB_csp}(%{SB_fsp})/%{SB_msp}] NP[%{SB_cnp}/%{SB_mnp}|%{SB_icc}]%; \
    /elseif (mode=~"emote") \
        /eval /send emote acts like a jugger and reports: \
            HP[%{SB_chp}(%{SB_fhp})/%{SB_mhp}|%{SB_php}% |%{SB_dhp}] \
            SP[%{SB_csp}(%{SB_fsp})/%{SB_msp}] NP[%{SB_cnp}/%{SB_mnp}|%{SB_icc}]%; \
    /elseif (mode=~"chat") \
        /eval /send echat acts like a jugger and reports: \
            HP[%{SB_chp}(%{SB_fhp})/%{SB_mhp}|%{SB_php}% |%{SB_dhp}] \
            SP[%{SB_csp}(%{SB_fsp})/%{SB_msp}] NP[%{SB_cnp}/%{SB_mnp}|%{SB_icc}]%; \
    /elseif (mode=~"tell") \
        /eval /send tell %{2} \
            HP[%{SB_chp}(%{SB_fhp})/%{SB_mhp}|%{SB_php}% |%{SB_dhp}] \
            SP[%{SB_csp}(%{SB_fsp})/%{SB_msp}] NP[%{SB_cnp}/%{SB_mnp}|%{SB_icc}]%; \
    /else \
        /test PPNotice(3,"Syntax is /report [say|lt|tell|chat|emote]")%; \
    /endif
/test zhelp_add("zmacros_report","Semi-silly routine to report stats. ie /report [say|lt|tell|chat|emote]")

;;; sm ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; shows whats in smuggle
;
/def sm = /CmdParse smuggle/hp
/test zhelp_add("zmacros_sm","Shows what is in smuggle pocket")

;;; smc = Smuggle Corpse ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; /smc [start] [end]
;
/def smc = \
    /let start=%{1}%; \
    /let end=%{2}%; \
    /if (end !~ "") /let count=$[end-start+1]%; /endif%; \
    /if (start =~ "") \
        /send smuggle preservation%; \
    /elseif ((start != "") & (count =~ "")) \
        /send smuggle preservation $[start]%; \
    /elseif ((start != "") & (count != "")) \
        /let i=0%; \
        /while (++i <= count) \
            /send smuggle preservation $[start]%; \
        /done%; \
    /endif%; \
    /send hp
/test zhelp_add("zmacros_smc","Sumggles selected corpses. ie /smc [start] [end]")

;;; smrc = Smuggle Remove Corpse ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; /smrc [start] [end]
;
/def smrc = \
    /let start=%{1}%; \
    /let end=%{2}%; \
    /if (end !~ "") /let count=$[end-start+1]%; /endif%; \
    /if (start =~ "") \
        /send smuggle remove preservation%; \
    /elseif ((start != "") & (count =~ "")) \
        /send smuggle remove preservation $[start]%; \
    /elseif ((start != "") & (count != "")) \
        /let i=0%; \
        /while (++i <= count) \
            /send smuggle remove preservation $[start]%; \
        /done%; \
    /endif%; \
    /send hp
/test zhelp_add("zmacros_smrc","Unsumggles selected corpses. ie /smrc [start] [end]")

;;; smra ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; fills inventory with smuggled corpes
;
/def smra = /CmdParse smuggle remove all/hp
/test zhelp_add("zmacros_smra","Unsumggles all corpses you can. ie /smra ")

;;; tcf = Take Corpse Tollower ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; /tcf [start] [end]
;
/def tcf = \
    /let start=%{1}%; \
    /let end=%{2}%; \
    /if (end !~ "") /let count=$[end-start+1]%; /endif%; \
    /if (start =~ "") \
        /send #get preservation%; \
    /elseif ((start != "") & (count =~ "")) \
        /send #get preservation $[start]%; \
    /elseif ((start != "") & (count != "")) \
        /let i=0%; \
        /while (++i <= count) \
            /send #get preservation $[start]%; \
        /done%; \
    /endif%; \
    /send hp
/test zhelp_add("zmacros_tcf","Follower takes selected corpses. /tcf [start] [end]")

;;; tcm = Take Corpse Me ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; /tcm [start] [end]
;
/def tcm = \
    /let start=%{1}%; \
    /let end=%{2}%; \
    /if (end !~ "") /let count=$[end-start+1]%; /endif%; \
    /if (start =~ "") \
        /send take preservation%; \
    /elseif ((start != "") & (count =~ "")) \
        /send take preservation $[start]%; \
    /elseif ((start != "") & (count != "")) \
        /let i=0%; \
        /while (++i <= count) \
            /send take preservation $[start]%; \
        /done%; \
    /endif%; \
    /send hp
/test zhelp_add("zmacros_tcm","Take selected corpses. /tcm [start] [end]")

;;; unbag ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; /unbag <item>
;
/def unbag = /send take %{-1} from bag %{1}
/test zhelp_add("zmacros_unbag","Takes <item> from bag . sytax /unbag <bag> <item> ie '/unbag 2 sword 4' takes sword 4 from bag 2.")

;;; unbox ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; /unbox <item>
;
/def unbox = /send take %* from box
/test zhelp_add("zmacros_unbox","Takes <item> from box. ie /unbox sword")

;;; unboxc = take corpse from box ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; /unboxc [start] [end]
;
/def unboxc = \
    /let start=%{1}%; \
    /let end=%{2}%; \
    /if (end !~ "") /let count=$[end-start+1]%; /endif%; \
    /if (start =~ "") \
        /send take preservation from box%; \
    /elseif ((start != "") & (count =~ "")) \
        /send take preservation $[start] from box%; \
    /elseif ((start != "") & (count != "")) \
        /let i=0%; \
        /while (++i <= count) \
            /send take preservation $[start] from box%; \
        /done%; \
    /endif%; \
    /send hp
/test zhelp_add("zmacros_unboxc","Takes selected corpses from box ie. /unboxc 2 8")

;;; unchest ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; /unchest <item>
;
/def unchest = \
    /let item=%*%; \
    /CmdParse retrieve/open chest/take $[item] from chest/close chest/deliver
/test zhelp_add("zmacros_unchest","Takes <item> from chest. ie /unbag sword")

;;; uwrc = Unwrap Corpse ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; /uwrc [start] [count]
;
/def uwrc = \
    /let start=%{1}%; \
    /let count=%{2}%; \
    /if (start =~ "") \
        /send unwrap%; \
    /elseif ((start != "") & (count =~ "")) \
        /send unwrap $[start]%; \
    /elseif ((start != "") & (count != "")) \
        /let i=0%; \
        /while (++i <= count) \
            /send unwrap $[start]%; \
        /done%; \
    /endif%; \
    /send hp
/test zhelp_add("zmacros_uwrc","Unwrap selected corpses from coffin. ie /uwrc [start] [count] or /uwrc 2 8")

;;; wrc = wrap Corpse ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; /wrc [count]
;
; /wrc
;     wrap
;
; /wrc 3
;    wrap
;    wrap
;    wrap
;
/def wrc = \
    /let count=%{1}%; \
    /let fubar=%{2}%; \
    /if (fubar != "") \
        /test ppnotice(2, "SYNTAX IS @{B}/wrc [count]@{n}")%; \
        /return 0%; \
    /endif%; \
    /if (count =~ "") \
        /send wrap%; \
    /elseif (count != "") \
        /let i=0%; \
        /while (++i <= count) \
            /send wrap%; \
        /done%; \
    /endif%; \
    /send hp
/test zhelp_add("zmacros_wrc","Wrap corpses in coffin starting on the ground and going to inventory. \
    Note that coffin goes nuts sometimes and switches out corpses with you when it is full. \
    ie /uwrc [count] or /wrc 2")

;;; Write Variables to a file ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; no arguments - no returns
;
/def WriteVars = \
    /eval /listvar fs_* %| /writefile Zvars.tfrc%; \
    /eval /listvar auto* %| /writefile -a Zvars.tfrc%; \
    /eval /listvar combat* %| /writefile -a Zvars.tfrc%; \
    /eval /listvar SB* %| /writefile -a Zvars.tfrc%; \
    /eval /listvar ZMine_Cutoff_* %| /writefile -a Zvars.tfrc%; \
    /eval /listvar MATRIX_maxstash__* %| /writefile -a Zvars.tfrc%; \
    /eval /listvar MATRIX_mobs__* %| /writefile -a Zvars.tfrc%; \
    /test ppnotice(4, "Zvars.tfrc File Written")
/test zhelp_add("zmacros_writevars","Writes variables into zvars.tfrc. \
    Currently suports Zcombat, Zbattle, Zstatus, Zcraft, ZMine and Zauto systems.")

;;; ztextencode ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; syntax ztextencode(<string>)
; returns string with spaces and commas replaced with underlines
; 
/def ztextencode = \
    /if ({*}=~"") \
        /echo -p -- $[zutoc({0},"BCyellow")] Syntax is /test dummy:=ztextencode(<string>).%; \
        /return -1%; \
    /endif%; \
    /return replace(",","_",replace(" ","_",{*}))

;;; Zutoc ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; replaces underlines with colons helper routine 
; syntax: zutos(<stringtoconvert>[,<attr>])
; example: /echo -p -- $[zutoc({0},"BCgreen")] No bag found.
/def Zutoc = \
    /let line=$[replace("_",":",{1})]%; \
    /let x=@{n}%; \
    /if ({2} !~ "") \
        /let line=$[strcat("@{",{2},"}",line,":",{x})]%; \
    /else \
        /let line=$[line,":"]%; \
    /endif%; \
    /return strcat({line})

;;; ZStripSpace ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; removes leading and trailing spaces helper routine
; syntax: /test <var>:=ZStripSpace(<string>)
; example: /let component=$[zstripspace({P1})]%; \
;
/def zstripspace = \
    /let line=%*%; \
    /let line=$[regmatch('^ *(.*?) *$', {*}), {P1}]%; \
    /return {line}
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License