What I basically did was copy the code from
http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=4176
To total up the stats. Here is the code below so you can see how I've modified it so far. The goal is to put these stats into a stats miniwindow I have created.
<triggers>
<trigger
enabled="n"
expand_variables="y"
keep_evaluating="y"
match="(int:|wis:|dex:|str:|chr:|con:|luc:|dmg:|hr:|da:|ma:|svs:)(\D*\d+)"
name="additup"
regexp="y"
repeat="y"
script="attrib_trigger_script"
send_to="12"
sequence="100"
>
</trigger>
<trigger
enabled="n"
match="You are using:"
name="clearoldstats"
script="start_of_equip_list"
sequence="100"
>
</trigger>
</triggers>
<aliases>
<alias
match="update eq stats"
enabled="y"
send_to="12"
sequence="100"
>
<send>EnableTrigger("clearoldstats", true)
EnableTrigger("additup", true)
Send "eq"
DoAfterSpecial (2, 'EnableTriggerGroup ("clearoldstats", false)', sendto.script)
DoAfterSpecial (2, 'EnableTriggerGroup ("additup", false)', sendto.script)
</send>
</alias>
</aliases>
<script>
<![CDATA[
function attrib_trigger_script (name, line, wildcards)
-- function to handle individual matches
local function one_attrib (m, t)
local name = "attrib_" .. string.gsub (t [1], ":", "")
local value = tonumber (t [2])
SetVariable (name, tonumber (GetVariable (name) or 0) + value)
end -- one_herb
local re = rex.new (GetTriggerInfo (name, 1)) -- get the match text, make into a regexp
re:gmatch (line, one_attrib) -- match repeatedly, call function
end -- attrib_trigger_script
function start_of_equip_list (name, line, wildcards)
for k, v in pairs (GetVariableList()) do
if string.match (k, "^attrib_") then
DeleteVariable (k)
end -- one of the attrib_* variables
end
end -- start_of_equip_list
]]>
</script>
While testing to print out the stat list, I used this.
<aliases>
<alias
script="show_equip_list"
match="show attribs"
enabled="y"
sequence="100"
>
</alias>
and for the function
function show_equip_list (name, line, wildcards)
for k, v in pairs (GetVariableList()) do
if string.match (k, "^attrib_") then
k = string.gsub (k, "^attrib_dex", "dex")
k = string.gsub (k, "^attrib_da", "da")
k = string.gsub (k, "^attrib_con", "con")
k = string.gsub (k, "^attrib_luc", "luc")
k = string.gsub (k, "^attrib_ma", "ma")
k = string.gsub (k, "^attrib_int", "int")
k = string.gsub (k, "^attrib_svs", "svs")
k = string.gsub (k, "^attrib_dmg", "dmg")
k = string.gsub (k, "^attrib_wis", "wis")
k = string.gsub (k, "^attrib_hr", "hr")
k = string.gsub (k, "^attrib_chr", "chr")
k = string.gsub (k, "^attrib_str", "str")
print (k, v)
end -- one of the attrib_* variables
end
end -- show_equip_list
So what I mainly need is a way to pull out just the values so I can put them into the stats miniwindow, which is already labeled with the names, just not the values.
Hope this clears things up?
See how it gets the entire variable list. Maybe if I weren't so confused I could use your reply and somehow modify it to work like that so I can pull the values out for the stats miniwindow. |