|Hi! I was trying to make a trigger to separate clothes from description in Lusternia but I'm having a weird issue with Lua in it. I'm using MUSHclient version 4.77. The following is the trigger I made:|
match="^(He|She) is (.+) (He|She) is wearing (.+)$"
<send>local data = "%0"
local gender = "%1"
local clothindex = string.find(data, "is wearing")
local description = string.sub(data, 1, clothindex - 2)
local reversed = string.reverse(description)
local lastperiod = string.find(reversed, "%.")
local description = string.sub(description, 1, string.len(description) - lastperiod + 1)
local clothes = string.sub(data, clothindex, string.len(data))
local lastperiod = string.find(clothes, "%.")
local clothes = string.sub(clothes, 1, lastperiod)
local clothes = gender .. " " .. clothes
local clothindex = string.find(data, clothes)
if clothindex then
description = description .. string.sub(data, clothindex + string.len(clothes), string.len(data))
local clothes = string.gsub(clothes, "is wearing", "is wearing:\n")
local clothes = string.gsub(clothes, ",", ",\n")
ColourNote("lightgrey", "", description)
ColourNote("lightgrey", "", clothes)</send>
And here's a sample match text:
She is a bouncing furrikin and stands at just under four feet in height. Her body is lithely built, with sensuous curves in all the right places. She is covered in thick, jet-black fur, with streaks of silver on her face and two wide bands running down the length of her tail, ending in a large patch at the tip. Her ears are triangular and stand straight up, twitching in response to any sound, while her tail sways gently from side to side. Her eyes burn with the brilliant orange of sunset, and contain flecks of azure and violet. They seem unable to focus on any one thing for long, and her gaze constantly shifts around the area. Her face is unmarked by the passage of time, save for the many thick scars curling down the right side of her face. The longest starts just below her eye and curls under her chin, and is crossed intermittently by shorter scars at irregular angles. She is wearing a golden lion brooch, a braided ring of opal and moonstone, a shining silver scabbard, a slender sapphire collar of brushed suede, a delicate snowflake earring through her left ear, a silver bracelet of snowflakes, a delicate snowflake earring through her right ear, velvet robes of snow and ice, a golden bear brooch, a thin opal bracelet carved with lilies, 3 pocketbelts and a twilight blue rose. Tattooed on her arms is the illustration of a twining vine with large leaves.
But I keep getting this error:
[string "Trigger: "]:15: unfinished string near '"is wearing:'
However, if I take the trigger script and paste it in the Immediate box, give the variables data = <matchtext above> and gender = <She> (the text the trigger would assign) and click Run it works!
I'm not sure if I'm using the keyword 'local' too much or too little. I'd appreciate any help regarding this. Thanks!