import lua?

User avatar
Zaphob
Posts: 180
Joined: Wed May 09, 2012 8:07 am
Location: mg.mud.de

Re: import lua?

Post by Zaphob »

Oh Jor'Mox, you are right. I didn't even bother to check just yet, but would not have expected that. Looking at Mudlet code base, those are indeed completely different things:

Clicking a new folder in the GUI will invoke dlgTriggerEditor::slot_add_new_folder() which will in case of triggers invoke dlgTriggerEditor::slot_addTriggerGroup() and that then addTrigger(true). The "true" means, create a folder, "false" would create a trigger. No other parameters are supplied, instead probably taken directly from GUI. My C++ is too weak to understand it all exactly now.

On the other hand, looking at the command permGroup - first the good news, it seems to actually take an optional third parameter for parent! This has not been reflected in manual, yet, but I can see it in code. Nice!

Looking at code history, it seems to be you Jor'Mox who added that optional parent parameter? So should we update manual as well? Are there any other improvements you did but which are not yet in the manual in wiki?

However still, calling permGroup(name, "trigger") for example will be directly invoking permSubstringTrigger(name, parent, {""}, "") and not create a "real" group like the button above, after all.

I wonder if my C++ would suffice to link the functionality of those commands to what is happening when clicking the buttons in GUI, as well as including all the other missing things mentioned above. Reviewing how SecareLupus included Keys, this may be a bit above my level still.

edit: Updated the permGroup() wiki manual :mrgreen:
Last edited by Zaphob on Thu Jun 29, 2017 3:03 pm, edited 2 times in total.

User avatar
Zaphob
Posts: 180
Joined: Wed May 09, 2012 8:07 am
Location: mg.mud.de

Re: import lua?

Post by Zaphob »

Another thing I noticed, when I want to use permKey(name, parent, modifier, key code, lua code)

The value of "modifier" has to be like mudlet.key.Escape, mudlet.key.F1, mudlet.key.A, but I don't have those values available in my package.lua file I want to include.

I found KeyCodes.lua which explains all values and the corresponding integer values. Am I expected to just put the integers in my permKey() and make sure my developers know which key is what? Would be better if we could use "mudlet.key.A" instead of the non-existent mudlet.key.A, if possible, what do you think?

User avatar
SlySven
Posts: 1019
Joined: Mon Mar 04, 2013 3:40 pm
Location: Deepest Wiltshire, UK
Discord: SlySven#2703

Re: import lua?

Post by SlySven »

I think Vadim wanted those keys to get into the mudlet globally accessible table so that other packages could use them - I think it was a bit awkward because, possibly, some older scripts or packages used the absence or presence of that table itself to signal something. Unfortunately I am not sure I have the details straight myself.

User avatar
Zaphob
Posts: 180
Joined: Wed May 09, 2012 8:07 am
Location: mg.mud.de

Re: import lua?

Post by Zaphob »

Thanks SlySven. In the last few posts, I raised quite a few issues I noticed during my endeavor to import my package as lua. Feel free to comment all.

Jor'Mox
Posts: 1142
Joined: Wed Apr 03, 2013 2:19 am

Re: import lua?

Post by Jor'Mox »

I have made a few changes to various Lua functions over the years, but I have yet to make any changes to the Wiki of any kind. I'm all for updating the documentation, I just suck at it. High motivation to fix bugs, low motivation to document changes... ;)

As far as some of your other issues, I know you were talking about wanting to create a trigger with multiple patterns, to include both regex and substring patterns, and you seemed to be confounded that there was no permanent equivalent to the tempComplexRegexTrigger. However, permRegexTrigger allows you the ability to match any sort of text based pattern matching, with multiple patterns. All you have to do is create a table of the patterns you want it to match, and pass that as the third argument. While each pattern type would technically be a regex pattern, making them match in the same way as substring would be extremely easy (and the default behavior so long as certain characters weren't involved).

So, as an example, you could do this:
Code: [show] | [select all] lua
local patterns = {[[^this is regex (.*)$]],[[this is a substring]],[[^this is a beginning of line substring]]}
permRegexTrigger("my trigger", "my trigger parent", patterns, [[print("here is some code to do")]])
Unfortunately, there is no way to turn on the various trigger options with any of the permTrigger functions, so to make a proper multiline trigger, or an AND trigger, you would need to use tempComplexRegexTrigger. Given that the capability exists, I don't understand why there aren't functions to allow for that level of manipulation via code, though with my own experience of deploying significant amounts of code to be used by non-coders, I find that using tempTriggers and the like is actually a boon, as it keeps people who don't know what they are doing from breaking things, and then complaining about how they don't work any more.

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

Re: import lua?

Post by Vadi »

Zaphob wrote:Another thing I noticed, when I want to use permKey(name, parent, modifier, key code, lua code)

The value of "modifier" has to be like mudlet.key.Escape, mudlet.key.F1, mudlet.key.A, but I don't have those values available in my package.lua file I want to include.

I found KeyCodes.lua which explains all values and the corresponding integer values. Am I expected to just put the integers in my permKey() and make sure my developers know which key is what? Would be better if we could use "mudlet.key.A" instead of the non-existent mudlet.key.A, if possible, what do you think?
You are not expected to use intergers - mudlet.key.Escape and so on should be just be there, but I think mudlet-lua didn't get updated to include KeyCodes as expected in the last 3.2 release. This'll be fixed with the upcoming 3.3 update.

User avatar
Zaphob
Posts: 180
Joined: Wed May 09, 2012 8:07 am
Location: mg.mud.de

Re: import lua?

Post by Zaphob »

Jor'Mox wrote:permGroup is actually even less appealing than it seems, in that it doesn't actually create folders the way you would in the GUI. Rather, it creates blank triggers/aliases, et cetera, which it uses as groups. You can do the same thing with the relevant functions, and just give them blank pattern and code arguments. Which conveniently allows for the creation of nested "groups", but shares the downfall of the "groups" shows as regular things with errors, since you aren't supposed to have an alias or a trigger without a pattern.
Seems like permGroup does not yet allow the creation of groups for "key" objects which can be added with permKey() - so I might have to really go that road, create a "parent" key with no content (instead of a group), then below that the "real" keys.

Jor'Mox wrote:I know you were talking about wanting to create a trigger with multiple patterns, to include both regex and substring patterns, and you seemed to be confounded that there was no permanent equivalent to the tempComplexRegexTrigger. However, permRegexTrigger allows you the ability to match any sort of text based pattern matching, with multiple patterns.
That is awesome! I have update wiki manual to reflect this possibility more clearly. :mrgreen:

Post Reply