Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Plugins ➜ Aardwolf: exits, autohunt and maybe some more

Aardwolf: exits, autohunt and maybe some more

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Swalec   (24 posts)  Bio
Date Wed 12 Nov 2008 02:47 PM (UTC)
Message
So, I decided to start a new subject for my own plugins.

So far I have done two. One is an exit detector, which is a support module with no user facing stuff.

The second is an autohunt module. I know that there are two versions of these around already, but I wasn't entirely happy with the one from Onoitsu2's; I wanted something that did error checking for failure conditions and opened doors. Also, I wanted to see how the plugins talked to each other.

I'll post the code in separate messages.
Top

Posted by Swalec   (24 posts)  Bio
Date Reply #1 on Wed 12 Nov 2008 02:49 PM (UTC)
Message
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Thursday, October 30, 2008, 7:39 PM -->
<!-- MuClient version 4.33 -->

<!-- Plugin "Aardwolf_exits_detector" generated by Plugin Wizard -->

<muclient>
<plugin
name="Aardwolf_exits_detector"
id="18c24130ab326dc05b49420d"
language="Lua"
purpose="Detect Exits and Room changes in Aardwolf"
author = "swalec"
date_written="2008-10-30 19:38:12"
requires="4.33"
version="1.0"
>



<!--
Copyright (c) 2008 Swalec

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

-->

<description trim="y">

This is a support plugin meant for other plugin authors.

This detects parts of the mud associated with movement. These
include current exits, current room title. It also detects
the inability to move.

Example of use

-- detect room or exit changes
function OnPluginBroadcast( msg, id, name, text )

if ( id == "18c24130ab326dc05b49420d" ) then
if ( msg == 2 ) then
exits_change()
end
if ( msg == 1 ) then
room_change()
end
if ( msg == 3 ) then
cant_move()
end
end
end

-- get the room name
local var = GetPluginVariableList( "18c24130ab326dc05b49420d" )
var.roomname

-- get the exits
loadstring( var.exits )()
current_exits = exits


Exits are stored as a table with valid exit directions as keys.
Value 1 indicates an exit, Value 2 indicates a closed exit.




License:

Copyright 2008 Swalec

This is released under the MIT license, which is the same license as Lua.

</description>

</plugin>


<!-- Get our standard constants -->

<include name="constants.lua"/>
<aliases>
<alias
script="OnHelp"
match="Aardwolf_exits_detector:help"
enabled="y"
>
</alias>
</aliases>

<triggers>
<trigger
enabled="y"
match="{exits}*"
send_to="12"
sequence="100"
script="process_exits"
omit_from_output="y"
/>

<trigger
enabled="y"
match="{rname}*"
send_to="12"
sequence="100"
script="process_room"
omit_from_output="y"
/>


<trigger
enabled = "y"
group = "swalec.exits"
match = "You can only fly there."
script = "process_stuck"
make_underline = "y"
>
</trigger>

<trigger
enabled = "y"
group = "swalec.exits"
match = "You are trapped in quicksand."
script = "process_stuck"
make_underline = "y"
>
</trigger>



</triggers>

<!-- Plugin help -->
<script>
<![CDATA[
function OnHelp ()
world.Note (world.GetPluginInfo (world.GetPluginID (), 3))
end
]]>
</script>




<script>
<![CDATA[



--[[


--]]

require "var"
require "serialize"

function process_stuck ( name, line, wildcards, styles )
BroadcastPlugin( 3, "" )
end

function process_exits ( name, line, wildcards, styles )
-- print the exits, so that this looks the same as normal
local exitstring = wildcards[ 1 ]
local exits = {}
ColourNote ( "Lime", "", exitstring )

for _,direction in ipairs( {"north", "south", "west", "east",
"up", "down", "none"} ) do
if string.find( exitstring, direction ) then
if string.find( exitstring, "[(]" .. direction .. "[)]" ) then
exits[ direction ] = 2
else
exits[ direction ] = 1
end
end
end



var.exits = serialize.save( "exits", exits )
BroadcastPlugin( 2, "" )
end

function process_room ( name, line, wildcards, styles )
ColourNote( "Lime", "", wildcards[ 1 ] )

var.roomname = wildcards[ 1 ]

BroadcastPlugin( 1, "" )
end

function process_stuck( name, line, wildcards, styles )

end


function OnPluginEnable ()
OnPluginConnect()
-- Send( "tags exits on" )
-- Send( "tags roomnames on" )
end -- OnPluginEnable

function OnPluginDisable ()
OnPluginClose()
-- Send( "tags exits off" )
-- Send( "tags roomnames off" )
end -- OnPluginDisable


-- pull in telnet option handling
dofile (GetPluginInfo (GetPluginID (), 20) .. "telnet_options.lua")

function OnPluginConnect ()
TelnetOptionOff(TELOPT_QUIET)
TelnetOptionOn(TELOPT_EXIT_NAMES)
TelnetOptionOn(TELOPT_ROOM_NAMES)
end -- function OnPluginConnect

function OnPluginClose ()
TelnetOptionOff(TELOPT_EXIT_NAMES)
TelnetOptionOff(TELOPT_ROOM_NAMES)
end -- OnPluginClose

function OnPluginInstall ()
-- if we are connected when the plugin loads, it must have been reloaded whilst playing

if IsConnected () then
OnPluginConnect ()
end -- if already connected
end -- OnPluginInstall

]]>
</script>
</muclient>
Top

Posted by Swalec   (24 posts)  Bio
Date Reply #2 on Thu 13 Nov 2008 01:20 PM (UTC)
Message
The other one is too long for posting here.

Nick, is there a better place to put these than the Forum?

Top

Posted by Swalec   (24 posts)  Bio
Date Reply #3 on Mon 17 Nov 2008 04:58 PM (UTC)
Message
I've put the my plugins up at

http://geocities.com/swalecaardwolf

on the off-chance that anyone is interested.
Top

Posted by Nick Gammon   Australia  (23,165 posts)  Bio   Forum Administrator
Date Reply #4 on Wed 19 Nov 2008 10:37 PM (UTC)
Message
Quote:

Nick, is there a better place to put these than the Forum?


This is fine, sometimes I grab a batch of plugins once they have stabilized and put them onto the plugins area.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Swalec   (24 posts)  Bio
Date Reply #5 on Sat 07 Feb 2009 07:27 PM (UTC)
Message
I've added two new plugins, one which does shortest-path speedwalking and another with navigates through a maze.

http://www.geocities.com/swalecaardwolf

Hope someone finds these useful.

Swalec
Top

Posted by Nick Gammon   Australia  (23,165 posts)  Bio   Forum Administrator
Date Reply #6 on Sat 07 Feb 2009 10:18 PM (UTC)

Amended on Sat 07 Feb 2009 10:20 PM (UTC) by Nick Gammon

Message
I have archived those plugins (as at this date/time) here, in case that site becomes unavailable:

http://www.gammon.com.au/mushclient/plugins/Swalec/

Instructions are here:

http://www.gammon.com.au/mushclient/plugins/Swalec/Swalec_srun_plugin.html

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Swalec   (24 posts)  Bio
Date Reply #7 on Sun 08 Feb 2009 02:12 AM (UTC)
Message
Thanks. Hope this won't cause a version problem, but I can see the point.

Swalec
Top

Posted by Swalec   (24 posts)  Bio
Date Reply #8 on Sun 15 Feb 2009 12:09 PM (UTC)
Message
Nick

My speedrunning plugin uses state fairly agressively -- basically, I dump the entire data structure. I've just found out, as a result, that mush places a limit on the file of the state file.

Is there a reason for this? I was going to change things anyway, to make the use of state more parsimonious, but this is going to take a while, and in the meantime, the plugin is crashing.

Swalec
Top

Posted by Swalec   (24 posts)  Bio
Date Reply #9 on Sun 15 Feb 2009 03:46 PM (UTC)
Message
I have posted a new version of my srun plugin. It's been cleaned up significantly and should be easier to use. There's been a bug fix with the Aardwolf Hotel.

It's also now has an import of iwuvaard directions, so requires less configuration to work well.

As before it and it's documentation are at: http://geocities.com/swalecaardwolf/

Cheers

Swalec
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


35,736 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.