Run Lua code from the command line

User avatar
Akaya
Posts: 414
Joined: Thu Apr 19, 2012 1:36 am

Re: Run Lua code from the command line

Post by Akaya »

How can I alter this to echo to a miniconsole or label instead of the main window?

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

Re: Run Lua code from the command line

Post by Vadi »

Adjust the display(r) part to an echo - although echoes don't handle tables.

There is a function that'll turn a table into a string you can use, but I can't check that this moment.

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

Re: Run Lua code from the command line

Post by Zaphob »

So, I love this module ever since I found it back a few years ago. And now it seems, Mudlet 3.0 comes bundled with it already!

My question now: How do you expect the script packages to manage? I would like to include "run lua" for all users 2.1, who don't have it already installed themselves. Of course, if they have it installed, or maybe use 3.0 already, no "run lua" needs to be added anymore.

I was thinking about adding something along these lines, but could not yet test around too much.
Code: [show] | [select all] lua
run-lua-module = run-lua-module or (put all code here somehow)
Maybe there is a preferred solution already?

Earlier, I just shipped 3.0 scripts with "run lua" included, but this made Mudlet run every lua command twice! Then I ditched "run lua" all together, but now 2.1 users can't rely on this luxury.

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

Re: Run Lua code from the command line

Post by Vadi »

It's already available in 2.1 as well, it gets added by default to new profiles people create. Someone using an existing profile on 3.0 won't have it either - this was in case someone already had it, Mudlet adding it would duplicate it.

There is getModulePriority(), which you could use to see if a module is installed... lua script gets installed as a package though and that doesn't have a corresponding function.

The solution I went with is to have another alias pattern trigger the lua script.

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

Re: Run Lua code from the command line

Post by SlySven »

There are three modules that get added in auto-magically from the Mudlet "resources" file for all new profiles by the dlgConnectionProfiles::slot_connectToServer() method:
  • deleteOldProfiles.xml
  • echo.xml
  • run-lua-code-v4.xml
Additonally, Aetolia, Achaea, Lusternia, Midkemia and Imperian profiles gain:
  • mudlet-mapper.xml
and 3Scapes and 3Kingdoms profiles get:
  • 3k-mapper.xml

Post Reply