My problem is simple this. When I load an lua file with require it seem to cause some kind of a problem with script="sub". No error message shows up when loaded, but when the pattern matches and the trigger runs, it says "Trigger function "sub" not found or had a previous error.". This is -only- when I load with require. If I open my triggers in mushclient and enable the trigger "test" manually it works just like it should. If I use EnableTrigger or EnableGroup the error shows up when the pattern matches.. Can someone please explain this, its driving me nuts.. I'm trying to inplant a flexible system changing my offence depanding on what characther I'm using and not filling up the entire client with triggers and etc.
------------------------------
My main lua file loaded by the mushclient contains this and much more:
function is called and name = "assassin":
DeleteTriggerGroup("classes")
DeleteAliasGroup("classes")
DeleteTimerGroup("classes")
DeleteTemporaryAliases()
DeleteTemporaryTriggers()
classes = utils.readdir (GetInfo(57) .. "plugins\\xtcy\\classes\\*.lua") assert (classes)
for k, v in classes do
if tostring(string.gsub(k, "(%a+).lua", "%1")) == name then
require(GetInfo(57) .. "plugins\\xtcy\\classes\\" .. tostring(k))
end
end
function sub(subtext)
if subtext ~= "" then stext = subtext end
for word in string.gfind(stext, "($[#%a%d]+$[^$]+)") do
ColourTell(tostring(string.gsub(word, "$([#%a%d]+)$(.*)", "%1")), "black", tostring(string.gsub(word, "$([#%a%d]+)$(.*)", "%2")))
end
ColourTell("", "", "\n")
end
---------------------------
Assassin.lua contains this and other things.
ImportXML
[[
<triggers>
<trigger name="test" lines_to_match="2" keep_evaluating="y" match="^You prepare yourself to hypnotise your victim, (.*)\n(.*)\.$" multi_line="y" regexp="y" script="sub" send_to="12" sequence="101" group="classes">
<send>stext = "$gray$Prepares hypnosis for $white$" .. tostring("%1%2") .. "$darkgray$."</send>
</trigger>
</triggers>
]]
Ps. I've used LoadPlugin("url") before, the problem with that is that I cant use function in my main lua file with the aliases, triggers and timers which is vital for my system since its need to know balances, wielded weapons, current afflictions and so on. .ds
Many thanks to whoever can solve or atleast tell me why and what my problem is.
------------------------------
My main lua file loaded by the mushclient contains this and much more:
function is called and name = "assassin":
DeleteTriggerGroup("classes")
DeleteAliasGroup("classes")
DeleteTimerGroup("classes")
DeleteTemporaryAliases()
DeleteTemporaryTriggers()
classes = utils.readdir (GetInfo(57) .. "plugins\\xtcy\\classes\\*.lua") assert (classes)
for k, v in classes do
if tostring(string.gsub(k, "(%a+).lua", "%1")) == name then
require(GetInfo(57) .. "plugins\\xtcy\\classes\\" .. tostring(k))
end
end
function sub(subtext)
if subtext ~= "" then stext = subtext end
for word in string.gfind(stext, "($[#%a%d]+$[^$]+)") do
ColourTell(tostring(string.gsub(word, "$([#%a%d]+)$(.*)", "%1")), "black", tostring(string.gsub(word, "$([#%a%d]+)$(.*)", "%2")))
end
ColourTell("", "", "\n")
end
---------------------------
Assassin.lua contains this and other things.
ImportXML
[[
<triggers>
<trigger name="test" lines_to_match="2" keep_evaluating="y" match="^You prepare yourself to hypnotise your victim, (.*)\n(.*)\.$" multi_line="y" regexp="y" script="sub" send_to="12" sequence="101" group="classes">
<send>stext = "$gray$Prepares hypnosis for $white$" .. tostring("%1%2") .. "$darkgray$."</send>
</trigger>
</triggers>
]]
Ps. I've used LoadPlugin("url") before, the problem with that is that I cant use function in my main lua file with the aliases, triggers and timers which is vital for my system since its need to know balances, wielded weapons, current afflictions and so on. .ds
Many thanks to whoever can solve or atleast tell me why and what my problem is.