VS Code + Mudlet scripts development

Post Reply
Delwing
Posts: 8
Joined: Thu Oct 29, 2020 12:08 pm

VS Code + Mudlet scripts development

Post by Delwing »

Hey,

I've been trying to improve my developer experience while coding scripts for Mudlet. Since my scripts are extracted to .lua files and I keep my .xml content as minimal as possible I can leverage IDE power to do so. I was using (as for my daily work) Intellij Idea, although LUA support there feels a bit messy, regardless of plugin you chose. Recently I've been doing a lot work with own DSL created in Xtext and Eclipse Theia as IDE. Theia is web IDE based on Monaco Editor, hugely inspired (base) by VS Code (to that extent that VS code extensions can be used in Theia). While developing language server extension I gave VS Code a test ride. Although in terms of Java development it's not as powerful as Intellij, I tried LUA there. Right on spot. With LUA language server extension works far better, better go to definition etc. So I started do write language server for mudlet... which proved a bit problematic cranky, but not impossible to have two language servers give proposals. I've added few Mudlet api functions definitions and was going to import rest of them. Then I thought... well this is futile... I've just copied .lua files used for doc generation (github . com/Mudlet/Mudlet/tree/development/src/mudlet-lua/lua) to my project without including them in loader.
vs1.png
vs1.png (38.15 KiB) Viewed 27130 times
vs2.png
vs2.png (11.94 KiB) Viewed 27130 times
If there is more interest in the topic I can try to actually set up some package + description for development using .lua files.
I have converter to automate process of XML extraction to .lua files, so if anyone is interested I can try to make it more generic.

---
UPDATE:

I wrote VS Code extension for easier setup:
https://marketplace.visualstudio.com/it ... cripts-sdk
Last edited by Delwing on Thu Sep 09, 2021 10:19 am, edited 1 time in total.

User avatar
demonnic
Posts: 884
Joined: Sat Dec 05, 2009 3:19 pm

Re: VS Code + Mudlet scripts development

Post by demonnic »

I'm definitely interested in the extraction from xml portion. I've got muddlet creating the xml fine but never found the time to do the reverse particularly well.

Though I'd want to go as far as pulling triggers/aliases/etc into the json format eventually. I just have too many irons in too many fires.

Delwing
Posts: 8
Joined: Thu Oct 29, 2020 12:08 pm

Re: VS Code + Mudlet scripts development

Post by Delwing »

Little update on the matter, after some Discord discussion.

I've mentioned before VS Code Lua extension.

You can set Mudlet instalation dir (or in matter of fact any other dir with .lua files inside) as lib directory.

While Mudlet running get path:

```lua lfs.currentdir()```
And set this path in setting `Lua.workspace.library`
Capture.png
Capture.png (3.85 KiB) Viewed 27125 times
Not sure about Mac and Linux right now. You can always download .lua files that I've mentioned before and point to another directory that they will reside in.

I will try to automate docs retrieval from Wiki, since those files might be outdated. But oh, well, so far better than nothing ;)



Demonic, I will try to generify my app to extract .xml
Be aware that it extracts only scripts, aliases and triggers. Didn't have need to add keybindings and timers.

Delwing
Posts: 8
Joined: Thu Oct 29, 2020 12:08 pm

Re: VS Code + Mudlet scripts development

Post by Delwing »

Just head to https://github.com/Delwing/mudlet-docs
I've prepared package of` .lua` files with some basic instruction for VS Code.

Package is extracted directly from predefined pages in Mudlet Wiki. Geyser is not covered atm.

gesslar
Posts: 5
Joined: Mon Jul 29, 2019 9:18 pm

Re: VS Code + Mudlet scripts development

Post by gesslar »

Can I ask how you go about setting this up?

I'm a little nubby about this. So, I'm guessing that maybe you have a single script in your package, top-level, that loads scripts that you need from there? I'm then guessing that if I do that, then I have to register my events manually from my external scripts? Like gmcp.Char stuff?

Delwing
Posts: 8
Joined: Thu Oct 29, 2020 12:08 pm

Re: VS Code + Mudlet scripts development

Post by Delwing »

gesslar - I will try to provide template project.
Basically all code lies in .lua files in project.
The only things I have in XML file are one-liners - calls to functions that are provided in .lua files.

Delwing
Posts: 8
Joined: Thu Oct 29, 2020 12:08 pm

Re: VS Code + Mudlet scripts development

Post by Delwing »

For easier setup, I've wrote VS Code extension that fetches docs:
https://marketplace.visualstudio.com/it ... cripts-sdk

Post Reply