In a game I play, if a line is detected to be an illusion, you will get a subsequent line telling you so. eg.
I've decided that instead of going through the pain of using triggers to ignore the afflictions added by the previous line (since one can use illusions to do far more than make you think you've been hit with something), I modified the packets directly to be prefixed by some text so that they wouldn't be matched. This is the code I am using now within a plugin:
The problem is, this works for most illusions, but some seem to escape it somehow. I'm not sure why, either. I figured there's just something wrong with the way I'm substituting things and I'm hoping someone has a better way to go about it that would work for every line. The example I provided in the beginning is one line that simply didn't detect once.
Most things detect just fine, however, such as:
^ is an output after successful modification.
A cloudy tendril lashes at you, filling your mind with disturbing images.
Your eye immediately notices the flaws in what is obviously an illusion.
I've decided that instead of going through the pain of using triggers to ignore the afflictions added by the previous line (since one can use illusions to do far more than make you think you've been hit with something), I modified the packets directly to be prefixed by some text so that they wouldn't be matched. This is the code I am using now within a plugin:
function OnPluginPacketReceived(text)
local i = string.find(text, "\nYour eye immediately notices the flaws in what is obviously an illusion%.")
if i then
local t = string.sub(text, 1, i - 1)
t = string.gsub(t, "%[", "%%[")
return string.gsub(text, t, string.gsub(t, "\n", "\nIllusion Detected: "))
end
end
The problem is, this works for most illusions, but some seem to escape it somehow. I'm not sure why, either. I figured there's just something wrong with the way I'm substituting things and I'm hoping someone has a better way to go about it that would work for every line. The example I provided in the beginning is one line that simply didn't detect once.
Most things detect just fine, however, such as:
Illusion Detected: A sudden headache makes you rub your temples for relief.
Your eye immediately notices the flaws in what is obviously an illusion.
^ is an output after successful modification.