Index of Lua functions, events, and globals?

Posted by Tesagk on Sat 02 Jul 2016 12:17 PM — 10 posts, 38,164 views.

#0
Hello! It's been awhile since I've posted here.

I remember asking something about Mudlet LUA and I got this awesome link to a page describing the function. However, and I know this is user-error, not a fault with site navigation, I'm having trouble finding an index I can bookmark which displays all of the functions, globals, and events.

One of the things that has held me back from using MUSHclient more is that I don't know how to work within its own LUA code.

I use Mudlet for my main game, a MUD.

My own LUA skills are... "eh", but, fortunately, I have a lot of good help from another player of the MUD who has spent a lot of time making scripts for the game that everyone can use. Similarly, I have invested a much smaller amount, but enough that I can do most things if I bang my head against the wall enough.

I have no such support for MUSHclient, and, as mentioned, am having a difficult time finding a page like this: ( http://wiki.mudlet.org/w/Manual:Lua_Functions ).

One of the things I'll probably have the most difficulty with, but really need to find resources for if I'm going to set MUSHclient up the way I like it, is interacting with the GUI: making buttons (and tabs), windows, etc... but, in general, I really don't know what functions do a lot of even the most basic things.
Australia Forum Administrator #1
I've put a lot of work into documenting and cross-referencing the various scripting functions. A good starting point is the main documentation page:

http://www.gammon.com.au/scripts/doc.php

That groups functions into the various sections (eg. relating to triggers, aliases, etc.)

Then there is an alphabetic function list:

http://www.gammon.com.au/scripts/doc.php?general=function_list

These same pages are available inside the client using the Help menu as they are generated from the same database.

In particular, if you press Ctrl+Alt+Shift+L you see a dialog box that lets you filter down to particular function names (or wildcard, eg. "trigger").

World functions


For historical reasons, the functions basically fall into two categories:

  • "World" functions, which are in the "world" table (note all lower-case). These are available to all supported scripting languages (eg. Lua, VBscript, Jscript, Python)
  • Lua-only functions. In particular the "normal" Lua libraries like "string", "table", "math" are all there, and work the same as described in the Lua Reference Manual. They are also documented by me, eg. http://www.gammon.com.au/scripts/doc.php?general=lua_string

    In addition to the standard Lua libraries, some extra functionality is provided by a few extra Lua libraries, such as the lpeg, bc, rex (PCRE regular expression), utils, luacom, and sqlite3 libraries.


Almost all of these are also documented in the built-in help (I can't find luacom in the help, but see http://www.gammon.com.au/forum/?id=6022 for more details about that).

Window manipulation



Quote:

I ... really need to find resources for if I'm going to set MUSHclient up the way I like it, is interacting with the GUI: making buttons (and tabs), windows ...


Initially the client only had limited support for buttons, etc. because it was a text client. A while back "miniwindows" were introduced which gave extra support for areas of the client window that could be used for status bars, inventory, mapper, etc.

For a lengthy tutorial and reference, see: http://www.gammon.com.au/mw

There are quite a few examples of miniwindows in use in the Miniwindows part of this forum.


Callbacks


Another part of the documentation worth exploring is the callbacks section, in particular plugin callbacks:

http://www.gammon.com.au/scripts/doc.php?general=plugin_callbacks

By supplying certain functions inside a plugin you can have the client "call back" to let you know something has happened, for example, you are about to send something to the server, you have just connected, the mouse has moved, etc.
Amended on Sat 02 Jul 2016 08:56 PM by Nick Gammon
#2
Thanks for the reply. The links will be helpful and your response has been so thorough! :)
#3
The documentation is incredibly thorough. However, right now, as I'm going through it, I'm having difficulty finding how to reference a pattern match (right now, specifically in an alias, but I should know about how to do triggers as well).

In my alias, I had an if statement as follows: if %1 == "all", however, I get an unrecognized symbol error.


<aliases>
  <alias
   match="^dt(?:/(all))?"
   enabled="y"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>if %1 == "all" then
  Send("cast 'detect invis'")
  Send("cast 'detect hidden'")
  Send("cast 'detect evil'")
  Send("cast 'detect good'")
else
  Send("cast 'detect invis'")
  Send("cast 'detect hidden'")
end</send>
  </alias>
</aliases>
USA Global Moderator #4
Quote:
if %1 == "all"

That needs to at least be
if "%1" == "all"


This is a dirty, dark, not well understood or explained corner of MUSHclient scripts and plugins. %1,%2,etc replacements are done by the XML parser long before the code ever gets to the Lua script engine, and that has a few significant effects like requiring quotation marks around things that are meant to be strings and special care for symbols like < and > if not wrapped by CDATA tags.
Amended on Mon 08 Aug 2016 02:43 PM by Fiendish
#5
I'll have to do my best to learn these rules then. Thank you.
Australia Forum Administrator #6
Fiendish said:

This is a dirty, dark, not well understood or explained corner of MUSHclient scripts and plugins.


Apart from FAQ 32.

Template:faq=32
Please read the MUSHclient FAQ - point 32.
USA Global Moderator #7
Nick Gammon said:

Fiendish said:

This is a dirty, dark, not well understood or explained corner of MUSHclient scripts and plugins.


Apart from FAQ 32.

(faq=32)

I meant the reason behind why it happens that way. :)
( xml parsing -> substitution -> handoff to script engine )
#8
Nick Gammon said:

Fiendish said:

This is a dirty, dark, not well understood or explained corner of MUSHclient scripts and plugins.


Apart from FAQ 32.

(faq=32)


Which I had thought to check out the FAQ.

I did a number of mushclient google searches trying to figure out what mushclient used for its matching-capture variable.
Australia Forum Administrator #9
Fiendish said:

( xml parsing -> substitution -> handoff to script engine )


The XML parsing is done at serialization time, but I take your point.

Certainly there are lots of things I would improve if I ever wrote a new client.




Going back into the dim past, the substitution was done before scripting was even implemented. And initially scripting was only done in a script file (with the function name in the trigger). More recently there was "send to script" and the possibility of this sort of confusion. Plus the annoyance of having to double the number of backslashes, and double the number of "%" symbols if you don't want them to be a wildcard expansion.