Difference between revisions of "Label.tf"

From AvatarWiki
Jump to navigation Jump to search
(/label grabs information from identify and labels an item)
 
m (Adds -s0 to the /eval we do on exit, no substitution needed)
 
(7 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
To see the results without actually labeling just use "/label <item>" while not standing at Edmuntrillion the ent.  When you're confident, go to the ent and do something like "remove all.acitem" and "/for c 1 16 /label %c.acitem"  ;)
 
To see the results without actually labeling just use "/label <item>" while not standing at Edmuntrillion the ent.  When you're confident, go to the ent and do something like "remove all.acitem" and "/for c 1 16 /label %c.acitem"  ;)
 
<BR><BR>
 
<BR><BR>
Bug reports, suggestions and/or diffs are appreciated, '''sulfar''' _AT_ ''inbox'' +DOT+ ''com''
 
  
Probable issue: If your identify lag is less than half a second the script will mess up.
+
New version:
 +
* kinda supports treasure/light
 +
* produces less spam in the room, it uses a get instead of a say to grab the keyword
 +
* implements a -x<command on exit> option much like the identify script to make it useful for other scripts.
 +
* fixes a minor bug, hr/dr enchants didn't make it into the label if the item was 0/0 by itself.  Now it'll just add hr/dr no matter what.  Also, draw strength shows up in the label.
 +
* identify now uses prompt_exe to get rid of the /repeat... meaning identify lag doesn't matter anymore
  
<pre>
 
; Label.tf
 
  
;Current label format:
+
To use this script you'll need [[verbose.tf]], [[identify.tf]] and [[prompt.tf]].  The identify script tries to use [[regen.tf]] if you're out of mana, but you dont really need that for the label stuff.  You should have TINYPREFIX set in your config file, pointing at the directory with tf scripts like
;
+
<pre>/set TINYPREFIX=~/tinyfugue/</pre>
;armor: l<level> b<base> [<enchant>] [<etch>]
 
;weapon: l<level> <min>-<avg>-<max> <hr>/<dr> w<weight> [<etch>]
 
;bow: l<level> <min>-<avg>-<max> [<hr>hr] [ds<drawstrength>] [<etch>]
 
;container: l<level> c<capacity> w<weight> [<etch>]
 
  
/echo -aCyellow %% /label <item>     Label item
+
<pre>
 
+
;Bug reports, suggestions and/or diffs are appreciated, '''sulfar''' _AT_ ''inbox'' +DOT+ ''com''
/def -i label_init_vars = \
 
    /set label_keyword=%;\
 
    /set label_string=%;\
 
    /set id_etch=%;\
 
    /set id_weight=%;\
 
    /set id_value=%;\
 
    /set id_level=%;\
 
    /set id_object_type=%;\
 
    /set id_base_armor=%;\
 
    /set id_enchant_armor=%;\
 
    /set id_draw_strength=%;\
 
    /set id_hr=%;\
 
    /set id_dr=%;\
 
    /set id_enchant_weapon=%;\
 
    /set id_enchant_bow=%;\
 
    /set id_dam_min=%;\
 
    /set id_dam_max=%;\
 
    /set id_dam_avg=%;\
 
    /set id_container_capacity=%;\
 
    /set _do_label_pid=
 
  
/label_init_vars
+
/loaded __SULFAR__/label.tf
  
/def -i label = \
+
/eval /require -q %{TINYPREFIX}identify.tf
    say %%% Identifying: %1%;\
+
/eval /require -q %{TINYPREFIX}verbose.tf
    c identify %1
 
  
/def -i -p900 -F -mregexp -t"You say '%% Identifying: ([^ ]+)'" label_keyword = \
+
/echo -aCyellow %% /label <item>        Label item
    /label_init_vars%;\
+
/echo -aCyellow %%    [-x<command>]        execute command after label
    /set labeling 1%;\
 
    /set label_keyword %{P1}%;\
 
     /repeat -0.5 1 /do_label%;\
 
    /set _do_label_pid=%?
 
  
/def -i -p900 -F -E(labeling) -t"You failed your identify due to lack of concentration!" id_failed = \
+
;Current label format:
    /@test _do_label_pid & (kill(_do_label_pid), _do_label_pid:=0)%;\
+
;
    say %%% I lost my concentration identifying %{label_keyword}!  Retrying...%;\
+
;armor:      l<level> b<base> [<enchant>] [<etch>]
     /label %{label_keyword}
+
;weapon:      l<level> <min>-<avg>-<max> <hr>/<dr> w<weight> [<etch>]
 +
;bow:        l<level> <min>-<avg>-<max> [ds<drawstrength>] <hr>hr [<etch>]
 +
;container:   l<level> c<capacity> w<weight> [<etch>]
 +
;light:      l<level> [<etch>]
 +
;treasure     l<level> [<etch>]
  
/def -i -p900 -F -mregexp -E(labeling) -t"Object '.+ ([^ ]+)' type ([^ ]+), extra flags.+etched." id_object_etched = \
+
;Set to 0-3 to override system verbosity level
    /set id_object_type %{P2}%;\
+
;Set to -100 to disable script verbosity level and keep system verbosity level
    /set id_etch %{P1}%;\
+
;see verbose.tf
 +
/verbose -s-100 label
  
/def -i -p900 -F -mregexp -E(labeling) -t"Object '.+' type ([^ ]+), extra flags*" id_object = \
+
/def -i label = \
    /set id_object_type %{P1}
+
        /if (!getopts("x:", "")) /return 0%; /endif%; \
 
+
        /set label_post %{opt_x}%;\
/def -i -p900 -F -mregexp -E(labeling) -t"Weight ([^ ]+), value ([^ ]+), level ([^ ]+)." id_level = \
+
        /verbose -o%{verbosity_label} -l1 - -aCcyan %%% /%0: Labeling. Post command is %{label_post}%;\
    /set id_weight %{P1}%;\
+
        /identify -e"get %1labeleok" -x/label_identify_done %1
    /set id_value %{P2}%;\
 
    /set id_level %{P3}
 
 
 
/def -i -p900 -F -mregexp -E(labeling) -t"Armor class is ([^ ]+)." id_base_armor = \
 
    /set id_base_armor %{P1}
 
 
 
/def -i -p900 -F -mregexp -E(labeling) -t"Damage is ([^ ]+) to ([^ ]+) \(average ([^ ]+)\)." id_dam = \
 
    /set id_dam_min %{P1}%;\
 
    /set id_dam_max %{P2}%;\
 
    /set id_dam_avg %{P3}
 
 
 
/def -i -p900 -F -mregexp -E(labeling) -t"'enchant armor 'Modifies armor class by ([^ ]+) continuous." id_enchant_armor = \
 
    /set id_enchant_armor %{P1}
 
 
 
/def -i -p900 -F -mregexp -E(labeling) -t" Modifies damage roll by ([^ ]+) continuous." id_dr = \
 
    /set id_dr %{P1}
 
/def -i -p900 -F -mregexp -E(labeling) -t" Modifies hit roll by ([^ ]+) continuous." id_hr = \
 
    /set id_hr %{P1}
 
 
 
/def -i -p900 -F -mregexp -E(labeling) -t"'enchant weapon 'Modifies damage roll by ([^ ]+) continuous." id_enchant_weapon = \
 
    /set id_enchant_weapon %{P1}
 
 
 
/def -i -p900 -F -mregexp -E(labeling) -t"'enchant bow    'Modifies hit roll by ([^ ]+) continuous." id_enchant_bow = \
 
    /set id_enchant_bow %{P1}
 
  
/def -i -p900 -F -mregexp -E(labeling) -t"Draw strength is ([^ ]+)." id_enchant_draw_strength = \
+
;Setting global variable identify_grab to make /label work in loops
    /set id_draw_strength %{P1}
+
;That's ok because the last identify comes after this trigger and sets
 +
;  identify_grab to 0 anyways.
 +
/def -i -p900 -F -mregexp -t"^I see no ([^ ]+)labeleok here.$" label_keyword = \
 +
        /set identify_grab 1%;\
 +
        /set label_keyword %{P1}%;\
 +
        /verbose -o%{verbosity_label} -l2 - -aCyellow %%% /%0: Got keyword, %{label_keyword}
  
/def -i -p900 -F -mregexp -E(labeling) -t"Capacity is ([^ ]+) lbs." id_container_capacity = \
+
/def -i label_identify_done = \
    /set id_container_capacity %{P1}
+
        /verbose -o%{verbosity_label} -l2 - -aCyellow %%% /%0: Compiling label string and labeling.%;\
 
+
        /let label_string=%;\
/def -i do_label = \
+
        /let _post=%{label_post}%;\
    /if (regmatch ("weapon", id_object_type))\
+
        /if (regmatch ("armor|weapon|bow|container|light|treasure", identify_type))\
        /set label_string l%{id_level}%;\
+
                /let label_string l%{identify_level}%;\
        /set label_string %{label_string} %{id_dam_min}-%{id_dam_avg}-%{id_dam_max}%;\
+
                /if (identify_type =~ "armor") \
;       /set label_string %{label_string} m%{id_dam_max}%;\
+
                        /let label_string %{label_string} b%{identify_armor_class}%;\
        /if ((id_hr>0)|(id_dr>0))\
+
                        /if (identify_enchant_armor < 0) \
            /set label_string %{label_string} $[id_hr+id_enchant_weapon]/$[id_dr+id_enchant_weapon]%;\
+
                                /let label_string %{label_string} %{identify_enchant_armor}%;\
        /endif%;\
+
                        /endif%;\
        /set label_string %{label_string} w%{id_weight}%;\
+
                /elseif (identify_type =~ "weapon") \
    /elseif (regmatch ("bow", id_object_type))\
+
                        /let label_string %{label_string} %{identify_dam_min}-%{identify_dam_avg}-%{identify_dam_max}%;\
        /set label_string l%{id_level}%;\
+
                        /let label_string %{label_string} $[identify_hr+identify_enchant_weapon]/$[identify_dr+identify_enchant_weapon]%;\
        /set label_string %{label_string} %{id_dam_min}-%{id_dam_avg}-%{id_dam_max}%;\
+
                        /let label_string %{label_string} w%{identify_weight}%;\
        /if (id_hr>0)\
+
                /elseif (identify_type =~ "bow") \
            /set label_string %{label_string} $[id_hr+id_enchant_bow]hr%;\
+
                        /let label_string %{label_string} %{identify_dam_min}-%{identify_dam_avg}-%{identify_dam_max}%;\
        /endif%;\
+
                        /if (identify_draw_strength !~ "") \
        /if (id_draw_strength !~ "") \
+
                                /let label_string %{label_string} ds%{identify_draw_strength}%;\
            /set label_string %{label_string} ds%{id_draw_strength}%;\
+
                        /endif%;\
        /endif%;\
+
                        /let label_string %{label_string} $[identify_hr+identify_enchant_bow]hr%;\
    /elseif (regmatch ("armor", id_object_type))\
+
                /elseif (identify_type =~ "container") \
        /set label_string l%{id_level}%;\
+
                        /let label_string %{label_string} c%{identify_capacity}%;\
        /set label_string %{label_string} b%{id_base_armor}%;\
+
                        /let label_string %{label_string} w%{identify_weight}%;\
         /if (id_enchant_armor<0) \
+
                /endif%;\
            /set label_string %{label_string} %{id_enchant_armor}%;\
+
                /if (identify_etch !~ "") \
 +
                        /let label_string %{label_string} %{identify_etch}%;\
 +
                /endif%;\
 +
                /verbose -o%{verbosity_label} -l1 - -aCcyan %%% /%0: Labeling %{label_keyword} %{label_string}%;\
 +
                label %{label_keyword} %{label_string}%;\
 +
         /else /verbose -o%{verbosity_label} -l1 - -aCcyan %%% /%0: I have no idea how to label %{label_keyword} of type %{identify_type}, sorry.%;\
 
         /endif%;\
 
         /endif%;\
    /elseif (regmatch ("container", id_object_type))\
+
         /unset label_post%;\
         /set label_string l%{id_level}%;\
+
         /unset label_keyword%;\
         /set label_string %{label_string} c%{id_container_capacity}%;\
+
         /if (_post !~ "") /eval -s0 %{_post}%; /endif
         /set label_string %{label_string} w%{id_weight}%;\
 
    /endif%;\
 
    /if (id_etch !~ "") \
 
        /set label_string %{label_string} %{id_etch}%;\
 
    /endif%;\
 
    /if (regmatch ("armor|weapon|container|bow", id_object_type))\
 
        say %%% Labeling %{label_keyword} %{label_string}%;\
 
        label %{label_keyword} %{label_string}%;\
 
    /elseif (regmatch ("trash|treasure|key", id_object_type)) \
 
        say %%% I do not label %{label_keyword} of type %{id_object_type}.%;\
 
    /else say %%% I have no idea how to label %{label_keyword}, sorry.%;\
 
    /endif%;\
 
    /set labeling 0%;\
 
    /label_init_vars
 
 
</pre>
 
</pre>
  
  
 
[[Category: TinyFugue Scripting]]
 
[[Category: TinyFugue Scripting]]

Latest revision as of 05:35, 8 November 2008

To see the results without actually labeling just use "/label <item>" while not standing at Edmuntrillion the ent. When you're confident, go to the ent and do something like "remove all.acitem" and "/for c 1 16 /label %c.acitem" ;)

New version:

  • kinda supports treasure/light
  • produces less spam in the room, it uses a get instead of a say to grab the keyword
  • implements a -x<command on exit> option much like the identify script to make it useful for other scripts.
  • fixes a minor bug, hr/dr enchants didn't make it into the label if the item was 0/0 by itself. Now it'll just add hr/dr no matter what. Also, draw strength shows up in the label.
  • identify now uses prompt_exe to get rid of the /repeat... meaning identify lag doesn't matter anymore


To use this script you'll need verbose.tf, identify.tf and prompt.tf. The identify script tries to use regen.tf if you're out of mana, but you dont really need that for the label stuff. You should have TINYPREFIX set in your config file, pointing at the directory with tf scripts like

/set TINYPREFIX=~/tinyfugue/
;Bug reports, suggestions and/or diffs are appreciated, '''sulfar''' _AT_ ''inbox'' +DOT+ ''com''

/loaded __SULFAR__/label.tf

/eval /require -q %{TINYPREFIX}identify.tf
/eval /require -q %{TINYPREFIX}verbose.tf

/echo -aCyellow %% /label <item>         Label item
/echo -aCyellow %%     [-x<command>]         execute command after label

;Current label format:
;
;armor:       l<level> b<base> [<enchant>] [<etch>]
;weapon:      l<level> <min>-<avg>-<max> <hr>/<dr> w<weight> [<etch>]
;bow:         l<level> <min>-<avg>-<max> [ds<drawstrength>] <hr>hr [<etch>]
;container:   l<level> c<capacity> w<weight> [<etch>]
;light:       l<level> [<etch>]
;treasure     l<level> [<etch>]

;Set to 0-3 to override system verbosity level
;Set to -100 to disable script verbosity level and keep system verbosity level
;see verbose.tf
/verbose -s-100 label

/def -i label = \
        /if (!getopts("x:", "")) /return 0%; /endif%; \
        /set label_post %{opt_x}%;\
        /verbose -o%{verbosity_label} -l1 - -aCcyan %%% /%0: Labeling.  Post command is %{label_post}%;\
        /identify -e"get %1labeleok" -x/label_identify_done %1

;Setting global variable identify_grab to make /label work in loops
;That's ok because the last identify comes after this trigger and sets
;  identify_grab to 0 anyways.
/def -i -p900 -F -mregexp -t"^I see no ([^ ]+)labeleok here.$" label_keyword = \
        /set identify_grab 1%;\
        /set label_keyword %{P1}%;\
        /verbose -o%{verbosity_label} -l2 - -aCyellow %%% /%0: Got keyword, %{label_keyword}

/def -i label_identify_done = \
        /verbose -o%{verbosity_label} -l2 - -aCyellow %%% /%0: Compiling label string and labeling.%;\
        /let label_string=%;\
        /let _post=%{label_post}%;\
        /if (regmatch ("armor|weapon|bow|container|light|treasure", identify_type))\
                /let label_string l%{identify_level}%;\
                /if (identify_type =~ "armor") \
                        /let label_string %{label_string} b%{identify_armor_class}%;\
                        /if (identify_enchant_armor < 0) \
                                /let label_string %{label_string} %{identify_enchant_armor}%;\
                        /endif%;\
                /elseif (identify_type =~ "weapon") \
                        /let label_string %{label_string} %{identify_dam_min}-%{identify_dam_avg}-%{identify_dam_max}%;\
                        /let label_string %{label_string} $[identify_hr+identify_enchant_weapon]/$[identify_dr+identify_enchant_weapon]%;\
                        /let label_string %{label_string} w%{identify_weight}%;\
                /elseif (identify_type =~ "bow") \
                        /let label_string %{label_string} %{identify_dam_min}-%{identify_dam_avg}-%{identify_dam_max}%;\
                        /if (identify_draw_strength !~ "") \
                                /let label_string %{label_string} ds%{identify_draw_strength}%;\
                        /endif%;\
                        /let label_string %{label_string} $[identify_hr+identify_enchant_bow]hr%;\
                /elseif (identify_type =~ "container") \
                        /let label_string %{label_string} c%{identify_capacity}%;\
                        /let label_string %{label_string} w%{identify_weight}%;\
                /endif%;\
                /if (identify_etch !~ "") \
                        /let label_string %{label_string} %{identify_etch}%;\
                /endif%;\
                /verbose -o%{verbosity_label} -l1 - -aCcyan %%% /%0: Labeling %{label_keyword} %{label_string}%;\
                label %{label_keyword} %{label_string}%;\
        /else /verbose -o%{verbosity_label} -l1 - -aCcyan %%% /%0: I have no idea how to label %{label_keyword} of type %{identify_type}, sorry.%;\
        /endif%;\
        /unset label_post%;\
        /unset label_keyword%;\
        /if (_post !~ "") /eval -s0 %{_post}%; /endif