Aardwolf Plugins

Posted by Starky on Wed 04 Jun 2008 05:59 PM — 17 posts, 71,783 views.

#0
I've got two to post here first I need help on second is just because I wrote it to fill a gap that nobody seems to have coded for.

The first one is that speedwalker plugin Lasher has asked for it searches speedwalks keywords pulls out the area names and speedwalks and creates aliases so that you can have a plugin that only uses 1 command to update itself instead of having to manually update it every time an area is added but I'm running into two problems:

1) First of all I can't seem to get the AddAlias command to work properly, I've got it to the point where the GetAlias command I've added that uses the getaliasinfo function shows all of the areas on the alias list and the aliasinfo command I"ve added shows the speedwalk under the info but they won't activate at all when trying to use them. I dont know if I have to use some special command structure to activate the aliases once they're added or what.

2) Secondly I tried using the DoAfterSpecial function so that it would switch on for so many seconds capture then switch off but using that it would always miss the first page of speedwalks for some reason so I've switched to a simple EnableTriggerGroup true argument the problem being theres no way to switch it off. I've asked Lasher if he could add an endline onto the speedwalks command so that I could have it switch off using that to which he agreed but he's been busy with the academy and hasnt done that yet. So in the meantime I have it trying to trigger to switch off using the last speedwalk on the list but the trigger refuses to activate.

anyways heres the script I realize it's horribly inefficient but I"m still teaching myself Lua and I'm trying not to get ahead of myself


<muclient>
<plugin
	name="Speedwalker"
	author="Starky"
	id="a234cd0873b23a1f234e826f"
	language="lua"
	purpose="Runto Command Plugin"
	date_written="2008-05-26 23:10:20"
	save_state="y"
	>
<description trim="n">
<![CDATA[
Only one command for this plugin

swalkupdate                             - updates the alias list with speedwalks to areas
]]>
</description>
</plugin>



<aliases>
	<alias
	match="^swalkupdate$"
	ignore_case="y"
	enabled="y"
	group="Commands"
	regexp="y"
	send_to="12"
	script="start"
	sequence="100"
	>	
	</alias>

	<alias
	match="^testrun$"
	ignore_case="y"
	enabled="y"
	group="Commands"
	regexp="y"
	send_to="12"
	sequence="100"
	>
	<send>
	AddAlias("food_alias", "%1", "run %2", alias_flag.Enabled, "")
	</send>
	</alias>

	<alias
	match="^aliasinfo (.*?)$"
	enabled="y"
	ignore_case="y"
	group="Commands"
	regexp="y"
	send_to="12"
	sequence="100"
	>
	<send>
var.aliasnum = "%1"
Note (GetAliasInfo(var.aliasnum, 2))
	</send>
	</alias>

	<alias
	match="^getalias$"
	ignore_case="y"
	enabled="y"
	group="Commands"
	regexp="y"
	send_to="12"
	script="aliaslist"
	sequence="100"
	>
	</alias>


	<alias
	match="^paging (.*?)$"
	enabled="y"
	group="Commands"
	regexp="y"
	send_to="12"
	sequence="100"
	>
	<send>
var.paging = "%1"
	</send>

	</alias>

</aliases>

<triggers>
	
	<trigger
	enabled="n"
	group="disabled"
	match="^@paging"
	expand_variables="y"
	regexp="y"
	send_to="12"
	sequence="100"
	>
	<send>
SendNoEcho ( "" )
	</send>
	</trigger>

	<trigger
	enabled="n"
	group="Capture"
	match="^(.*?)\srun\s(.*?)$"
	omit_from_output="y"
	regexp="y"
	send_to="12"
	sequence="100"
	>
	<send>
AddAlias("%1", "%1", "run %2", alias_flag.Enabled, "")
	</send>
	</trigger>

	<trigger
	enabled="n"
	group="Capture"
	match="^pyre\s$"
	regexp="y"
	send_to="12"
	sequence="100"
	>
	<send>
EnableTriggerGroup ("Capture" , false)
SendNoEcho( "Gt off")
	</send>
	</trigger>

</triggers>









<script>

require "var"

var.paging = var.paging or "[ Paging \: (Enter), (T)op, (Q)uit, (B)ack, (R)efresh, (L)ast, (A)ll ]:"
var.areaname = var.areaname or "0"
var.speedwalk = var.speedwalk or "0"
var.aliasname = var.aliasname or "0"


function OnPluginInstall()
OnHelp()
end -- OnPluginInstall

function OnHelp ()
  Note (GetPluginInfo (GetPluginID (), 3))
end

function start ()
	EnableTriggerGroup ("Capture", true)
	SendNoEcho( "speedwalk keywords"  )
end

function aliaslist ()
	al = GetAliasList()
	if al then
	  for k, v in ipairs (al) do 
	    Note (v) 
	  end  -- for
	end -- if we have any aliases
end


	


</script>

</muclient>
#1
Heres the second one I've seen many plugins doing quest tracking but none of them have integrated averages so I set out to write a simple quest tracker whose only purpose was really to track averages over time and I finally figured out how to do it. I realize it's missing several features others might deem mandatory but I wrote it mostly for myself and am sharing it as an afterthought as above the code is rather inefficient but I'm still teaching myself Lua etc etc.


<muclient>
<plugin
	name="QuestTracker"
	author="Starky"
	id="a234cd0873b23a1f234e826e"
	language="lua"
	purpose="Simple quest tracker"
	date_written="2008-05-25 05:57:45"
	save_state="y"
	>
<description trim="n">
<![CDATA[
Commands for the script are pretty simple its a mostly self running script with a few
commands to help you personalize it.

questchan <channel name>                  - changes the channel that the output displays on
qreport                                   - reports the current tracking amount of quests and
					                        average qp and gold rewards
]]>
</description>
</plugin>

<aliases>
	<alias
	match="questchan *"
	ignore_case="y"
	enabled="y"
	send_to="12"
	sequence="100"
	>
	<send>
SetVariable ("questchan", "%1" )
	</send>
	</alias>
	
	<alias
	match="qreport"
	ignore_case="y"
	enabled="y"
	send_to="12"
	sequence="100"
	>
	<send>
SendNoEcho(
var.questchan .. " So far I have completed " .. 
var.quests .. " quests with an average of " ..
var.questaverage .. " qps per quest and " ..
var.goldaverage .. " gold per quest. With a " ..
var.completion .. "% quest completion percentage. "
)
	</send>
	</alias>
</aliases>

<triggers>
	<trigger
	enabled="y"
	group="Quests"
	match="^(.*?) tells you 'Congratulations (.*?) on completing your quest!'$"
	expand_variables="y"
	regexp="y"
	send_to="12"
	sequence="100"
	>
	<send>
var.questbonus = "0"
	</send>
	</trigger>

	<trigger
	enabled="y"
	group="Quests"
	match="^(.*?) tells you 'You have (.*?) minutes to complete your quest.'$"
	expand_variables="y"
	regexp="y"
	send_to="12"
	sequence="100"
	>
	<send>
var.totalquest = var.totalquest + 1
	</send>
	</trigger>

	<trigger
	enabled="y"
	group="Quests"
	match="^(.*?) tells you \'As a reward\, I am giving you (.*?) quest points and (.*?) gold\.\'$"
	expand_variables="y"
	regexp="y"
	send_to="12"
	sequence="100"
	>
	<send>
var.questreward = "%2"
var.questtotal = var.questtotal + var.questreward
var.quests = var.quests + 1
var.goldreward = "%3"
var.goldtotal = var.goldtotal + var.goldreward
	</send>
	</trigger>

	<trigger
	enabled="y"
	group="Quests"
	match="^You get lucky and gain an extra (.*?) quest points\.$"
	regexp="y"
	expand_variables="y"
	send_to="12"
	sequence="100"
	>
	<send>
var.questbonus = "%1"
var.questtotal = var.questtotal + var.questbonus
	</send>
	</trigger>

	
	<trigger
	enabled="y"
	group="Quests"
	match="^(.*?) tells you \'I am also giving you (.*?) quest points tier bonus\.$"
	expand_variables="y"
	send_to="12"
	sequence="100"
	>
	<send>
var.tierbonus = "%2"
var.questtotal = var.questtotal + var.tierbonus
	</send>
	</trigger>

	<trigger
	enabled="y"
	group="Quests"
	match="^You gain an extra 2 quest points \'MCCP Bonus\'\.$"
	regexp="y"
	expand_variables="y"
	send_to="12"
	sequence="100"
	>
	<send>
var.questtotal = var.questtotal + 2
var.questbonus = var.questbonus + var.tierbonus + 2
var.questaverage = var.questtotal / var.quests
var.questaverage = var.questaverage * 10
var.questaverage = math.floor(var.questaverage)
var.questaverage = var.questaverage / 10
var.goldaverage = var.goldtotal / var.quests
var.goldaverage = math.floor(var.goldaverage)
var.completion = var.totalquest / var.quests
var.completion = var.completion * 10000
var.completion = math.floor(var.completion)
var.completion = var.completion / 100
SendNoEcho(


		<!--   Change the text in Quotes to change your display message -->



var.questchan .. " Quest completed with " .. 
var.questreward .. " + " .. 
var.questbonus .. " and " .. 
var.goldreward .. " gold with an average of " ..
var.questaverage .. " qps per quest and " ..
var.goldaverage .. " gold per quest over " ..
var.quests .. " quests tracked. With a " ..
var.completion .. "% quest completion percentage."
)
	</send>
	</trigger>
</triggers>

<script>
require "var"

var.questchan = var.QuestChan or "gt"
var.questreward = var.questreward or "0"
var.goldreward = var.goldreward or "0"
var.questtotal = var.questtotal or "0"
var.quests = var.quests or "0"
var.goldtotal = var.goldtotal or "0"
var.questaverage = var.questaverage or "0"
var.goldaverage = var.goldaverage or "0"
var.questbonus = var.questbonus or "0"
var.totalquest = var.totalquest or "0"
var.completion = var.completion or "0"
var.tierbonus = var.tierbonus or "0"


function OnPluginInstall()
	OnHelp()
end

function OnHelp ()
	Note (GetPluginInfo (GetPluginID (), 3))
end

</script>
</muclient>
Amended on Wed 04 Jun 2008 06:16 PM by Starky
#2
figured I'd add my vorpal counter as well since it's another script I havent seen posted anywhere for MUSH complete but doesnt support deathblows usual story about inefficient coding I never quite got the mushclient capturing the time it's installed on and displaying that to quite work right so I added that manually probably something that should be fixed but I've been working on the above ones too much to come back and fix it.


<muclient>
<plugin
	name="VorpalCounter"
	author="Starky"
	id="a234cd0873b23a1f234e826c"
	language="lua"
	purpose="Simple vorpal counter which tallies per mort and total"
	date_written="2007-12-22 02:24:45"
	save_state="y"
	>
<description trim="n">
<![CDATA[
Commands for the script are pretty simple its a mostly self running script with a few
commands to help you personalize it.

vorpchan <channel name>                   - changes the channel that the output displays on
vorpreset                                 - resets the number of vorpals this mort to 0 for easy
					    use on remorts.
]]>
</description>

</plugin>

<aliases>
	<alias
	match="vorpchan *"
	enabled="y"
	send_to="12"
	sequence="100"
	>
	<send>
SetVariable ("VorpChan", "%1" )
	</send>
	</alias>
	<alias
	match="vorpals"
	enabled="y"
	send_to="12"
	sequence="100"
	>
	<send>
SendNoEcho(
var.VorpChan .. " So far I have vorpalled " ..
var.VorpCount .. " mobs this remort and " ..
var.VorpTotal .. " mobs since added on 12-29-07"
)
	</send>
	</alias>
	<alias
	match="vorpreset"
	enabled="y"
	send_to="12"
	sequence="100"
	>
	<send>
SetVariable ("VorpCount", "0")
	</send>
	</alias>
</aliases>

<triggers>
	<trigger
	enabled="y"
	group="Vorpal"
	match="Your weapon glows brightly and almost decapitates *."
	expand_variables="y"
	send_to="12"
	sequence="100"
	>
	<send>
var.VorpVictim = "%1"
var.VorpCount = var.VorpCount + 1
var.VorpTotal = var.VorpTotal + 1
SendNoEcho(




		<!--   Change the text in Quotes to change your display message -->	



	var.VorpChan .. " I just vorpalled " .. 
            var.VorpVictim .. "! Which is " .. 
            var.VorpCount .. " total vorpals this remort, and " .. 
            var.VorpTotal .. " since added on 12-29-07" 
           )



	</send>
	</trigger>
</triggers>	

<script>
require "var"

var.Chan = var.Chan or "gt "
var.Count = var.Count or "0"
var.Total = var.Total or "0"


function OnPluginInstall()
	OnHelp()
end

function OnHelp ()
	Note (GetPluginInfo (GetPluginID (), 3))
end

</script>
</muclient>


Amended on Wed 04 Jun 2008 06:20 PM by Starky
Australia Forum Administrator #3
I am not totally sure what you are doing here, but let's look at this one:


<alias
	match="^testrun$"
	ignore_case="y"
	enabled="y"
	group="Commands"
	regexp="y"
	send_to="12"
	sequence="100"
	>
	<send>
	AddAlias("food_alias", "%1", "run %2", alias_flag.Enabled, "")
	</send>
	</alias>


According to the AddAlias documentation:

http://www.gammon.com.au/scripts/doc.php?function=AddAlias

The prototype for AddAlias is:


result = AddAlias(AliasName, MatchText, ResponseText, Flags, ScriptName);


Now I am puzzled about your use of %1 and %2 in this example. %1 matches the first wildcard, and %2 matches the second wildcard. But you don't have any wildcards! Thus %1 and %2 will be an empty string.

To have any wildcards you would need something like:


match="^testrun (.*) with (.*)$"


The thing in the first set of brackets is the first wildcard, and the other one is the second.


What is useful when calling a lot of MUSHclient functions is to "check" the return code. This applies to all functions that are documented to return codes like eOK as the return value.

You can do this like this:


require "check"
check (AddAlias("food_alias", "%1", "run %2", alias_flag.Enabled, ""))


Basically you require the "check" file, and then put check (... whatever ...) where you had your function. What this does is nothing if the function works, but raises an error if it doesn't. This can help you debug.

In your example, I did this, like this:


require "check"
check (AddAlias("food_alias", "", "run ", alias_flag.Enabled, ""))


Since %1 and %2 were going to be empty, I replaced them by an empty string. Now see what happens when I press <Enter>:


Run-time error
World: smaug 2
Immediate execution
[string "Command line"]:1: The alias "match" string cannot be empty
stack traceback:
        [C]: in function 'error'
        C:\Program Files\MUSHclient\lua\check.lua:23: in function 'check'
        [string "Command line"]:1: in main chunk


There is your problem. You are matching on an empty string. And since you got an error, the alias was not added.

Amended on Wed 04 Jun 2008 10:28 PM by Nick Gammon
Australia Forum Administrator #4
Quote:

So in the meantime I have it trying to trigger to switch off using the last speedwalk on the list but the trigger refuses to activate.


What is that last line?



	<trigger
	enabled="n"
	group="Capture"
	match="^pyre\s$"
	regexp="y"
	send_to="12"
	sequence="100"
	>
	<send>
EnableTriggerGroup ("Capture" , false)
SendNoEcho( "Gt off")
	</send>
	</trigger>



Is it exactly "pyre "? That is what you are matching on.
#5
The testrun is something I forgot to remove hence why it doesnt seem to make any sense because the stuff it was firing off of is now gone. as for pyre it's trying to match


pyre run 2s4e3s2ed

theres no characters at the beginning of the line or end and theres no distinguishing line after it.

the AddAlias that I'm working on is the one under triggers that's matching off of

<trigger
	enabled="n"
	group="Capture"
	match="^(.*?)\srun\s(.*?)$"
	omit_from_output="y"
	regexp="y"
	send_to="12"
	sequence="100"
	>
	<send>
AddAlias("%1", "%1", "run %2", alias_flag.Enabled, "")
	</send>
	</trigger>
Amended on Wed 04 Jun 2008 10:51 PM by Starky
Australia Forum Administrator #6
Quote:

as for pyre it's trying to match


pyre run 2s4e3s2ed


Well it won't because you are looking for "pyre ".

You need to change the match to:


match="^pyre\s"


That final $, which I removed, says "assert end of line".

Quote:

the AddAlias that I'm working on is the one under triggers that's matching off of


Add the check function and see what is happening:


require "check"
check (AddAlias("%1", "%1", "run %2", alias_flag.Enabled, ""))



#7
thanks I"ll try that but the pyre thing is a bandaid anyway hoping to have something like an end line to trigger off of instead of the pyre line
Australia Forum Administrator #8
When I tried your trigger on the line:

pyre run 2s4e3s2ed

It added the alias fine. So maybe some lines work and some don't. The "check" suggestion will help work that out.
Australia Forum Administrator #9
When I look at your earlier post, preserving spacing, you said:


pyre                            run 2s4e3s2ed


That is a lot more than one space.

So you really need to match on one or more spaces, like this:


match="^(.*?)\s+run\s+(.*?)$"


#10
Okay that works for the AddAlias command but the Pyre trigger still fails even with using "^pyre\s+"

still doesnt trigger so the capture triggers arent turning off thats a bit of a problem
Australia Forum Administrator #11
Can you post a few lines leading up to pyre? Like, is it exactly at the start of the line?

What is probably happening is that the other trigger matches first. Once a trigger matches, MUSHclient stops processing other triggers *unless* you check "keep evaluating".

Make both triggers have "keep evaluating" checked.
#12
ah didnt know about that one thanks that works
#13
New question


 Directions from Aylor recall

Area Name                       Speedwalk 
------------------------------  ----------------------------------------------
marketroad                      run 2s12e12se
lowlands                        run 4ne;open n;run 2nw7nw
orchard                         run 2s8enen
lidnesh                         run 2s8e5ne5n3e
goblinpath                      run 4ne;open n;run 2nw19ne
ratslair                        run 13s2w;open s;run sd
camps                           run 2s9e5sw
melody                          run 2s5ws;dance
callhero                        run 2n2w;open w;run 2wn;knock door
gallows                         run 2s9e14s
orlando                         run 2s8w2n5wn7wn
legend                          run 4ne;op n;run 2nw2ne
sennarre                        run 2s8w3nw7n5w
beer                            run 2s8wn22w
whitelotus                      run 2s8e5ne12n13e
challenge                       See 'help duel'.
academy                         zgoto academy


ones like lowlands goblinpath ratslair etc anything with the ; in them arent working correctly. MUSH is sending the commands complete with the ; to the mud instead of parsing ; as the command stacking character. Is there any way to fix this? I know theres a "AliasSpeedWalk" option in AddAlias but I have absolutely no idea how it works does this mean it'll interpret the ;'s correctly or no?
Australia Forum Administrator #14
You need to send to "execute" rather than straight to the MUD. After the AddAlias add this line:


check (SetAliasOption ("%1", "send_to", "10"))


Now it will go through the command processor, and evaluate command-stack characters.
#15
Thanks, I declare that script done :] at least until he adds an endline then I just change the match text
Australia Forum Administrator #16
Can you upload the finished version? Then other people can use it.