<?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>
|