Hello, I'm having a problem creating simple casting and targeting aliases since I do not have much experience with scripting and I was wondering if I could get some assistance
Example 1
I've created an alias to cast lightning on a target;
pattern: ^cl(.+)$
send("cast lightning"..(matches[2] or target))
This works fine. If I "cl bear", it casts "cast lightning bear".
However, it's conflicting with basic in-game commands. For example, if I "clanwhere" to check where my clannies are located, it'll do the following "cast lightninganwhere"
Example 2
I've created two aliases for different spells;
The first casts shocking on a target:
pattern: ^cs(.+)$
send("cast shocking"..(matches[2] or target))
Again, this works fine. "cs bear" casts "cast shocking bear"
The second casts sanctuary without a target (because it doesn't need one, it casts only on the user);
pattern: ^css$
command: cast sanctuary
Again, this works fine. However, it also casts shocking because of the similar syntax. So, I'll see in-game
"cast shockings"
"cast sanctuary"
In both cases, I'd like it to use the exact match of the alias syntax without conflicting with in-game commands or other aliases. I know I could simply change the pattern in example 2 to something like "^csanc$" but this does not solve the conflict with in-game commands and there are numerous ones. Is there a way to change the pattern or the sending without having to change the alias naming itself and fix this conflict?
Like I said, I have very little experience with scripting so any help would be appreciated!
Help creating casting alias
Re: Help creating casting alias
For the spells with a target, I'd change the pattern slightly:
Pattern: ^cl(?: (.+))?$
Script: send("cast lightning " .. (matches[2] or target)) -- I added a space behind lightning
This should get rid of the conflicts, as long as there are no "cs" or "cl" aliases or in-game commands (just that word or starting with it and a whitespace).
An explanation of the changed pattern can be found at https://regex101.com/r/yRw4N2/1 on the right side.
Pattern: ^cl(?: (.+))?$
Script: send("cast lightning " .. (matches[2] or target)) -- I added a space behind lightning
This should get rid of the conflicts, as long as there are no "cs" or "cl" aliases or in-game commands (just that word or starting with it and a whitespace).
An explanation of the changed pattern can be found at https://regex101.com/r/yRw4N2/1 on the right side.
Re: Help creating casting alias
It worked! You know, I had been experimenting with the with the spaces and the commands in the mudlet help file but I had not gotten around to this combination I guess. Thank you so much