Skip to content

Commit

Permalink
build: release 1.4.1 (#79)
Browse files Browse the repository at this point in the history
* fix(stats): πŸ› add check to xpForNextLevel (#76)
* fix(stats): πŸ› add check for gmcp player data at login (#77)
* fix(chat): πŸ› add guards around chat triggers (#75)
* docs: πŸ“„ advance local version to 1.4.1

---------

Co-authored-by: eterchun <edward.terchunian@gmail.com>
  • Loading branch information
iLPdev and eterchun committed May 13, 2023
1 parent d3ea8a1 commit ad665df
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 60 deletions.
4 changes: 2 additions & 2 deletions PRS.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-- Procedural Realms Script (PRS) by Stack

local version = "1.4.0"
local version = "1.4.1"

-- check if the generic_mapper package is installed and, if so, uninstall it
if table.contains(getPackages(),"generic_mapper") then
Expand All @@ -14,4 +14,4 @@ registerAnonymousEventHandler("gmcp.Char.player", function()
end, true)

-- Announce PR on Discord
setDiscordGame("Procedural Realms")
setDiscordGame("Procedural Realms")
125 changes: 70 additions & 55 deletions prs-chat.lua
Original file line number Diff line number Diff line change
Expand Up @@ -87,87 +87,102 @@ function PRSchat.initialize()
PRSchat.triggers.chat_trigger_id = tempRegexTrigger("^< Chat \\| (?<sender>.+) > (?<msg>.+)$", function()
local chat_lines = {}

PRSchat.triggers.chat_line_id = tempRegexTrigger(".*", function()
if isPrompt() then
local concat_lines = table.concat(chat_lines)
local result = concat_lines:sub(1, -2).."\n"

PRSchat.EMCO:decho("Chat", result, false)
killTrigger(PRSchat.triggers.chat_line_id)
else
table.insert(chat_lines, copy2decho().." ")
end
end)
if not PRSchat.triggers.chat_line_id then
PRSchat.triggers.chat_line_id = tempRegexTrigger(".*", function()
if isPrompt() then
local concat_lines = table.concat(chat_lines)
local result = concat_lines:sub(1, -2).."\n"

PRSchat.EMCO:decho("Chat", result, false)
killTrigger(PRSchat.triggers.chat_line_id)
PRSchat.triggers.chat_line_id = nil
else
table.insert(chat_lines, copy2decho().." ")
end
end)
end
end)
end

if not PRSchat.triggers.newbie_trigger_id then
PRSchat.triggers.newbie_trigger_id = tempRegexTrigger("^< Newbie \\| (?<sender>.+) > (?<msg>.+)$", function()
local chat_lines = {}

PRSchat.triggers.newbie_line_id = tempRegexTrigger(".*", function()
if isPrompt() then
local concat_lines = table.concat(chat_lines)
local result = concat_lines:sub(1, -2).."\n"

PRSchat.EMCO:decho("Newbie", result, false)
killTrigger(PRSchat.triggers.newbie_line_id)
else
table.insert(chat_lines, copy2decho().." ")
end
end)

if not PRSchat.triggers.newbie_line_id then
PRSchat.triggers.newbie_line_id = tempRegexTrigger(".*", function()
if isPrompt() then
local concat_lines = table.concat(chat_lines)
local result = concat_lines:sub(1, -2).."\n"

PRSchat.EMCO:decho("Newbie", result, false)
killTrigger(PRSchat.triggers.newbie_line_id)
PRSchat.triggers.newbie_line_id = nil
else
table.insert(chat_lines, copy2decho().." ")
end
end)
end
end)
end

if not PRSchat.triggers.trade_trigger_id then
PRSchat.triggers.trade_trigger_id = tempRegexTrigger("^< Trade \\| (?<sender>.+) > (?<msg>.+)$", function()
local chat_lines = {}

PRSchat.triggers.trade_line_id = tempRegexTrigger(".*", function()
if isPrompt() then
local concat_lines = table.concat(chat_lines)
local result = concat_lines:sub(1, -2).."\n"

PRSchat.EMCO:decho("Trade", result, false)
killTrigger(PRSchat.triggers.trade_line_id)
else
table.insert(chat_lines, copy2decho().." ")
end
end)
if not PRSchat.triggers.trade_line_id then
PRSchat.triggers.trade_line_id = tempRegexTrigger(".*", function()
if isPrompt() then
local concat_lines = table.concat(chat_lines)
local result = concat_lines:sub(1, -2).."\n"

PRSchat.EMCO:decho("Trade", result, false)
killTrigger(PRSchat.triggers.trade_line_id)
PRSchat.triggers.trade_line_id = nil
else
table.insert(chat_lines, copy2decho().." ")
end
end)
end
end)
end

if not PRSchat.triggers.local_trigger_id then
PRSchat.triggers.local_trigger_id = tempRegexTrigger("^(?<sender>.+) say(?<s>s)?, '(?<msg>.+)$", function()
local chat_lines = {}

PRSchat.triggers.local_line_id = tempRegexTrigger(".+", function()
table.insert(chat_lines, copy2decho().." ")
if string.ends(line, "'") then
local concat_lines = table.concat(chat_lines)
local result = concat_lines:sub(1, -2).."\n"

PRSchat.EMCO:decho("Local", result, false)
killTrigger(PRSchat.triggers.local_line_id)
end
end)
if not PRSchat.triggers.local_line_id then
PRSchat.triggers.local_line_id = tempRegexTrigger(".+", function()
table.insert(chat_lines, copy2decho().." ")
if string.ends(line, "'") then
local concat_lines = table.concat(chat_lines)
local result = concat_lines:sub(1, -2).."\n"

PRSchat.EMCO:decho("Local", result, false)
killTrigger(PRSchat.triggers.local_line_id)
PRSchat.triggers.local_line_id = nil
end
end)
end
end)
end

if not PRSchat.triggers.tell_trigger_id then
PRSchat.triggers.tell_trigger_id = tempRegexTrigger("^(?<from>.+) tell(?<s>s)? (?<to>\\w+), '(?<msg>.+)$", function()
local chat_lines = {}

PRSchat.triggers.tell_line_id = tempRegexTrigger(".+", function()
table.insert(chat_lines, copy2decho().." ")
if string.ends(line, "'") then
local concat_lines = table.concat(chat_lines)
local result = concat_lines:sub(1, -2).."\n"

PRSchat.EMCO:decho("Tell", result, false)
killTrigger(PRSchat.triggers.tell_line_id)
end
end)

if not PRSchat.triggers.tell_line_id then
PRSchat.triggers.tell_line_id = tempRegexTrigger(".+", function()
table.insert(chat_lines, copy2decho().." ")
if string.ends(line, "'") then
local concat_lines = table.concat(chat_lines)
local result = concat_lines:sub(1, -2).."\n"

PRSchat.EMCO:decho("Tell", result, false)
killTrigger(PRSchat.triggers.tell_line_id)
PRSchat.triggers.tell_line_id = nil
end
end)
end
end)
end
end
Expand Down
10 changes: 7 additions & 3 deletions prs-stats.lua
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,9 @@ local function add_gauges()

if PRSstats.events.xpForNextLevel_id then killAnonymousEventHandler(PRSstats.events.xpForNextLevel_id) end
PRSstats.events.xpForNextLevel_id = registerAnonymousEventHandler("gmcp.Char.player.xpForNextLevel", function()
PRSstats.xp.tnl = gmcp.Char.player.xpForNextLevel - gmcp.Char.player.xpForCurrentLevel
if gmcp.Char.player.xpForNextLevel then
PRSstats.xp.tnl = gmcp.Char.player.xpForNextLevel - gmcp.Char.player.xpForCurrentLevel
end
end)
end
end
Expand All @@ -246,8 +248,10 @@ function PRSstats.stats()
add_gauges()
else
local initialize_ev_handler = registerAnonymousEventHandler("gmcp.Char.player", function()
PRSstats.UW:setTitle("Vitals - "..gmcp.Char.player.name)
add_gauges()
if gmcp and gmcp.Char and gmcp.Char.player and gmcp.Char.player.name then
PRSstats.UW:setTitle("Vitals - "..gmcp.Char.player.name)
add_gauges()
end
end, true)
end
end

0 comments on commit ad665df

Please sign in to comment.