Skip to content

Commit

Permalink
Merge branch 'development' into MUSHclient
Browse files Browse the repository at this point in the history
  • Loading branch information
fiendish committed Apr 4, 2018
2 parents 48aa23b + cdc6202 commit 4296bd1
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 22 deletions.
3 changes: 3 additions & 0 deletions MUSHclient/AardwolfPackageChanges.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
Aardwolf Client Package Major Changes List

r1982 snapshot
- bug fix: The #sub/#gag plugin will politely decline invalid patterns instead of entering an endless cycle of errors.

r1981 snapshot
- new feature: The communication log's storeFromOutside function now lets you set the tab index or name where you want your message to go. It defaults to the first tab.
- new feature: functions findTab, nameTab, and getNamedTab added to the communication log plugin to, respectively, find the index of a named tab, programmatically name a tab, and programmatically add a new named tab if one doesn't already exist with the given name.
Expand Down
53 changes: 31 additions & 22 deletions MUSHclient/worlds/plugins/aard_text_substitution.xml
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ dofile(GetInfo(60) .. "aardwolf_colors.lua")
require "addxml"
function apply_pattern_as_trigger(original_pattern, nocase, alone)
addxml.trigger(
if pcall(
addxml.trigger,
{
match = original_pattern:gsub("([^%%]?)%%([^%%])", "%1\\%2"), -- replace % escapes with \ escapes
enabled = true,
Expand All @@ -164,7 +165,13 @@ function apply_pattern_as_trigger(original_pattern, nocase, alone)
send = "StopEvaluatingTriggers(true)",
group = "all"
}
)
) then
return true
else
AnsiNote(ColoursToANSI("@RERROR CREATING PATTERN: @Y"..original_pattern))
Simulate(ColoursToANSI("@RThis may be caused by needing to escape dangling magic characters in your pattern with @Y%@R (Read https://www.lua.org/pil/20.2.html for information about Lua patterns)\r\n"))
return false
end
end
function set_triggers()
Expand Down Expand Up @@ -399,19 +406,20 @@ function addsub(name, line, wildcards)
local found = find_in(subs, wildcards[1], nocase, alone, use_function)
if found then remsub(nil, nil, {found}) end
table.insert(subs,
{
fromstr=fromstr,
tostr=tostr,
original=wildcards[1],
nocase=nocase,
alone=alone,
use_function=use_function
})
if apply_pattern_as_trigger(wildcards[1], nocase, alone) then
table.insert(subs,
{
fromstr=fromstr,
tostr=tostr,
original=wildcards[1],
nocase=nocase,
alone=alone,
use_function=use_function
})
apply_pattern_as_trigger(wildcards[1], nocase, alone)
AnsiNote(ColoursToANSI("@YCreated sub "..#subs..": "..format_sub(subs[#subs])))
end
AnsiNote(ColoursToANSI("@YCreated sub "..#subs..": "..format_sub(subs[#subs])))
SaveState()
end
Expand Down Expand Up @@ -451,17 +459,18 @@ function addgag(name, line, wildcards)
local found = find_in(gags, wildcards[1], nocase, alone, use_function)
if found then remgag(nil, nil, {found}) end
table.insert(gags, {
gagstr=gagstr,
original=wildcards[1],
nocase=nocase,
alone=alone,
use_function=use_function
})
if apply_pattern_as_trigger(wildcards[1], nocase, alone) then
table.insert(gags, {
gagstr=gagstr,
original=wildcards[1],
nocase=nocase,
alone=alone,
use_function=use_function
})
apply_pattern_as_trigger(wildcards[1], nocase, alone)
AnsiNote(ColoursToANSI("@YCreated gag "..#gags..": "..format_gag(gags[#gags])))
end
AnsiNote(ColoursToANSI("@YCreated gag "..#gags..": "..format_gag(gags[#gags])))
SaveState()
end
Expand Down

0 comments on commit 4296bd1

Please sign in to comment.