Skip to content

Commit ad665df

Browse files
iLPdeveterchun
andauthored
build: release 1.4.1 (#79)
* 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 <[email protected]>
1 parent d3ea8a1 commit ad665df

File tree

3 files changed

+79
-60
lines changed

3 files changed

+79
-60
lines changed

β€ŽPRS.luaβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
-- Procedural Realms Script (PRS) by Stack
22

3-
local version = "1.4.0"
3+
local version = "1.4.1"
44

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

1616
-- Announce PR on Discord
17-
setDiscordGame("Procedural Realms")
17+
setDiscordGame("Procedural Realms")

β€Žprs-chat.luaβ€Ž

Lines changed: 70 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -87,87 +87,102 @@ function PRSchat.initialize()
8787
PRSchat.triggers.chat_trigger_id = tempRegexTrigger("^< Chat \\| (?<sender>.+) > (?<msg>.+)$", function()
8888
local chat_lines = {}
8989

90-
PRSchat.triggers.chat_line_id = tempRegexTrigger(".*", function()
91-
if isPrompt() then
92-
local concat_lines = table.concat(chat_lines)
93-
local result = concat_lines:sub(1, -2).."\n"
94-
95-
PRSchat.EMCO:decho("Chat", result, false)
96-
killTrigger(PRSchat.triggers.chat_line_id)
97-
else
98-
table.insert(chat_lines, copy2decho().." ")
99-
end
100-
end)
90+
if not PRSchat.triggers.chat_line_id then
91+
PRSchat.triggers.chat_line_id = tempRegexTrigger(".*", function()
92+
if isPrompt() then
93+
local concat_lines = table.concat(chat_lines)
94+
local result = concat_lines:sub(1, -2).."\n"
95+
96+
PRSchat.EMCO:decho("Chat", result, false)
97+
killTrigger(PRSchat.triggers.chat_line_id)
98+
PRSchat.triggers.chat_line_id = nil
99+
else
100+
table.insert(chat_lines, copy2decho().." ")
101+
end
102+
end)
103+
end
101104
end)
102105
end
103106

104107
if not PRSchat.triggers.newbie_trigger_id then
105108
PRSchat.triggers.newbie_trigger_id = tempRegexTrigger("^< Newbie \\| (?<sender>.+) > (?<msg>.+)$", function()
106109
local chat_lines = {}
107-
108-
PRSchat.triggers.newbie_line_id = tempRegexTrigger(".*", function()
109-
if isPrompt() then
110-
local concat_lines = table.concat(chat_lines)
111-
local result = concat_lines:sub(1, -2).."\n"
112-
113-
PRSchat.EMCO:decho("Newbie", result, false)
114-
killTrigger(PRSchat.triggers.newbie_line_id)
115-
else
116-
table.insert(chat_lines, copy2decho().." ")
117-
end
118-
end)
110+
111+
if not PRSchat.triggers.newbie_line_id then
112+
PRSchat.triggers.newbie_line_id = tempRegexTrigger(".*", function()
113+
if isPrompt() then
114+
local concat_lines = table.concat(chat_lines)
115+
local result = concat_lines:sub(1, -2).."\n"
116+
117+
PRSchat.EMCO:decho("Newbie", result, false)
118+
killTrigger(PRSchat.triggers.newbie_line_id)
119+
PRSchat.triggers.newbie_line_id = nil
120+
else
121+
table.insert(chat_lines, copy2decho().." ")
122+
end
123+
end)
124+
end
119125
end)
120126
end
121127

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

126-
PRSchat.triggers.trade_line_id = tempRegexTrigger(".*", function()
127-
if isPrompt() then
128-
local concat_lines = table.concat(chat_lines)
129-
local result = concat_lines:sub(1, -2).."\n"
130-
131-
PRSchat.EMCO:decho("Trade", result, false)
132-
killTrigger(PRSchat.triggers.trade_line_id)
133-
else
134-
table.insert(chat_lines, copy2decho().." ")
135-
end
136-
end)
132+
if not PRSchat.triggers.trade_line_id then
133+
PRSchat.triggers.trade_line_id = tempRegexTrigger(".*", function()
134+
if isPrompt() then
135+
local concat_lines = table.concat(chat_lines)
136+
local result = concat_lines:sub(1, -2).."\n"
137+
138+
PRSchat.EMCO:decho("Trade", result, false)
139+
killTrigger(PRSchat.triggers.trade_line_id)
140+
PRSchat.triggers.trade_line_id = nil
141+
else
142+
table.insert(chat_lines, copy2decho().." ")
143+
end
144+
end)
145+
end
137146
end)
138147
end
139148

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

144-
PRSchat.triggers.local_line_id = tempRegexTrigger(".+", function()
145-
table.insert(chat_lines, copy2decho().." ")
146-
if string.ends(line, "'") then
147-
local concat_lines = table.concat(chat_lines)
148-
local result = concat_lines:sub(1, -2).."\n"
149-
150-
PRSchat.EMCO:decho("Local", result, false)
151-
killTrigger(PRSchat.triggers.local_line_id)
152-
end
153-
end)
153+
if not PRSchat.triggers.local_line_id then
154+
PRSchat.triggers.local_line_id = tempRegexTrigger(".+", function()
155+
table.insert(chat_lines, copy2decho().." ")
156+
if string.ends(line, "'") then
157+
local concat_lines = table.concat(chat_lines)
158+
local result = concat_lines:sub(1, -2).."\n"
159+
160+
PRSchat.EMCO:decho("Local", result, false)
161+
killTrigger(PRSchat.triggers.local_line_id)
162+
PRSchat.triggers.local_line_id = nil
163+
end
164+
end)
165+
end
154166
end)
155167
end
156168

157169
if not PRSchat.triggers.tell_trigger_id then
158170
PRSchat.triggers.tell_trigger_id = tempRegexTrigger("^(?<from>.+) tell(?<s>s)? (?<to>\\w+), '(?<msg>.+)$", function()
159171
local chat_lines = {}
160-
161-
PRSchat.triggers.tell_line_id = tempRegexTrigger(".+", function()
162-
table.insert(chat_lines, copy2decho().." ")
163-
if string.ends(line, "'") then
164-
local concat_lines = table.concat(chat_lines)
165-
local result = concat_lines:sub(1, -2).."\n"
166-
167-
PRSchat.EMCO:decho("Tell", result, false)
168-
killTrigger(PRSchat.triggers.tell_line_id)
169-
end
170-
end)
172+
173+
if not PRSchat.triggers.tell_line_id then
174+
PRSchat.triggers.tell_line_id = tempRegexTrigger(".+", function()
175+
table.insert(chat_lines, copy2decho().." ")
176+
if string.ends(line, "'") then
177+
local concat_lines = table.concat(chat_lines)
178+
local result = concat_lines:sub(1, -2).."\n"
179+
180+
PRSchat.EMCO:decho("Tell", result, false)
181+
killTrigger(PRSchat.triggers.tell_line_id)
182+
PRSchat.triggers.tell_line_id = nil
183+
end
184+
end)
185+
end
171186
end)
172187
end
173188
end

β€Žprs-stats.luaβ€Ž

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,9 @@ local function add_gauges()
233233

234234
if PRSstats.events.xpForNextLevel_id then killAnonymousEventHandler(PRSstats.events.xpForNextLevel_id) end
235235
PRSstats.events.xpForNextLevel_id = registerAnonymousEventHandler("gmcp.Char.player.xpForNextLevel", function()
236-
PRSstats.xp.tnl = gmcp.Char.player.xpForNextLevel - gmcp.Char.player.xpForCurrentLevel
236+
if gmcp.Char.player.xpForNextLevel then
237+
PRSstats.xp.tnl = gmcp.Char.player.xpForNextLevel - gmcp.Char.player.xpForCurrentLevel
238+
end
237239
end)
238240
end
239241
end
@@ -246,8 +248,10 @@ function PRSstats.stats()
246248
add_gauges()
247249
else
248250
local initialize_ev_handler = registerAnonymousEventHandler("gmcp.Char.player", function()
249-
PRSstats.UW:setTitle("Vitals - "..gmcp.Char.player.name)
250-
add_gauges()
251+
if gmcp and gmcp.Char and gmcp.Char.player and gmcp.Char.player.name then
252+
PRSstats.UW:setTitle("Vitals - "..gmcp.Char.player.name)
253+
add_gauges()
254+
end
251255
end, true)
252256
end
253257
end

0 commit comments

Comments
Β (0)