diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c53f934..e56298f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -30,7 +30,7 @@ jobs: uses: 1arp/create-a-file-action@0.4.5 # see https://github.com/marketplace/actions/create-a-file with: - path: 'src/resources' + path: './' isAbsolutePath: false file: 'version.txt' content: ${{ env.mfile_version }} @@ -60,7 +60,7 @@ jobs: - uses: ncipollo/release-action@v1 # see https://github.com/marketplace/actions/create-release with: - artifacts: "build/MUDKIP_Mud2.mpackage,src/resources/version.txt" + artifacts: "build/MUDKIP_Mud2.mpackage,version.txt" allowUpdates: true bodyFile: "./README.md" tag: ${{ env.mfile_version }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ec4ce3..47b342f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,25 @@ # CHANGELOG +## 1.2.0 + +*17/6/2024* + +* Rewrote the automatic update code a little bit. +* Using the `dword` alias will clear the known dreamword. + * Also added a `DWORD` alias for saying the dreamword IN CAPITALS (for personae who tend to say things in capitals) +* Added an alias to fix accidentally putting an 's' at the end of emote-y commands whilst in game (correcting `smiles` to `smile`, `waves` into `wave`, `laughs` into `laugh` etc). +* Renamed the package to `Multi User Dungeon Kool Informational Package for MUD2` (says `Package` instead of `Panels`) + ## 1.1.2 *7/6/2024* +* Fixed automatic updates (forgot to delete the downloaded version check file :P) + +## 1.1.1 + +*7/6/2024* + * Added automatic updates so you (hopefully) don't need to manually update MUDKIP any more :) ## 1.1.0 diff --git a/README.md b/README.md index 69e71fa..546d634 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # MUDKIP_Mud2 -## Multi User Dungeon Kool Informational Panels (for playing MUD2 with Mudlet) +## Multi User Dungeon Kool Informational Package (for playing MUD2 with Mudlet) -**MUDKIP** is a plucky little [Mudlet](https://www.mudlet.org) plugin +**MUDKIP** is a plucky little [Mudlet](https://www.mudlet.org) package I bodged together, which adds some Kool Informational Panels that might be of use whilst one is playing *MUD2*. @@ -53,13 +53,17 @@ whistles like speedwalking, fancy maps, re-fighting, etc. ### Aliases -* `dword` - * **automatic dreamword** - * If the dreamword is known, this will send a `say ` - command to the game. +* **automatic dreamword** `dword` + * If the dreamword is known, this will send a `say ` command to the game. * If the dreamword is not known, MUDKIP will leave a message telling you that it doesn't know what the dreamword is. * `dwo` and `dwor` are also aliases for this. + * There's an uppercase variant which says the dreamword in uppercase instead. +* **fixing emotes** + * Tired of accidentally sending `laughs`,`smiles`,`waves` etc + and then having the MUD2 parser complain about it? + * *MUDKIP_Mud2* will correct them to `laugh`, `smile`, `wave` etc, allowing you to perform those actions in peace. + * Many other verbs along these lines have also been fixed. ### API @@ -84,12 +88,17 @@ if you wish to contribute to the development of *MUDKIP*. ## CHANGELOG -* **1.1.2** (7/6/2024) - * Added automatic updates so you (hopefully) don't need to manually update MUDKIP any more :) +* **1.2.0** (`17/6/2024) + * Rewrote the automatic update code a little bit. + * Using the `dword` alias will clear the known dreamword. + * Also added a `DWORD` alias for saying the dreamword IN CAPITALS (for personae who tend to say things in capitals) + * Added an alias to fix accidentally putting an 's' at the end of emote-y commands whilst in game (correcting `smiles` to `smile`, `waves` into `wave`, `laughs` into `laugh` etc). + * Slight rebrand for the package (P stands for 'Package' instead of 'Panels' now) - -See [CHANGELOG.md](https://github.com/11BelowStudio/MUDKIP_Mud2/CHANGELOG.md) for the full changelog. +See [CHANGELOG.md](https://github.com/11BelowStudio/MUDKIP_Mud2/blob/main/CHANGELOG.md) for the full changelog. ## TODO * see what people want I guess +* get the auto-update to check the tag on the latest release on git or something like that instead of the release version.txt(?) + diff --git a/docs/readme.png b/docs/readme.png index 7f90b92..a633fe0 100644 Binary files a/docs/readme.png and b/docs/readme.png differ diff --git a/mfile b/mfile index 7fb8c3e..195671a 100644 --- a/mfile +++ b/mfile @@ -1,8 +1,8 @@ { "package": "MUDKIP_Mud2", - "version": "1.1.2", + "version": "1.2.0", "author": "11BelowStudio", - "title": "Multi User Dungeon Kool Informational Panels (for playing MUD2 with Mudlet)", + "title": "Multi User Dungeon Kool Informational Package (for playing MUD2 with Mudlet)", "outputFile": true, "icon": "mudkip.png" } diff --git a/release.json b/release.json index 9fdb257..3c4f4e7 100644 --- a/release.json +++ b/release.json @@ -1,8 +1,8 @@ { "package": "MUDKIP_Mud2", - "version": "1.1.2", + "version": "1.2.0", "author": "11BelowStudio", - "title": "Multi User Dungeon Kool Informational Panels (for playing MUD2 with Mudlet)", + "title": "Multi User Dungeon Kool Informational Package (for playing MUD2 with Mudlet)", "outputFile": true, "icon": "mudkip.png" } \ No newline at end of file diff --git a/src/aliases/MUDKIP_Mud2/aliases.json b/src/aliases/MUDKIP_Mud2/aliases.json index 53bfc56..75a1267 100644 --- a/src/aliases/MUDKIP_Mud2/aliases.json +++ b/src/aliases/MUDKIP_Mud2/aliases.json @@ -6,7 +6,17 @@ }, { "name": "say_dreamword", - "regex": "^dwo(rd?)?", + "regex": "^d[Ww][Oo]([Rr][Dd]?)?$", "isActive": "true" + }, + { + "name": "say_dreamword_uppercase", + "regex": "^D[Ww][Oo]([Rr][Dd]?)?$", + "isActive": "true" + }, + { + "name":"emotes_with_s", + "isActive":"true", + "regex":"(?i)^(?bay|bark|blink|cackle|cheer|chuckle|drool|duck|flip|frown|gasp|giggle|glare|grin|groan|growl|gurgle|howl|laugh|leer|nod|point|ponder|pounce|pucker|purr|quack|roar|scream|shake|shiver|shout|shrug|sing|smile|smirk|spin|stammer|think|twiddle|wait|(re)?wave|whisper|wink|woof|yodel|yawn)s$" } ] diff --git a/src/aliases/MUDKIP_Mud2/emotes_with_s.lua b/src/aliases/MUDKIP_Mud2/emotes_with_s.lua new file mode 100644 index 0000000..64efd67 --- /dev/null +++ b/src/aliases/MUDKIP_Mud2/emotes_with_s.lua @@ -0,0 +1,8 @@ +-- this alias is used to send emotes like 'laugh' when you accidentally send 'laughs' instead +if MUDKIP_Mud2:isInGame() then + --send(matches.emote) -- matches.namedGroup doesn't work for aliases for some reason. + send(matches[2]) -- this does seem to work. weird. +else + -- sends command as-is if you're not in-game + send(command) +end \ No newline at end of file diff --git a/src/aliases/MUDKIP_Mud2/say_dreamword.lua b/src/aliases/MUDKIP_Mud2/say_dreamword.lua index 2dcc033..85c7908 100644 --- a/src/aliases/MUDKIP_Mud2/say_dreamword.lua +++ b/src/aliases/MUDKIP_Mud2/say_dreamword.lua @@ -3,6 +3,7 @@ if MUDKIP_Mud2:isInGame() then local dword = MUDKIP_Mud2:getDreamword() if dword ~= "" then send('say ' .. dword) + MUDKIP_Mud2:clearDreamword() else MUDKIP_Mud2:mcecho("Cannot say an unknown dreamword!","warn") end diff --git a/src/aliases/MUDKIP_Mud2/say_dreamword_uppercase.lua b/src/aliases/MUDKIP_Mud2/say_dreamword_uppercase.lua new file mode 100644 index 0000000..b4e46da --- /dev/null +++ b/src/aliases/MUDKIP_Mud2/say_dreamword_uppercase.lua @@ -0,0 +1,9 @@ +if MUDKIP_Mud2:isInGame() then + local dword = MUDKIP_Mud2:getDreamword() + if dword ~= "" then + send('say ' .. string.upper(dword)) + MUDKIP_Mud2:clearDreamword() + else + MUDKIP_Mud2:mcecho("Cannot say an unknown dreamword!","warn") + end +end \ No newline at end of file diff --git a/src/scripts/MUDKIP_Mud2/updates.lua b/src/scripts/MUDKIP_Mud2/updates.lua index 9a93b52..12c4bfd 100644 --- a/src/scripts/MUDKIP_Mud2/updates.lua +++ b/src/scripts/MUDKIP_Mud2/updates.lua @@ -1,7 +1,7 @@ --[[ THE AUTO-UPDATER FOR MUDKIP_Mud2 -heavily ripped off from https://forums.mudlet.org/viewtopic.php?f=6&t=4400&p=20635&hilit=update#p20635 +heavily ripped off from https://forums.mudlet.org/viewtopic.php?p=20504 (DSL PNP 4.0 Main Script, Zachary Hiland, 2/09/2014) Shoutouts to demonnic for providing the lua code to actually get the package installed and such @@ -17,14 +17,13 @@ local defaults = { version_check_download = "version.txt", version_url = "", file_path = "", - version_check_save = "dl_version.txt", - versions_file_name = "version.txt", + version_check_save = "dl_version.txt"--, + --versions_file_name = "version.txt", } defaults.package_url = defaults.download_path .. defaults.package_name .. ".mpackage" defaults.version_url = defaults.download_path .. defaults.version_check_download defaults.file_path = getMudletHomeDir() .. "/".. defaults.package_name .. "/" - - +defaults.temp_file_path = getMudletHomeDir() .. "/" .. defaults.package_name .. "_temp" .. "/" local download_queue = download_queue or {} local downloading = false @@ -34,7 +33,12 @@ local scripts_list = {} local init_list = {} local event_list = {} +--[[ +Attempts to open a file to read/write/append/modify. +If file could be read, returns table of file {name:str,mode:str,type:"fileIO_file",contents:{str}} and a nil +If it couldn't be read, returns a nil and a string with info about the error. +]] local function fileOpen(filename,mode) local errors mode = mode or "read" @@ -123,18 +127,58 @@ local function update_the_package() end) end -local function load_package_xml() +local function load_package_xml(path) + + + if path ~= defaults.temp_file_path .. defaults.package_name.. ".xml" then + if MUDKIP_Mud2 then + MUDKIP_Mud2:mcecho("Given unexpected .xml file (".. path .."), aborting! (please install the update manually.)", "error") + else + cecho("\nERROR - Given unexpected .xml file (".. path .."), aborting! (please install the update manually.)\n") + return + end + end + + -- uninstall old package uninstallPackage(defaults.package_name) + + -- wipe old package variables etc from memory + _G.MUDKIP_Mud2 = nil + -- install new package - installPackage(defaults.download_path .. defaults.package_name .. ".xml") + tempTimer(1, function() + installPackage(path) + os.remove(path) + lfs.rmdir(defaults.temp_file_path) + end) end -local function load_package_mpackage() +local function load_package_mpackage(path) + + if path ~= defaults.temp_file_path .. defaults.package_name.. ".mpackage" then + if MUDKIP_Mud2 then + MUDKIP_Mud2:mcecho("Given unexpected .mpackage file (".. path .."), aborting! (please install the update manually.)", "error") + else + cecho("\nERROR - Given unexpected .mpackage file (".. path .."), aborting! (please install the update manually.)\n") + return + end + end + -- uninstall old package uninstallPackage(defaults.package_name) + + -- wipe old package variables etc from memory + _G.MUDKIP_Mud2 = nil + -- install new package - installPackage(defaults.download_path .. defaults.package_name .. ".mpackage") + tempTimer(1, function() + installPackage(path) + --installPackage(defaults.temp_file_path .. defaults.package_name .. ".mpackage") + os.remove(path) + lfs.rmdir(defaults.temp_file_path) + end) + --installPackage(defaults.download_path .. defaults.package_name .. ".mpackage") end @@ -144,7 +188,7 @@ local function start_download() -- get info from queue local info = download_queue[1] if MUDKIP_Mud2 then - MUDKIP_Mud2:mcecho("Downloading remote version file " .. info[2] .. " to " .. info[1], "info") + MUDKIP_Mud2:mcecho("Downloading remote file " .. info[2] .. " to " .. info[1], "info") else cecho("\nINFO - Downloading remote version file " .. info[2] .. " to " .. info[1] .. "\n") end @@ -204,33 +248,35 @@ end local function get_version_check() -- create MUDKIP_Mud2 folder in Mudlet home directory if necessary - lfs.mkdir(getMudletHomeDir() .. "/" .. defaults.package_name) + lfs.mkdir(defaults.file_path) -- download current version info queue_download(defaults.file_path .. defaults.version_check_save, defaults.download_path .. defaults.version_check_download) end local function check_versions() - local version_path = defaults.file_path .. defaults.versions_file_name + + + + --local version_path = defaults.file_path .. defaults.versions_file_name local dl_path = defaults.file_path .. defaults.version_check_save local dl_version, curr_version - local dl_file, version_file + local dl_file, dl_errors--, version_file -- read in check file - dl_file = fileOpen(dl_path,"read") - if io.exists(version_path) then - -- read in version file - version_file = fileOpen(version_path,"read") - else - -- create new version file - local temp_v_file = fileOpen(version_path, "write") - temp_v_file.contents = {getPackageInfo(defaults.package_name,"version")} - fileClose(temp_v_file) + dl_file, dl_errors = fileOpen(dl_path,"read") - version_file = fileOpen(version_path,"read") + if dl_file == nil then + -- if something's gone AWOL and we couldn't read the file + if MUDKIP_Mud2 then + MUDKIP_Mud2:mcecho("Could not read remote version info file, aborting auto-update routine. (".. dl_errors ..")", "error") + else + cecho("\nERROR - Could not read remote version info file, aborting auto-update routine. (".. dl_errors ..")\n") + return + end end - curr_version = version_file.contents[1] + curr_version = getPackageInfo(defaults.package_name,"version") --version_file.contents[1] dl_version = dl_file.contents[1] if MUDKIP_Mud2 then @@ -240,7 +286,7 @@ local function check_versions() end -- close the files (we don't need them any more) - fileClose(version_file) + --fileClose(version_file) fileClose(dl_file) os.remove(dl_path) @@ -251,7 +297,8 @@ local function check_versions() else cecho("\nINFO - Attempting to update MUDKIP to v" .. dl_version .."\n") end - update_the_package() + M2Updates:update_package() + --update_the_package() else if MUDKIP_Mud2 then MUDKIP_Mud2:mcecho("MUDKIP_Mud2 is up-to-date, have a nice day :)", "info") @@ -260,6 +307,8 @@ local function check_versions() end end + + end local function finish_download(path) @@ -273,9 +322,9 @@ local function finish_download(path) if string.find(path,defaults.version_check_save) then check_versions() elseif string.find(path,".mpackage") then - --load_package_mpackage() + load_package_mpackage(path) elseif string.find(path,".xml") then - --load_package_xml() + load_package_xml(path) end end @@ -286,17 +335,17 @@ local function fail_download(...) if MUDKIP_Mud2 then MUDKIP_Mud2:mcecho("failed downloading " .. arg[2] .. arg[1], "error") else - cecho("\nERROR - failed downloading " .. arg[2] .. arg[1].. "\n") + cecho("\nERROR - failed downloading " .. arg[2] .. arg[1].. "\n") end --table.insert(unavailable, arg[1]) end function M2Updates:update_package() - -- create MUDKIP_Mud2 folder in Mudlet home directory if necessary - --lfs.mkdir(getMudletHomeDir() .. "/MUDKIP_Mud2") + -- create MUDKIP_Mud2_temp folder in Mudlet home directory if necessary + lfs.mkdir(defaults.temp_file_path) -- download newest package - --queue_download(defaults.file_path .. defaults.package_name .. ".xml", defaults.download_path .. defaults.package_name .. ".xml") + queue_download(defaults.temp_file_path .. defaults.package_name .. ".mpackage", defaults.download_path .. defaults.package_name .. ".mpackage") end function M2Updates:update_scripts()