Its good practice to always escape the period, if you only want a period. Not really relevant in the case of your trigger (since that line only ever ends in one), but in other cases where the final punctuation mark is variable, it can be pretty relevant.
Its good practice to always escape the period, if you only want a period. Not really relevant in the case of your trigger (since that line only ever ends in one), but in other cases where the final punctuation mark is variable, it can be pretty relevant.
I try to remove as many wild cards and open ended matches as I can in my regex. Not sure the end improvement on performance but I tend to think that's good practice.
That being said, if you don't enjoy coding, do whatever makes it work for you and move on.
There is also a native Mudlet function that @Dicene stumbled across that deletes the current line and any prompt following it. The name escapes me so maybe he can chime in.
First pattern is the line (so exact match, perl, whatever)
Second line is a lua function with the pattern as:
return isPrompt()
Click the multiline/AND box, change the delta to 3
Edit: The delta can be 1. Mistake saved for posterity.
In the script, do
deleteLine()
moveCursor(0,getLineNumber()-1)
deleteLine()
Just as a note on moveCursor() -- it's noted here that moveCursor moves relative to your Mudlet screen and therefore if you have Mudlet wrapping your text (which most of us probably do), it will not actually delete the full line if the line is wrapped.
How would you go about having a stance tracker to be visibly seen in your prompt? I have the trigger line thanks to @Ultrix and I can send an echo, but configuring it I am at a loss.
Slightly more advanced script for a nicer look(also won't generate errors before you've seen a stance change:
local str = " <white>["
predStance = predStance or "none"
if predStance=="Gyanis" then
str = str .. "<goldenrod>Gya"
elseif predStance=="Vae-sant" then
str = str .. "<deep_sky_blue>Vae"
elseif predStance=="Rizet" then
str = str .. "<deep_pink>Riz"
elseif predStance=="Ein-fasit" then
str = str .. "<SaddleBrown>Ein"
elseif predStance=="Laesan" then
str = str .. "<CadetBlue>Lae"
else
str = str .. " "
end
str = str .. "<white>]"
cecho(str)
Here's an example of what the more advanced form of the second trigger looks like:
Disclaimer: I don't have a Pred anymore, so I don't know if Vae-sant and Ein-fasit are listed with a lowercase or uppercase first letter to the second part of their hyphenated name. If the first letter there is uppercase, you'd have to fix that in my script to get it to work properly. Also, there's a good chance I've got the trigger for the stance change wrong, so update with whatever Ultrix gave you.
Stumbled unto this and figured it might be of use to someone, especially while Mudlet still doesn't support 256 colors in color triggers, just ansi.
If you use very specific value and check lines with something like selectString(line) getFgColor(), you should be able to match these and capture to something like Demonnic's chat window with ease.
Not finished, and you can't just plug n play the script and have it work. These are all the functions my tracker uses. This was one of my first projects when starting back and learning Mudlet, so ignore stuff like me using table.getn(table) instead of #table
Hopefully, it'll at least be an example of what to (not) do
Next thing to work on towards understanding combat and PK is more tracker stuff in particular the aliases.
So I have trigger msgs for things like rebounding and shield and parryinng, and I'm guessing those msgs are the 'trackers'. Now, I need to harness that trigger msg into an alias and execute multiple commands based off the tracker msg.
For example if rebound = 1 based off the msg and shield = 1 based off its own msg as well then how do I go about setting up attacks for that circumstance or really any variety of circumstances? Such as rebound = 1 shield = 0, vice versa, rebound = 0 shield = 0, etc. This stuff confuses me and thus I seek help and better understanding on how these things work.
"// #If (@rebounding = 1 & @shield = 1) {#if (@pstance = einfasit) {combo raze raze lowhook @target};#if (@pstance = laesan) {combo raze raze lateral @target}}.” <-- how do you translate that into mudlet?
How would I continue that code for the next set of circumstances be it rebound = 0 and shield = 0, rebound = 0 and shield = 0? Use 'elseif' then have commands under those variables?
I'd advise using true and false instead of 1 and 0.
If rebounding is going up, use:
rebounding = true
If rebounding is going down, use:
rebounding = false
Then in your IF statements, you replace "rebounding == 1" with "rebounding" and replace "rebounding == 0" with "not rebounding".
Obviously not required, but I find that kind of code more readable in the end, and it's probably best practice to use booleans instead of integers whenever possible. =P
Then, to fill out the rest of that conditional tree:
if rebounding and shield then --matches when they have BOTH rebounding and shield
if pstance=="einfasit" then
send(blah)
elseif pstance=="laesan" then
send(blah)
end
elseif rebounding or shield then --matches when they have either of the two(would also match both if this wasn't an elseif of that original condition)
if pstance=="einfasit" then
send(blah)
elseif pstance=="laesan" then
send(blah)
end
else --this condition will only fire if they have neither rebounding nor shield
if rebounding == true and shield == true then if pstance == "einfasit" then send("combo raze raze lowhook "..target) elseif pstance == "laesan" then send("combo raze raze lateral "..target) end elseif rebounding == false and shield == false then <more_coding> end
segments can be either 'rebounding == true' or 'rebounding', and segments can be 'rebounding == false' or 'not rebounding'.
segments show when checking if a variable matches a certain word(string), you need to use quotations(") on each side to show that is a word, not another variable being compared.
shows you how to call your variables. Two periods(..) call it, then two after escape it. If the variable is being called at the beginning or end of the section, you don't need the two periods, such as: (target.." is here"), ("I see "..target), and it would normally be: ("There is "..target.." at my location.)
Dicene pretty much told you it. I felt like colour coding it for you for fun anyways.
Comments
That being said, if you don't enjoy coding, do whatever makes it work for you and move on.
I'm glad I managed to find that before attempting to compile and add it myself.
local re, r
local lastTime = os.clock()
re = rex.new([[^(?<name>\w+) balls up one fist and hammerfists (?<target>\w+)\.$]])
print("\nExecuting re 10000 times....")
for i = 1, 10000, 1 do
r = {re:exec("Septus balls up one fist and hammerfists you.")}
end
print(os.clock() - lastTime, "\n")
display(r)
Output(on my extremely slow computer):
Executing re 10000 times....
0.065999999998894
{
1,
45,
{
1,
6,
42,
44,
name = "Septus",
target = "you"
}
}
deleteLine() deletes the line itself, but the prompt still fires. Is there any way to remove that as well?
deleteLine()
moveCursor(0,getLineNumber()-1)
deleteLine()
Edit: http://wiki.mudlet.org/w/DeleteFull
Prompt Trigger
Pattern(Lua function): return isPrompt()
local str = " <white>["
predStance = predStance or "none"
if predStance=="Gyanis" then
str = str .. "<goldenrod>Gya"
elseif predStance=="Vae-sant" then
str = str .. "<deep_sky_blue>Vae"
elseif predStance=="Rizet" then
str = str .. "<deep_pink>Riz"
elseif predStance=="Ein-fasit" then
str = str .. "<SaddleBrown>Ein"
elseif predStance=="Laesan" then
str = str .. "<CadetBlue>Lae"
else
str = str .. " "
end
str = str .. "<white>]"
cecho(str)
Here's an example of what the more advanced form of the second trigger looks like:
Disclaimer: I don't have a Pred anymore, so I don't know if Vae-sant and Ein-fasit are listed with a lowercase or uppercase first letter to the second part of their hyphenated name. If the first letter there is uppercase, you'd have to fix that in my script to get it to work properly. Also, there's a good chance I've got the trigger for the stance change wrong, so update with whatever Ultrix gave you.
http://upload.wikimedia.org/wikipedia/en/1/15/Xterm_256color_chart.svg
So I have trigger msgs for things like rebounding and shield and parryinng, and I'm guessing those msgs are the 'trackers'. Now, I need to harness that trigger msg into an alias and execute multiple commands based off the tracker msg.
For example if rebound = 1 based off the msg and shield = 1 based off its own msg as well then how do I go about setting up attacks for that circumstance or really any variety of circumstances? Such as rebound = 1 shield = 0, vice versa, rebound = 0 shield = 0, etc. This stuff confuses me and thus I seek help and better understanding on how these things work.
"// #If (@rebounding = 1 & @shield = 1) {#if (@pstance = einfasit) {combo raze raze lowhook @target};#if (@pstance = laesan) {combo raze raze lateral @target}}.” <-- how do you translate that into mudlet?
Thanks guys.
Equals to:
if rebounding == true and shield == true then
if pstance == "einfasit" then send("combo raze raze lowhook "..target)
elseif pstance == "laesan" then send("combo raze raze lateral "..target)
end
elseif rebounding == false and shield == false then
<more_coding>
end
segments can be either 'rebounding == true' or 'rebounding', and segments can be 'rebounding == false' or 'not rebounding'.
segments show when checking if a variable matches a certain word(string), you need to use quotations(") on each side to show that is a word, not another variable being compared.
shows you how to call your variables. Two periods(..) call it, then two after escape it. If the variable is being called at the beginning or end of the section, you don't need the two periods, such as: (target.." is here"), ("I see "..target), and it would normally be: ("There is "..target.." at my location.)
Dicene pretty much told you it. I felt like colour coding it for you for fun anyways.
2) AFAIK, yes. I think you can also use playSoundFile() or something like that. Not mucked around with it too much, myself.