I apologize in advance for this post. I'm almost religious about not asking other people to write scripts for them. However, I have no idea how to even begin with parsing in a script.
Anyway, I was trying to figure out a way of parsing quotes ("" and `' if possible :D) in an emote so that the script will colorcode the emote correctly based on if there is speech or not. Unfortunately, after trying for about half an hour and getting nowhere, I decided I'd come to you guys :P Really I only need help figuring out how to parse something, and I can probably figure out the rest :)
The hard part comes in because I don't know beforehand how many quotes there will be. If I knew there would only be one set of quotes per emote, then I'd be able to do it. But I really don't know how many. It's roleplay, not a movie. :)
Something like:
> emote smirks at the man. "Yeah right, John." Adding with a shrug, "I guess that would add to our sales income though." He smirks again, still laughing softly at your comment.
I'm trying to make a script that would colorize all the text between quotes ("Yeah right..." and "I guess...")
This is the best I could do. I had hoped to use one large regexp, but couldn't think of a way of doing it. ;)
<triggers>
<trigger
enabled="y"
match="Nick *"
omit_from_output="y"
send_to="14"
sequence="100"
>
<send>
do
local line = "%0" -- copy matching line into variable
local i = 1 -- start at column 1
-- customize this!
local normal_colour = "white"
local quote_colour = "blue"
-- keep processing the line, looking for quoted sections
while i < #line do
-- find opening quote
local quote, _, closing_quote = line:find ([=[(['"])]=], i + 1)
if not quote then
break
end -- no quote found
-- show up to the quote
ColourTell (normal_colour, "", line:sub (i, quote))
-- find closing quote
local end_quote = line:find (closing_quote, quote + 1) or #line
-- show quoted stuff in different colour
ColourTell (quote_colour, "", line:sub (quote + 1, end_quote - 1))
-- next loop iteration is past the quote
i = end_quote
end -- while
-- finish off line
ColourNote (normal_colour, "", line:sub (i))
end
</send>
</trigger>
</triggers>
Basically the script loops looking for quoted sections. You will need to adjust the trigger match to whatever works for you, and plug in some more appropriate colours.
Also, I'm not quite sure how that would even work... You mean I'd have to use some regexp thing to fire through that trigger? I don't quite get what you're doing.