<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Wednesday, August 29, 2007, 9:22 PM -->
<!-- MuClient version 3.74 -->
<!-- Plugin "ClanLevelDonateLUA" generated by Plugin Wizard -->
<muclient>
<plugin
name="ClanLevelDonateLUA"
author="Onoitsu2"
id="e6992b64478eb9a68d6182b9"
language="Lua"
purpose="Automatically Donates Gold To the Clan based upon % of gold earned per level/pup"
save_state="y"
date_written="2007-08-29 21:20:54"
requires="3.74"
version="1.0"
>
</plugin>
<!-- Triggers -->
<triggers>
<trigger
enabled="y"
group="donate"
ignore_case="y"
match="^You (?:get|receive) (\d+) gold(\scoins)?"
regexp="y"
send_to="12"
sequence="100"
>
<send>SetVariable("goldperlevel",tonumber(GetVariable("goldperlevel")) + tonumber("%1"))</send>
</trigger>
<trigger
enabled="y"
group="donate"
ignore_case="y"
match="^(You raise a level\!\!|Congratulations hero\. You have increased your powers\!)"
regexp="y"
send_to="12"
sequence="100"
>
<send>SetVariable("totdonate",tonumber(GetVariable("totdonate")) + tonumber(GetVariable("goldperlevel")))
SetVariable("doncount",tonumber(GetVariable("doncount")) + 1)
SetVariable("donateamount",tonumber(GetVariable("totdonate") * tonumber(GetVariable("taxrate")) / 100)
if GetVariable("doncount") == GetVariable("doncounttrue") then
Send("clandon " .. GetVariable("donateamount"))
SetVariable("doncount",0)
setVariable("totdonate",0)
elseif GetVariable("doncounttrue") == "0" then
SetVariable("doncount",0)
setVariable("totdonate",0)
SetVariable("goldperlevel",0)
end -- if</send>
</trigger>
</triggers>
<!-- Aliases -->
<aliases>
<alias
match="^settax$"
enabled="y"
group="donate"
omit_from_command_history="y"
regexp="y"
send_to="12"
ignore_case="y"
sequence="100"
>
<send>taxrate = tonumber(GetVariable("taxrate"))
doncounttrue = tonumber(GetVariable("doncounttrue"))
doncount = tonumber(GetVariable("doncount"))
if taxrate == nil then taxrate = 0 end
if doncounttrue == nil then doncounttrue = 1 end
if doncount == nil then doncount = 0 end
repeat
taxrate = tonumber(utils.inputbox("Enter percentage to donate from 1-100","Please Enter Tax Rate To Donate At",taxrate))
if taxrate == nil or taxrate < 1 then
if taxrate == nil then taxrate = "nil" end -- if
utils.msgbox(taxrate .. " is an invalid percentage, please enter a number between 1-100.\nPlease enter another
value...","Invalid Number Entered","ok","!") end -- if
until taxrate ~= nil and taxrate > 0
repeat
doncounttrue = tonumber(utils.inputbox("Enter the number of levels/pups before you donate","Please Enter Number Of
Levels/Pups Till You Donate"))
if doncounttrue == nil or doncounttrue < 0 then
if doncount == nil then doncounttrue == nil end -- if
utils.msgbox(doncounttrue .. " is an invalid number of levels/pups.\nPlease enter a positive number","ok","!") end -- if
elseif doncount > doncounttrue then doncount = 0 end -- if
until doncounttrue ~= nil and doncounttrue > -1
SetVariable("taxrate",taxrate)
SetVariable("doncounttrue",doncounttrue)
SetVariable("doncount",doncount)</send>
</alias>
</aliases>
</muclient>
You can copy that ENTIRE section and paste it into notepad, or any other true text editor, and save it as a FILENAME.xml, and load that into mushclient and it will get the job done. I even added error checking for invalid inputs, just cause I am always cautious like that. And there are a few other ways to accomplish this task, rather than always saving and converting from mushclient variables and back and saving immediately, but since this might be part of a larger system I wanted it to work standalone, since I don't know the rest of the "script" to be.
Hope this helps :)
-Onoitsu2 |