Starting a Mudlet System - Take 2

User avatar
Rakon
Posts: 350
Joined: Tue Feb 16, 2010 7:41 pm
Contact:

Starting a Mudlet System - Take 2

Post by Rakon »

So, a few months ago I got started on converting my MUSH system to Mudlet. I did not have a lot of my python code translated to lua, but had a basic system in place. However, after much frustrations and a harddrive crash, I lost everything I had worked on with Mudlet, and reverted to my saved MUSH info.

I am once again, going to be attempting this conversion process. I'd like to use this thread for the many questions I'll likely have, regarding help converting from MUSH to Mudlet, and most importantly, translating what I have done in python, to lua. My scripts that I have written in python are complex at times, and I truly cannot find simple ways to complete the same task in lua; although I am hoping to. I want to use Mudlet, but in creating this new system, I want things to be done right, efficient and in the 'mudlet way' to be speedy and powerful. The only resources I currently have for learning lua are:

Lua Pil
Lua Wiki
And of course the Mudlet docs.

Are there more, or more indepth lua documentation/examples out there? What are some of your well used and helpful resources?

My first question is regarding the initial conversion, in terms of MUSH triggers to Mudlet. I have a ton of triggers, and about 90% of them are regex. This is because I capture things within the trigger line, or in a line where a word, or phrase isn't static, that obviously can't be matched/captured with just a simple 'exact match' trigger.

I understand that in Mudlet (and in MUSH) RegEx matching is horribly slow compared to properly crafted Exact match/Begin of Line Substring triggers. What would be the best practice in Mudlet, to create triggers to be the quickest they can, an precise, without making every single one a RegEx? What's the proper Mudlet way to utilize the trigger matching and gates?? I'd rather not post a list of 1800 triggers and say 'how do I do this in mudlet', so I'm more asking for the concept rather than an exact line by line script.

Is it truly faster to have a 'begin of line' trigger gate, enable a regex trigger on said line, and process that way for every RegEx, than to have a one-line (no gate) Regex??

I look forward to the responses, thank you.

User avatar
Rakon
Posts: 350
Joined: Tue Feb 16, 2010 7:41 pm
Contact:

Re: Starting a Mudlet System - Take 2

Post by Rakon »

First major question.

I know there are 'miniwindows' and then 'dockable windows' in Mudlet. Majority of the scripts for things such as the chat window, aren't really windows; they're overlays still inside the MAIN Mudlet window.

How can I resize, move and undock the floating windows (not miniconsoles) through scripting?? The Manual states this:
You may want to use dock windows to display information you gathered in your scripts, or you may want to use them as chat windows etc. Adding a user defined window:

openUserWindow( string window_name )

setWindowSize( int x, int y )
The 'openUserwindow()' does open a new window, but it's typically docked along the right side, full length of the main screen. How can I use scripting to make that window undocked, placed and sized say, 150x60 everytime it is created without manually having to do so??

setWindowSize function returns as 'nil' - not defined.

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

Re: Starting a Mudlet System - Take 2

Post by Vadi »

Yeah, it really is faster to shield your regexes either via gates or multilines. I did some basic testing here.

The floating windows are from the old times, we settled on miniWindows instead now since they integrate into the overall look much better. userWindows weren't developed too far - no functions to get the overall desktop size, move them, minimize and etc...

User avatar
Rakon
Posts: 350
Joined: Tue Feb 16, 2010 7:41 pm
Contact:

Re: Starting a Mudlet System - Take 2

Post by Rakon »

Alright, thanks. So I'll have to stick to using miniConsoles within the main Mudlet window?

The link to your drop.io video testing shielded/un-shielded is not there. (Neither is drop.io! HA)

Regarding your post in that linked thread though; making an and trigger, is essentially a 'multi-line' trigger, but instead of matching on multiple lines, the trigger only fires if matches on the first given line, then proceeds to check the rest of the criteria on that same matched line??
IE Example of shielded regex and trigger would be :

match 0 (begin of line substring) - A nearly invisible shield forms around
match 1 (RegEx) - ^A nearly invisible shield forms around (\w+)\.$

With multi-line/And trigger checked?

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

Re: Starting a Mudlet System - Take 2

Post by Vadi »

Right, and line delta 0.

User avatar
Rakon
Posts: 350
Joined: Tue Feb 16, 2010 7:41 pm
Contact:

Re: Starting a Mudlet System - Take 2

Post by Rakon »

Alright, so for a trigger that I want a wildcard in, but only fires if the wildcard matches what I specify... how would I do that??

Example:

Incoming line:
Khalaz raises his sword over his head and begins to swing it in a wide circle, gaining speed as he goes.

I have the trigger set as follows:
0: ^(\w+) raises (his|her) sword over (his|her) head and begins to swing it in a wide circle\, gaining speed as (he|she) goes\.$ (Regex type)
1: if multimatches[1][2] == target then return true end (lua function type)

I'd like to check for that wildcard (matches[2]) in the matching of the trigger, and when they both are true, then the script in the trigger script editor would run. Is this possible, or is there another ... more tedious way I'd have to check for variable against variable, before execution of scripts? Ideally, I'd love to be able to write a trigger that contains a lua variable wildcard IN the matching process....

^(<lua_variable:target>) raises (his|her) sword over (his|her) head and begins to swing it in a wide circle\, gaining speed as (he|she) goes\.$

And that would expand the lua_variable specified, to the trigger match text. Again, failing the above, how else can I do this?? It needs to be scalable, as I'd have a lot of triggers to check for target name on and running scripts. I'd rather not have to run a line in EVERY trigger that equals 'if matches[2] ~= target then' ....

Thanks.

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

Re: Starting a Mudlet System - Take 2

Post by Vadi »

Neither would work.

We don't allow embedding of Lua variables in any patterns - that's be hellishly slow to retrieve them each time. multimatches[] is also filled in only when the whole trigger *matched*, so time isn't wasted on filling it with triggers that potentially won't match at all in the end.

So you'd need to do the if multimatches[1][2] ~= target then return end thing right at the start of the triggers script, that'd work then.

User avatar
Rakon
Posts: 350
Joined: Tue Feb 16, 2010 7:41 pm
Contact:

Re: Starting a Mudlet System - Take 2

Post by Rakon »

I suppose so then...

I tried making it a function to return off of instead, but that didn't seem to work either.

Code: Select all

0: ^(\w+) raises (his|her) sword over (his|her) head and begins to swing it in a wide circle\, gaining speed as (he|she) goes\.$ (Regex type)
1: isTarget() (lua function type)
Code: [show] | [select all] lua
function isTarget()
 local wl = split(line," ")
 if table.contains(wl,target:title()) then
  return true
 else
  return false
 end
end

Yes, multiline trigger is checked, and set to 0 (And trigger?) and the code is not efficient, but I just needed to know if that process would work. It doesn't, though. Is there something I'm missing in this processes too?

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

Re: Starting a Mudlet System - Take 2

Post by Vadi »

That sounds like it should work, hm... oh, try:

return isTarget()

User avatar
Rakon
Posts: 350
Joined: Tue Feb 16, 2010 7:41 pm
Contact:

Re: Starting a Mudlet System - Take 2

Post by Rakon »

Ahh, there we go, adding return into the lua function match, made it work as intended.

Now that I know that process works, anyway to pass JUST the matches/groups of the line/regex to a function without running the trigger script first, instead of parsing/spliting the entire line it matched on, as the example shows??

Post Reply