mirror of
https://github.com/chenasraf/aardwolf.git
synced 2026-05-17 17:38:10 +00:00
250 lines
5.9 KiB
XML
250 lines
5.9 KiB
XML
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
<!DOCTYPE muclient>
|
|
<!-- MuClient version 5.07-pre -->
|
|
<!-- Author: Chen Asraf <contact@casraf.dev> (KumoGami) -->
|
|
<!-- Source: https://github.com/chenasraf/aardwolf/tree/master/Spellbook -->
|
|
<!-- Plugin "SpellRotation" generated by Plugin Wizard -->
|
|
|
|
<muclient>
|
|
<plugin
|
|
name="SpellRotation"
|
|
author="KumoGami"
|
|
id="dc0917daa7ea3e68b4494d10"
|
|
language="Lua"
|
|
purpose="Allows you to switch between saved spells in custom categories, for easier attacking."
|
|
save_state="y"
|
|
date_written="2024-11-02 02:37:52"
|
|
requires="5.07"
|
|
version="1.03"
|
|
>
|
|
|
|
</plugin>
|
|
|
|
|
|
<script><![CDATA[
|
|
-- utils
|
|
|
|
require "serialize"
|
|
|
|
utils.unserialize = function (s)
|
|
local f = load("return " .. s)
|
|
if f then
|
|
return f()
|
|
end
|
|
end
|
|
|
|
utils.serialize = function (val)
|
|
return serialize.save_simple(val)
|
|
end
|
|
|
|
string.lpad = function(str, len, char)
|
|
if char == nil then char = ' ' end
|
|
return string.rep(char, len - #str) .. str
|
|
end
|
|
|
|
string.rpad = function(str, len, char)
|
|
if char == nil then char = ' ' end
|
|
return str .. string.rep(char, len - #str)
|
|
end
|
|
|
|
logger = {}
|
|
local function withColor(color)
|
|
return function (text)
|
|
ColourNote(color, "", text)
|
|
end
|
|
end
|
|
logger.Cyan = withColor("cyan")
|
|
logger.Yellow = withColor("yellow")
|
|
logger.Normal = withColor("white")
|
|
|
|
-- main
|
|
Rot = {
|
|
data = {},
|
|
type = "main",
|
|
snd = true,
|
|
}
|
|
|
|
function Rot:init()
|
|
self.data = utils.unserialize(GetVariable("rotData") or "{}")
|
|
self.type = GetVariable("rotType") or "main"
|
|
self.snd = GetVariable("rotSnd") == "true"
|
|
self:save()
|
|
end
|
|
|
|
function Rot:save()
|
|
SetVariable("rotData", utils.serialize(self.data or {}))
|
|
SetVariable("rotType", self.type)
|
|
SetVariable("rotSnd", tostring(self.snd))
|
|
end
|
|
|
|
function Rot:set(name, act)
|
|
self.data[name] = utils.split(act or "", ";")
|
|
self:save()
|
|
end
|
|
|
|
function Rot:get(name)
|
|
return self.data[name]
|
|
end
|
|
|
|
function Rot:switch(name)
|
|
self.type = name
|
|
if self.snd then
|
|
Execute("xset kk kp")
|
|
end
|
|
logger.Cyan("Switched to " .. name)
|
|
self:save()
|
|
end
|
|
|
|
function Rot:act(name, tgt)
|
|
tgt = tgt or ""
|
|
if tgt == "-" then
|
|
tgt = ""
|
|
end
|
|
if string.match(tgt, " ") and not self.snd then
|
|
tgt = "'" .. tgt .. "'"
|
|
end
|
|
local cmds = self:get(name)
|
|
if not cmds then
|
|
logger.Yellow("No cmds found for " .. name)
|
|
return
|
|
end
|
|
for _, cmd in ipairs(cmds) do
|
|
Send(cmd .. " " .. tgt)
|
|
end
|
|
end
|
|
|
|
function Rot:actDefault(tgt)
|
|
if self.data[tgt] then
|
|
self:switch(tgt)
|
|
tgt = "-"
|
|
end
|
|
self:act(self.type, tgt)
|
|
end
|
|
|
|
function Rot:parse(val)
|
|
local split = utils.split(val, " ")
|
|
local act = split[1]
|
|
local value = table.concat(split, " ", 2)
|
|
|
|
if act == "set" then
|
|
local split = utils.split(value, " ")
|
|
local name = split[1]
|
|
local cmds = table.concat(split, " ", 2)
|
|
self:set(name, cmds)
|
|
logger.Cyan("Set rotation '" .. name .. "' to: \"" .. table.concat(self:get(name), "; ") .. '"')
|
|
elseif act == "get" then
|
|
logger.Cyan("Rotation for '" .. value .. "': \"" .. table.concat(self:get(value), ", ") .. '"')
|
|
elseif act == "switch" then
|
|
self:switch(value)
|
|
elseif act == "list" then
|
|
self:list()
|
|
elseif act == "snd" then
|
|
if value == "on" then
|
|
self.snd = true
|
|
logger.Cyan("SnD features enabled")
|
|
elseif value == "off" then
|
|
self.snd = false
|
|
logger.Cyan("SnD features disabled")
|
|
else
|
|
logger.Cyan("SnD features are " .. (self.snd and "enabled" or "disabled"))
|
|
end
|
|
elseif act == "help" or act == "h" then
|
|
self:help()
|
|
else
|
|
self:actDefault(value)
|
|
end
|
|
end
|
|
|
|
function Rot:list()
|
|
logger.Cyan("Available rotations:")
|
|
local max = 0
|
|
for name, cmds in pairs(self.data) do
|
|
if #name > max then
|
|
max = #name
|
|
end
|
|
end
|
|
max = max + 2
|
|
for name, cmds in pairs(self.data) do
|
|
logger.Normal(string.rpad(name .. ": ", max + 2) .. table.concat(cmds, "; "))
|
|
end
|
|
end
|
|
|
|
function Rot:help()
|
|
logger.Cyan("SpellRotation")
|
|
logger.Cyan("--------------------------------------------------------------")
|
|
logger.Cyan("kp [target] Execute current rotation")
|
|
logger.Cyan("kp [name] Switch to rotation [name] and execute")
|
|
logger.Cyan("ks set <name> <cmds> Set rotation")
|
|
logger.Cyan("ks get <name> Get rotation")
|
|
logger.Cyan("ks switch <name> Switch to rotation")
|
|
logger.Cyan("ks list List all rotations and their commands")
|
|
logger.Cyan("ks snd <on|off> Sets SnD features on/off.")
|
|
logger.Cyan("ks snd View SnD features state.")
|
|
-- logger.Cyan("kkp Execute rotation on SnD target, and")
|
|
-- logger.Cyan(" fill Command input with main rotation")
|
|
logger.Cyan("--------------------------------------------------------------")
|
|
logger.Cyan("Plugin author: KumoGami")
|
|
logger.Cyan("Source: https://github.com/chenasraf/aardwolf/tree/master/SpellRotation")
|
|
end
|
|
|
|
function OnPluginInstall()
|
|
Rot:init()
|
|
logger.Cyan("SpellRotation initialized")
|
|
end
|
|
|
|
]]></script>
|
|
|
|
<!-- Aliases -->
|
|
|
|
<aliases>
|
|
<alias
|
|
match="kp *"
|
|
enabled="y"
|
|
group="atk"
|
|
send_to="12"
|
|
sequence="101"
|
|
>
|
|
<send>Rot:actDefault("%1")</send>
|
|
</alias>
|
|
<alias
|
|
match="^ks (.+)$"
|
|
enabled="y"
|
|
regexp="y"
|
|
group="cmd"
|
|
send_to="12"
|
|
sequence="100"
|
|
>
|
|
<send>Rot:parse("%1")</send>
|
|
</alias>
|
|
<alias
|
|
match="kkp"
|
|
enabled="n"
|
|
group="atk"
|
|
send_to="12"
|
|
sequence="100"
|
|
>
|
|
<send><![CDATA[
|
|
SetCommandSelection(0, 2)
|
|
PasteCommand("kp")
|
|
Execute("kk;kp")
|
|
]]></send>
|
|
</alias>
|
|
<alias
|
|
match="kp"
|
|
enabled="y"
|
|
group="atk"
|
|
send_to="10"
|
|
sequence="100"
|
|
>
|
|
<send>kp -</send>
|
|
</alias>
|
|
</aliases>
|
|
|
|
<!-- Variables -->
|
|
|
|
<variables>
|
|
<!-- <variable name="rotData">{ main = { "attack" } }</variable> -->
|
|
</variables>
|
|
|
|
</muclient>
|