Hi... me again... this time I decided to try to see if I could make things work more like the suggestions in the other post about variables, or at least begin to work towards that... the issue is that I'm trying to do some slightly odd things, I think, and I'm not sure exactly whether or not they're supported. Anyways, here's the code I've worked out so far... 3 triggers, and an alias. First the triggers.
<triggers>
<trigger
lines_to_match="3"
match="\n\nYour aura is"
multi_line="y"
name="spell_stopper"
regexp="y"
send_to="12"
sequence="40"
>
<send>
-- don't need to track inventories any more
EnableTrigger ("spell_line", false)
EnableTrigger ("spell_stopper", false)
-- in case no table yet
spell_table = spell_table or {}
table.sort (spell_table)
SetVariable ("spell_table", serialize.save ("spell_table"))</send>
</trigger>
<trigger
match="([a-z]*)([\s]*)([a-z_\']*)([\s]*)([0-9]*)([\s]*)([a-z_\-]*)([\s]*)([a-zA-Z]*)"
name="spell_line"
regexp="y"
send_to="12"
sequence="50"
>
<send>
spell_table.%1 = {}
spell_table.%1.initials = "%1"
spell_table.%1.name = "%3"
spell_table.%1.time = %5
spell_table.%1.cost = "%7"
spell_table.%1.count = "%9"
</send>
</trigger>
<trigger
enabled="y"
group="Multi Line"
lines_to_match="2"
keep_evaluating="y"
match="Abbr Name Time Cost Skill \n\=\=\=\=\= \=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\= \=\=\=\= \=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\= \=\=\=\=\=\=\=\=\=\=\Z"
multi_line="y"
regexp="y"
send_to="12"
sequence="100"
>
<send>
spell_table = {}
EnableTrigger ("spell_line", true)
EnableTrigger ("spell_stopper", true)
</send>
</trigger>
</triggers>
And the alias:
<aliases>
<alias
match="spelltable"
enabled="y"
send_to="12"
ignore_case="y"
sequence="100"
>
<send>print ("Your spells are:")
for _, item in ipairs (spell_table) do
print (item)
end -- for
</send>
</alias>
</aliases>
Right now, I have this automatically serializing, so I can see that it's properly working... Basically, I have it match the top line of description for spells, then parsing each row, which goes in like this...
lowercase letters, lowercase letters with apostrophes and underscores, numbers, lowercase letters with hyphens, and upper and lowercase letters.
This part seems to work, according to my serialization... what I'd really like for it to do though, is to properly display (my alias is all sorts of screwed up), use the proper names instead of the initials, and if possible to look up my current variables for the count. The issue is that I have to run the variables through a cleaner to make them actually save properly, because they include apostrophes and other things that don't work right as MUSHclient variable names (or apparently lua table names, based on earlier errors, which is why I'm using the initials instead of the actual spell name for my tables). I'm using the following bit of code to actually set my variables:
<triggers>
<trigger
enabled="y"
match="^(> )?\* You think your ([a-z#_\' -]*) skill has improved\. \*"
regexp="y"
send_to="12"
sequence="100"
>
<send>local SkillName = string.gsub("%2", "[ '#-]", "_")
SetVariable(SkillName .. "_skill", (GetVariable(SkillName .. "_skill") or 0) + 1)
Execute("skill " .. SkillName)
SetChanged (true)
Save("")</send>
</trigger>
</triggers>
As you can see, it's doing a gsub to take the skill name (spells are a subset of skill, but they improve in the same display method) and take out any spaces, apostrophes, number signs, or hyphens, and turn them into underscores, which MUSHclient actually likes... the issue is, how do I tell lua that I'm actually giving it a variable name to save instead of just giving it a static part... When I tried to use SkillName or SpellName (I changed the gsub for the spell trigger) to do this, it just made that the entry for the table...
As well, my lookup isn't working. This is the most working it's been... it now shows the names of each of the tables and the raw data... here's an example:
Problem is, when I tried to have it show item.name, for example, it doesn't give me anything at all... serialize lets me see that it is actually saving properly, it's just not retrieving it.
Was well I'd like for it to also look up the variable using either the var function or GetVariable client function and save that instead of the text, at least until I update them and get them to save into the table if I can get both of the upper two issues working properly. While having it display both the text and number wouldn't be a problem, I'd prefer to do that as a check later, so that I can have it make the skill display brightly if my counts are off... I care more about the actual number then the somewhat descriptive name for it. If I have the local variable thing working, I think I can probably figure this out, but currently it's not working properly.
Thanks... this is the start of a relatively major new tabling project for me. Serialization appears to be working wonderfully, and was especially useful for setting up the proper regexp strings to make the trigger match up. |