Hey!
I'm new to Mudlet/Lua as a whole, so this could be a multitude of problems, ranging from PCRE, to Lua, to Mudlet in general.
Here is what I'm trying to do!
Change:
Your guardian angel senses Keahi at The Arcanists' Teleportation Chamber, on a health of 4854 and a mana of 3857.
To:
Keahi is at The Arcanists' Teleportation Chamber. Health: 4854. Mana: 3857.
Here's what I tried.
Name: Presences Trigger
Pattern: ^Your guardian angel senses \w at .*\, on a health of \d and a mana of \d\.$
(Perl Regex option in the drop-down menu)
Script:
resetFormat()
selectString("^Your guardian angel senses \w at .*\, on a health of \d and a mana of \d\.$", 1)
replace(matches[2].." is at "..matches[3]..". Health: "..matches[4]..". Mana: "..matches[5]..".")
How did I fail?
Substitutions!
Re: Substitutions!
Ok, first of all \w only matches a -single- letter/digit and \d only matches a -single- digit. For matching one or more of them, you'd use \w+ and \d+. Second, you don't need the \ before the comma. Third, in order to capture your wildcards and use them in the script, you need to put brackets around them. Therefore your pattern should be:
^Your guardian angel senses (\w+) at (.+), on a health of (\d+) and a mana of (\d+)\.$
Then you'll also need to change your selectString() to:
selectString(line, 1)
selectString doesn't work with regular expressions. You have to use literal strings. Line is simply the whole line your trigger matched on. (Alternatively, you could also use matches[1] in this example.)
Last, make sure your screenwidth is set to 0, or the trigger won't match if the message goes over two lines.
^Your guardian angel senses (\w+) at (.+), on a health of (\d+) and a mana of (\d+)\.$
Then you'll also need to change your selectString() to:
selectString(line, 1)
selectString doesn't work with regular expressions. You have to use literal strings. Line is simply the whole line your trigger matched on. (Alternatively, you could also use matches[1] in this example.)
Last, make sure your screenwidth is set to 0, or the trigger won't match if the message goes over two lines.
Re: Substitutions!
Thanks! That helps clear a lot up.
Another question, I was wondering if it was possible to set up different coloring. Such as in Cmud I would do
%1 is at %ansi(high,blue)%2. %ansi(high,green)Health: %3. %ansi(high,blue)Mana: Health: %4.
Is such a thing possible in Mudlet/Lua?
(P.s. Sorry for posting on two forums, a friend told me the other one would be checked more often!)
Another question, I was wondering if it was possible to set up different coloring. Such as in Cmud I would do
%1 is at %ansi(high,blue)%2. %ansi(high,green)Health: %3. %ansi(high,blue)Mana: Health: %4.
Is such a thing possible in Mudlet/Lua?
(P.s. Sorry for posting on two forums, a friend told me the other one would be checked more often!)
Re: Substitutions!
You could:
replace("")
cecho("<blue>blue <green>green")
and such.
replace("")
cecho("<blue>blue <green>green")
and such.
Re: Substitutions!
Sure. cecho() allows you to echo something with color tags.
E.g.:
selectString(line,1)
replace("")
cecho("<blue>This is my new <red:blue>replaced <yellow>line.")
<color> makes the color within your foreground color for the next words, <:color> sets the background color. The colors allowed are the ones in Mudlet's color_table. Execute the Mudlet function showColors() to see them all displayed.
In your example, you could do it like:
cecho(matches[2].." is at <DeepSkyBlue>"..matches[3]..". <green>Health: "..matches[4]..". <blue>Mana: "..matches[5]..".")
Or a bit more elegantly (and I believe more efficiently):
cecho(string.format("%s is at %s%s. %sHealth: %s. %sMana: %s.", matches[2], "<magenta>", matches[3], "<green>", matches[3], "<blue>", matches[5]))
P.S. Oops sorry. Posted before I saw Vadi's reply.
E.g.:
selectString(line,1)
replace("")
cecho("<blue>This is my new <red:blue>replaced <yellow>line.")
<color> makes the color within your foreground color for the next words, <:color> sets the background color. The colors allowed are the ones in Mudlet's color_table. Execute the Mudlet function showColors() to see them all displayed.
In your example, you could do it like:
cecho(matches[2].." is at <DeepSkyBlue>"..matches[3]..". <green>Health: "..matches[4]..". <blue>Mana: "..matches[5]..".")
Or a bit more elegantly (and I believe more efficiently):
cecho(string.format("%s is at %s%s. %sHealth: %s. %sMana: %s.", matches[2], "<magenta>", matches[3], "<green>", matches[3], "<blue>", matches[5]))
P.S. Oops sorry. Posted before I saw Vadi's reply.
Re: Substitutions!
Hey! It worked -well- for a while! Suddenly, today, it was only gagging, with no output.
This is the error I was getting:
object:<Presences Trigger> function:<Trigger42> <edittedmyinfo>/mudlet/LuaGlobal.lua:1127: attempt to call field 'Process' (a nil value.
Trigger:
^Your guardian angel senses (\w+) at (.+), on a health of (\d+) and a mana of (\d+)\.$ (perl regex)
Script:
resetFormat()
selectString(line,1)
replace("")
cecho(matches[2].." is at <yellow>"..matches[3]..". <green>Health: "..matches[4]..". <blue>Mana: "..matches[5]..".")
This is the error I was getting:
object:<Presences Trigger> function:<Trigger42> <edittedmyinfo>/mudlet/LuaGlobal.lua:1127: attempt to call field 'Process' (a nil value.
Trigger:
^Your guardian angel senses (\w+) at (.+), on a health of (\d+) and a mana of (\d+)\.$ (perl regex)
Script:
resetFormat()
selectString(line,1)
replace("")
cecho(matches[2].." is at <yellow>"..matches[3]..". <green>Health: "..matches[4]..". <blue>Mana: "..matches[5]..".")
Re: Substitutions!
I had a question about something like this! I read the manual, but couldn't find anything on it. I want a trigger that does this: lets say that I am going south, and I come to a door, and when I try to go south again it says "the door seems to be closed" then the trigger would send open door. This would be easy, except that I would have to create a trigger for every door in the mud, so how would I go about doing this so that it would work with more doors? (so basically:
The room of death
my command: east
the hiddenhatch seems to be closed <-- trigger grabs name hiddenhatch opens it, mvs me east, and closes it
The room of death
my command: east
the hiddenhatch seems to be closed <-- trigger grabs name hiddenhatch opens it, mvs me east, and closes it
Re: Substitutions!
cecho relies on the Echoes table which contains data and a helper function, have you overwritten it?Gippal wrote:Hey! It worked -well- for a while! Suddenly, today, it was only gagging, with no output.
This is the error I was getting:
object:<Presences Trigger> function:<Trigger42> <edittedmyinfo>/mudlet/LuaGlobal.lua:1127: attempt to call field 'Process' (a nil value.
Trigger:
^Your guardian angel senses (\w+) at (.+), on a health of (\d+) and a mana of (\d+)\.$ (perl regex)
Script:
resetFormat()
selectString(line,1)
replace("")
cecho(matches[2].." is at <yellow>"..matches[3]..". <green>Health: "..matches[4]..". <blue>Mana: "..matches[5]..".")
Re: Substitutions!
Just looked, and nope! :/
Only tables I have are named general and antitheft.
Only tables I have are named general and antitheft.
Re: Substitutions!
Can you upload your profile? That error really would seem to indicate that the Echoes table has been altered.