mudgangster

Log | Files | Refs

commit bbb763dccbdbc0f5dc22b03b03ad4363e36e0905
parent 348a2def10a1855ce420e2184afcd8d69cd07077
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Fri,  7 Sep 2018 15:18:09 +0300

pcall subs

Diffstat:
src/lua/sub.lua | 7++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/lua/sub.lua b/src/lua/sub.lua @@ -5,7 +5,12 @@ local function doSubs( line ) local sub = Subs[ i ] if sub.enabled then - local newLine, subs = line:gsub( sub.pattern, sub.replacement ) + local ok, newLine, subs = pcall( string.gsub, line, sub.pattern, sub.replacement ) + + if not ok then + mud.print( "\n#s> sub failed: %s\n%s\n%s", newLine, sub.pattern, sub.replacement ) + return line + end if subs ~= 0 then return newLine