Named patterns demo

Share your scripts and packages with other Mudlet users.
Post Reply
User avatar
Vadi
Posts: 4941
Joined: Sat Mar 14, 2009 3:13 pm

Named patterns demo

Post by Vadi »

A little demo package showing how to use named patterns, which allows your triggers to use matches.variablename as a capture instead of matches[#]:

Before:
Selection_077.png
Selection_077.png (54.85 KiB) Viewed 357 times
After:
Selection_079.png
Selection_079.png (82.41 KiB) Viewed 357 times
This is particularly handy when you have several patterns and the order of matches changes throughout them, as you can notice is the case here - attacker either comes first or second in the patterns.
Attachments
Named patterns demo.mpackage
(1.26 KiB) Downloaded 29 times

User avatar
demonnic
Posts: 720
Joined: Sat Dec 05, 2009 3:19 pm

Re: Named patterns demo

Post by demonnic »

+1 for the use of f as well =)

User avatar
Vadi
Posts: 4941
Joined: Sat Mar 14, 2009 3:13 pm

Re: Named patterns demo

Post by Vadi »

Indeed, check out the docs for this useful addition by demonnic: https://wiki.mudlet.org/w/Manual:Lua_Functions#f

Post Reply