<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<muclient>
<plugin
name="MM_Auto_Sac"
author="Deacla"
id="dc109a6028175ae32994c209"
language="Lua"
save_state="y"
purpose="Auto Sacs Items"
requires="4.52"
version="1.0"
>
<description trim="y">
<![CDATA[
---------------------------------------------------------------------------
---------------------------++++++++++++++++--------------------------------
MUD: Materia Magica
Requires: serialize.lua
This plugin keeps a list of items that are to be automatically
sacrified when you grab them from a corpse. It also saves this list
when MUSHclient is closed. Command line usage is as follows:
ASI item name (Adds Item 'item name' to the auto-sac list)
RSI item name (Removes Item 'item name' to the auto-sac list)
sacson (Turns on all auto-sac triggers)
sacsoff (Turns off all auto-sac triggers)
sacshelp (Displays this command list)
---------------------------++++++++++++++++--------------------------------
---------------------------------------------------------------------------
]]>
</description>
</plugin>
<triggers>
<trigger
enabled="y"
group="AutoSacTriggers"
match="^You take (.*) from the corpse of (?:.*)\.$"
name="SacFromCorpse"
regexp="y"
send_to="12"
sequence="90"
>
<send>
if AutoSacItems["%1"] then -- check item name for match in table
Send ("drop '" .. "%1" .. "'")
Send ("sac '" .. "%1" .. "'")
end -- if
</send>
</trigger>
</triggers>
<aliases>
<alias
match="^ASI (.*)$"
regexp="y"
enabled="y"
send_to="12"
sequence="100"
>
<send>AutoSacItems["%1"] = true
Note ()
ColourTell("silver", "black", "Added '" .. "%1" .. "' to AutoSacItems list.")
Send ("")</send>
</alias>
<alias
match="^RSI (.*)$"
regexp="y"
enabled="y"
send_to="12"
sequence="100"
>
<send>AutoSacItems["%1"] = nil
Note ()
ColourTell("silver", "black", "Removed '" .. "%1" .. "' from the AutoSacItems list.")
Send ("")</send>
</alias>
<alias
match="^sacson$"
regexp="y"
enabled="y"
send_to="12"
sequence="100"
>
<send>EnableTriggerGroup ("AutoSacTriggers", true)
Note ()
ColourTell("silver", "black", "Sacs are now ON!.")
Send ("")</send>
</alias>
<alias
match="^sacsoff$"
regexp="y"
enabled="y"
send_to="12"
sequence="100"
>
<send>EnableTriggerGroup ("AutoSacTriggers", false)
Note ()
ColourTell("silver", "black", "Sacs are now OFF!.")
Send ("")</send>
</alias>
<alias
match="^sacshelp$"
regexp="y"
enabled="y"
send_to="12"
sequence="100"
>
<send>
Note ()
ColourTell("white", "black", "Auto_sac commands:")Note()
ColourTell("silver", "black", "ASI item name")Note(" (Adds Item 'item name' to the auto-sac list)")
ColourTell("silver", "black", "RSI item name")Note(" (Removes Item 'item name' to the auto-sac list)")
ColourTell("silver", "black", "sacson")Note(" (Turns on all auto-sac triggers)")
ColourTell("silver", "black", "sacsoff")Note(" (Turns off all auto-sac triggers)")
Send ()</send>
</alias>
</aliases>
<script>
<![CDATA[
require "serialize" -- needed to serialize table to string
AutoSacItems = {} -- ensure table exists, if not loaded from variable
-- on plugin install, convert variable into Lua table
function OnPluginInstall ()
assert (loadstring (GetVariable ("AutoSacItems") or "")) ()
end -- function OnPluginInstall
-- on saving state, convert Lua table back into string variable
-- save_simple is for simple tables that do not have cycles (self-reference)
-- or refer to other tables
function OnPluginSaveState ()
SetVariable ("AutoSacItems",
"AutoSacItems = " .. serialize.save_simple (AutoSacItems))
end -- function OnPluginSaveState
]]>
</script>
</muclient>
|