Code: Select all
<triggers>
<trigger
enabled="y"
group="exam"
match="(.*?)You notice (.+?)\.$"
omit_from_output="y"
regexp="y"
send_to="14"
sequence="100"
>
<send>-- Display room description and items
ColourNote ("lightgray", "black", "%1\\n\\nIn this room:")
-- Split the items into a table of items and strip the commas and leading space from each
local items = utils.split ("%2", ",")
for i, v in ipairs (items) do
items [i] = v:sub (2)
end -- for
-- Calcualate a count of each item
local counts = {}
for _, v in ipairs (items) do
counts [v] = (counts [v] or 0) + 1
end -- for
-- Display every item with a running count
for key, value in ipairs (items) do
print (key, value)
end -- for
-- Display each item with its quantity
for k, v in pairs (counts) do
ColourNote ("lightgray", "black", ("%i %s"):format (v, k))
end -- for
</send>
</trigger>
</triggers>