For my deeply narcissistic self. -(anti-weapon field). I dsl'd a decadent goblin priest. (a curved sabre) -133 ( 0.70) I dsl'd a decadent goblin priest. (a curved sabre) -3 ( 0.00) I slew a decadent goblin priest.
Not really a question, but a TIL: If you use an echo to test your MiniConsole wrap length, don't use one big word, or you'll wonder why it's broken for a week or three.
I'm trying to track shadowplants on multiple targets, because because.
2nd match is the herb, 3rd match is the name. herb is set and accounted for. Need the name in the timer ID so I can hearken back to it when I need to kill the deactivate timer, so I tried to do what I found at http://www.lua.org/pil/14.1.html to utter failure. Dunno why I bothered to try doing the fancy code for the activate timer, but I did.
I'm getting "lua syntax error: 1" and "lua syntax error: 4". I threw in cecho(timer1) after the first pair of variable sets, and it's reporting the variable as nil.
Edit: Okay, so the assignment thing does not do at all what I thought it did. I'll debug some more to see if I can go from there, but I have the timers at least trying to go.
Edit 2 - Got it working. My [[]] craziness didn't work either, so the function thing is much cleaner. Will have to remember that for some future stuff.
Final version -
timer1 = matches[3].."-shadowplant-activate"
timer2 = matches[3].."-shadowplant-deactivate"
timer1 = tempTimer(1, function () trackerAdd(name, "shadowplant-" .. herb) end)
timer2 = tempTimer(4, function () trackerRemove(name, "shadowplant-"..herb.."") end)
Be careful how you select though. If I accidentally select in the timestamp instead of over the actual text, or in a different miniconsole and move into the primary one, Mudlet tends to crash on me. Also, it adds newlines when you copy/paste multiple lines, which just show up as spaces when you paste. I also tend to have better results using right click+copy instead of control+c, which likes to grab my command line instead of what I've got selected. And I think right click+copy is the only way to reliably copy from other consoles, like from chat window.
A reliable copy through selecting the left margin is about the only thing I miss about Cmud.
For some of the reasons @Dicene mentioned is why I put most of my major lua scripts in external files. Then load them as part of my init by doing
dofile(getMudletHomeDir().."/scripts/MyScript.lua") where getMudletHomeDir() is (at least on a mac) ~/.config/mudlet/profiles/<your profile>/
That way I can check all my major scripts into version control and use whatever editor I want to do the actual coding. Because lets be honest; mudlet is a good client but fails as an editor.
And I think right click+copy is the only way to reliably copy from other consoles, like from chat window.
That's what I meant. Copypasting the wrong sections of my chat capture is aggravating. I thought maybe there'd be some way to make ctrl+c a key that copies whatever's highlighted.
I'm trying to track shadowplants on multiple targets, because because.
2nd match is the herb, 3rd match is the name. herb is set and accounted for. Need the name in the timer ID so I can hearken back to it when I need to kill the deactivate timer, so I tried to do what I found at http://www.lua.org/pil/14.1.html to utter failure. Dunno why I bothered to try doing the fancy code for the activate timer, but I did.
Does the io stuff need the file to already exist? If so, do you just have to manually install the file or is there some way to make sure it goes along with the script?
You can get Lua to create the file by doing something called assert. I believe when you assert a writable or appendable file, it creates a new one, but I have yet to sort out how to make it fail grace-fully. @Dicene?
First thing: Anyone made use of the db functions at all? I'm rather unfamiliar with sql, but my players table is sitting at 2300 entries right now and even though reading from the table is quick, writing to the table from a Truehonours has become really slow. If using DB instead of a standard table would be more efficient, I'd definitely be willing to learn.
Second thing: Has anyone added a regex library to the Lua included in Mudlet? I really want access to regex in scripts, but I don't particularly look forward to trying to compile a lua regex library and integrate it properly, since I usually find a way to mess those things up.
I use the mudlet db functions in a few places, and they seem fine. They give you control over most things you will want (sorting, WHERE type filtering, etc). You don't really need to know sql to use them unless you want to get into some complicated queries.
I don't currently don't have any tables that size so I can't speak to the functions performance from experience, but I would imagine it depends on where your performance hit is happening. Is it the parsing of the truehonours? The lookups? The actual writes? If it is the parsing then using a database probably won't help much. If it is the lookups and writes using a database could give a performance boost depending on your implementation (if you have to do a bunch of complicated queries for each item before you write it there might not be much of a gain). Sorry none of that really helps much but like most topics involving performance it depends a lot on your use case.
I haven't tried to add a regex library to lua, but doesn't it already have one? I was pretty sure string.match would accept regex.
As an aside, I was under the impression mudlet just included a standard lua interpreter with some custom functions[1]. At one point I even pulled down the source code, extracted the functions and added them to my local lua path so I could do some scripting and debugging outside of mudlet.
As far as the thonours issue, I checked os.clock() repeatedly between each line of code. The issue was with me saving the file to the harddrive every time I updated the players table. Removed it and check take an average of 0.003s after ping instead of upwards of a second(2300kb file on a really terrible computer).
Disk writes are always expensive (unless you have a SSD). With that in mind I would imagine using a db would give you a nice boost to performance. There are some functions available too that would allow you to unpack your table right into your new sheets (the mudlet documentation calls them sheets, really they are tables but they didn't want lua tables and sql tables getting mixed up) after a small conversion.
Can someone once and for all help me understand why sometimes, you escape the period at the end of a sentence with \ but other times, especially if you have a capture right at the beginning of the trigger, using \ before the period at the end of the sentence will prevent the trigger from firing. I just don't understand how/why this is at all. I understand that the escape makes the client interpret the . literally, and without an escape, the . just matches any single character (thanks to some careful, patient explanations), but I just absolutely don't understand why sometimes this is THE way to format the end of a regex trigger, and other times, it can keep that same trigger from firing at all.
Can someone once and for all help me understand why sometimes, you escape the period at the end of a sentence with \ but other times, especially if you have a capture right at the beginning of the trigger, using \ before the period at the end of the sentence will prevent the trigger from firing. I just don't understand how/why this is at all. I understand that the escape makes the client interpret the . literally, and without an escape, the . just matches any single character (thanks to some careful, patient explanations), but I just absolutely don't understand why sometimes this is THE way to format the end of a regex trigger, and other times, it can keep that same trigger from firing at all.
I pretty much always escape it, otherwise it acts as a wildcard.
That makes perfect sense... So, this is what I'd like to finally understand.
This trigger works: ^(\w+)\'s aura of weapons rebounding disappears.$
This one does not: ^(\w+)\'s aura of weapons rebounding disappears\.$
I really feel I've seen this before, and my guess/intuition is that it has something to do with capturing stuff right after the newline thing. It's the kind of thing that drives someone not immersed in coding (me) absolutely nuts.
Comments
function queueSet(action,type)
--Sets the action as the "active" in the queue type. Type is bal, eqbal, or eq.
sys.queue[type].command = action
cecho("Debug:"..sys.queue.eqbal.command)
end
and the debug changed to
Alias name=run lua code(^lua (.*)$) matched.
Alias: capture group #1 = <lua queueSet(test,eqbal)>
Alias: capture group #2 = <queueSet(test,eqbal)>
LUA: ERROR running script run lua code (Alias6) ERROR:[string "--Queue..."]:73: attempt to index
field '?' (a nil value)n
function queueSet(action,type)
--Sets the action as the "active" in the queue type. Type is bal, eqbal, or eq.
cecho("T1")
cecho("Type:"..type)
cecho("Action:"..action)
end
and Mudlet thinks that type doesn't exist
LUA: ERROR running script run lua code (Alias6) ERROR:[string "--Queue..."]:73: attempt to
concatenate local 'type' (a nil value)
Should be something like:
lua queueSet("test","equal")
-(anti-weapon field).
I dsl'd a decadent goblin priest. (a curved sabre) -133 ( 0.70)
I dsl'd a decadent goblin priest. (a curved sabre) -3 ( 0.00)
I slew a decadent goblin priest.
timer1 = _G[matches[3].."-shadowplant-activate"]
timer2 = _G[matches[3].."-shadowplant-deactivate"]
timer1 = tempTimer(1,[[trackerAdd(]]..matches[3]..[[,"shadowplant-"]]..herb..[[)]])
timer2 = tempTimer(4,[[trackerRemove(]]..matches[3]..[[,"shadowplant-"]]..herb..[[)]])
Help me to unfrak this, please?
Edit: Already fixed the wrong match in the temp timers >.> Had it fixed in the main copy, but missed the switch here.
timer1 = matches[3].."-shadowplant-activate"
timer2 = matches[3].."-shadowplant-deactivate"
timer1 = tempTimer(1, function () trackerAdd(name, "shadowplant-" .. herb) end)
timer2 = tempTimer(4, function () trackerRemove(name, "shadowplant-"..herb.."") end)
dofile(getMudletHomeDir().."/scripts/MyScript.lua") where getMudletHomeDir() is (at least on a mac) ~/.config/mudlet/profiles/<your profile>/
That way I can check all my major scripts into version control and use whatever editor I want to do the actual coding. Because lets be honest; mudlet is a good client but fails as an editor.
I pretty much always escape it, otherwise it acts as a wildcard.
This one does not: ^(\w+)\'s aura of weapons rebounding disappears\.$