diff --git a/Makefile b/Makefile index 43fcfcf..06e6490 100644 --- a/Makefile +++ b/Makefile @@ -5,3 +5,8 @@ PLUGDIR=$(MUSHDIR)/worlds/plugins install/spellbook: cp "./Spellbook/Spellbook.xml" "$(PLUGDIR)" @echo "Spellbook installed." + +.PHONY: watch/spellbook +watch/spellbook: + @echo "Watching for changes in Spellbook..." + @fswatch -o "./Spellbook/Spellbook.xml" | xargs -n1 -I{} make install/spellbook diff --git a/Spellbook/README.md b/Spellbook/README.md index f6eec59..0741812 100644 --- a/Spellbook/README.md +++ b/Spellbook/README.md @@ -19,6 +19,9 @@ Example: load the spell list into a floating window. 1. Click a spell to cast it. You must have an active target as the cast command will be immediately sent to the world. +1. Click a spell's learned % to practice it (you must be at a trainer npc to do so). Use + `spw prac ` to switch between practicing each spell to its max %, or one practice + session at a time. 1. You can move & resize the window as you wish 1. Adding any modifier to the spells command will use the regular spell output. This is useful for one-time lookups of the next spells, or spells in a certain level range. @@ -29,10 +32,13 @@ Use `spw help` to see this list at any time in the game. ``` Spellbook window commands ------- -spw enable - Enable spellbook -spw disable - Disable spellbook -spw hide - Hide spell from spellbook -spw unhide - Unhide spell from spellbook -spw hidden - List hidden spells +---------------------------------------------------------------- +spw enable - Enable spellbook +spw disable - Disable spellbook +spw hide - Hide spell from spellbook +spw unhide - Unhide spell from spellbook +spw hidden - List hidden spells +spw prac - Display practice % mode +spw prac one - Practice spell % once per click +spw prac full - Practice spell % to full on click ``` diff --git a/Spellbook/Spellbook.png b/Spellbook/Spellbook.png index f63d390..2724569 100644 Binary files a/Spellbook/Spellbook.png and b/Spellbook/Spellbook.png differ diff --git a/Spellbook/Spellbook.xml b/Spellbook/Spellbook.xml index eda4313..1f70720 100644 --- a/Spellbook/Spellbook.xml +++ b/Spellbook/Spellbook.xml @@ -16,14 +16,15 @@ save_state="y" date_written="2024-10-08 00:56:30" requires="5.07" - version="1.2" + version="1.30" > - +]]> - - local name = "%1" - local mana = "%2" - local learned = "%3" - local spn = "%4" + +table.insert(SpWinData, { + level = spWinLv, + name = name, + mana = mana, + learned = learned, + id = spn +}) +]]> - - spWinLv = %1 - local name = "%2" - local mana = "%3" - local learned = "%4" - local spn = "%5" + +table.insert(SpWinData, { + level = spWinLv, + name = name, + mana = mana, + learned = learned, + id = spn +}) +]]> - - require "themed_miniwindows" + +local lv = 0 +for i, sp in ipairs(SpWinData) do + local line = "" + if not SpWinIgnore[sp.id] then + local hLen = 9 + local lvlLen = 3 + local nameLen = 30 + local learnedLen = 4 + + if sp.level > lv then + line = line .. "@W" .. string.rpad("lv " .. sp.level, 7) + lv = sp.level + hLen = 8 + else + line = line .. string.rpad("", 8) + end + + line = line .. "@M[@G" .. string.lpad(sp.id, lvlLen) .. "@M] " + line = line .. "@C" .. string.rpad(sp.name, nameLen) + line = line .. "@Y" .. string.lpad(sp.learned .. "%", learnedLen) + + local tooltip = "Cast spell: " .. sp.name + local spNameStart = hLen + 1 + lvlLen + 1 + local spNameEnd = spNameStart + #sp.name + spWin:add_text( + line, + true, + { + { label = tooltip, start = 1, stop = spNameEnd, text = "Send('cast " .. sp.id .. "')" }, + { label = "Practice spell: " .. sp.name, start = spNameStart + nameLen, stop = #line, text = practice(sp) }, + } + ) + end +end + +ColourNote("yellow", "", "Output captured to window.") +EnableTriggerGroup("spellbook", false) +]]> - - require "themed_miniwindows" + +EnableTriggerGroup("spellbook") +SpWinData = {} +Send("spells%2") +]]> - - local args = utils.split("%1", " ") - local main = args[1] + +local function showHelp() + ColourNote("cyan", "", "Spellbook window commands") + ColourNote("cyan", "", "----------------------------------------------------------------") + ColourNote("cyan", "", "spw enable - Enable spellbook") + ColourNote("cyan", "", "spw disable - Disable spellbook") + ColourNote("cyan", "", "spw hide - Hide spell from spellbook") + ColourNote("cyan", "", "spw unhide - Unhide spell from spellbook") + ColourNote("cyan", "", "spw hidden - List hidden spells") + ColourNote("cyan", "", "spw prac - Display practice % mode") + ColourNote("cyan", "", "spw prac one - Practice spell % once per click") + ColourNote("cyan", "", "spw prac full - Practice spell % to full on click") +end + +if main == 'disable' or main == 'off' then + spWin:hide() + EnableAliasGroup("spellbook", false) + EnableTriggerGroup("spellbook", false) + ColourNote("yellow", "", "Spellbook disabled.") +elseif main == 'enable' or main == 'on' then + EnableAliasGroup("spellbook", true) + EnableTriggerGroup("spellbook", true) + ColourNote("yellow", "", "Spellbook enabled.") +elseif main == 'hide' then + local sp = args[2] + if not sp then + ColourNote("yellow", "", "Usage: spw hide ") + return + end + SpWinIgnore[sp] = true + SetVariable("SpWinIgnore", utils.serialize(SpWinIgnore)) + ColourNote("yellow", "", "Spell " .. sp .. " hidden.") +elseif main == 'unhide' then + local sp = args[2] + if not sp then + ColourNote("yellow", "", "Usage: spw unhide ") + return + end + SpWinIgnore[sp] = nil + SetVariable("SpWinIgnore", utils.serialize(SpWinIgnore)) + ColourNote("yellow", "", "Spell " .. sp .. " unhidden.") +elseif main == 'hidden' then + local hidden = "" + for sp, _ in pairs(SpWinIgnore) do + hidden = hidden .. sp .. ", " + end + if hidden == "" then + hidden = "None" + else + hidden = hidden:sub(1, -3) + end + ColourNote("yellow", "", "Hidden spells: " .. hidden) +elseif main == 'prac' then + local mode = args[2] + if mode == 'one' then + SetVariable("SpWinPrac", "one") + ColourNote("yellow", "", "Practice mode set to 'one'.") + elseif mode == 'full' then + SetVariable("SpWinPrac", "full") + ColourNote("yellow", "", "Practice mode set to 'full'.") + else + ColourNote("yellow", "", "Practice mode is currently set to " .. GetVariable("SpWinPrac") .. ".") + end +elseif main == 'help' then + showHelp() +end +]]> - - - - - Send("") - - - -