Lua Mod Development Cycle

Post Reply
modtea
New member
Posts: 3
Joined: Sat May 14, 2022 21:03
GitHub: modtea

Lua Mod Development Cycle

by modtea » Post

First post.

Please consider the following Lua Mod development cycle:
1. Type and save Lua code into a mod folder.
2. Launch Minetest Server with a world that has enabled the mod.
3. Sign into the Minetest world from a client.
4. Interact with the world in ways that involve the mod.
5. Read logs for crash data or console debugging output generated by mod.
6. Stop the Minetest Server.
7. Edit lua code.
Return to step 2 and repeat.

This 'works', but with horrendous time and tedium costs. In particular, reloading the entire server to detect every typo or syntax error makes for an unenviable developer experience.

What improvements would you suggest, over this baseline (and intolerable) development cycle?

More specifically: How do you catch Lua syntax errors before trying to run the mod in the game? What editor or IDE do you use and why? Does any Lua editor offer meaningful refactoring utilities or auto complete in a Minetest modding context?

When debugging a mod, is there a way to reload changes to Lua code without having to restart the entire server?

Thank you for your consideration and for the cool mods you create.

L-Dog
Member
Posts: 481
Joined: Sat Jun 19, 2021 12:49
GitHub: N-nec
In-game: L-Dog

Re: Lua Mod Development Cycle

by L-Dog » Post

modtea wrote:
Sat May 14, 2022 21:39
First post.

Please consider the following Lua Mod development cycle:
1. Type and save Lua code into a mod folder.
2. Launch Minetest Server with a world that has enabled the mod.
3. Sign into the Minetest world from a client.
4. Interact with the world in ways that involve the mod.
5. Read logs for crash data or console debugging output generated by mod.
6. Stop the Minetest Server.
7. Edit lua code.
Return to step 2 and repeat.

This 'works', but with horrendous time and tedium costs. In particular, reloading the entire server to detect every typo or syntax error makes for an unenviable developer experience.

What improvements would you suggest, over this baseline (and intolerable) development cycle?

More specifically: How do you catch Lua syntax errors before trying to run the mod in the game? What editor or IDE do you use and why? Does any Lua editor offer meaningful refactoring utilities or auto complete in a Minetest modding context?

When debugging a mod, is there a way to reload changes to Lua code without having to restart the entire server?

Thank you for your consideration and for the cool mods you create.



Best Advice... Make a copy of your Mods and load them onto an OFFLINE world... then any errors happen instantly and to fix them is even faster (no server loading times)

Bastrabun
Member
Posts: 211
Joined: Mon Nov 04, 2019 19:48

Re: Lua Mod Development Cycle

by Bastrabun » Post

You may want to use git. Then you can return to previous versions easily.

> How do you catch Lua syntax errors before trying to run the mod in the game? What editor or IDE do you use and why? Does any Lua editor offer meaningful refactoring utilities or auto complete in a Minetest modding context?

Use an IDE that supports your language. For MT, I use Visual Studio Code, with the Minetest extension by GreenXenith and some lua extension of your choice

Use luacheck

> When debugging a mod, is there a way to reload changes to Lua code without having to restart the entire server?

Look at the snippets mod. You can overwrite public functions from within the game.
Whatever I say is CC0

User avatar
rubenwardy
Moderator
Posts: 6972
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: Bristol, United Kingdom
Contact:

Re: Lua Mod Development Cycle

by rubenwardy » Post

You can host a server from a client by checking the host server checkbox in the main menu.

VsCode is a pretty common editor, there are Lua extensions that provide linting using luacheck
Renewed Tab (my browser add-on) | Donate | Mods | Minetest Modding Book

Hello profile reader

modtea
New member
Posts: 3
Joined: Sat May 14, 2022 21:03
GitHub: modtea

Re: Lua Mod Development Cycle

by modtea » Post

Bastrabun wrote:
Sat May 14, 2022 22:08
You may want to use git ... For MT, I use Visual Studio Code, with the Minetest extension by GreenXenith and some lua extension of your choice...
Use luacheck

Look at the snippets mod. You can overwrite public functions from within the game.
Using git. :) Would you still use Visual Studio if you ran Linux?

snippets mod looks great! Thanks! I'll look into luacheck, too.
rubenwardy wrote:
Sat May 14, 2022 22:10
You can host a server from a client by checking the host server checkbox in the main menu.

VsCode is a pretty common editor, there are Lua extensions that provide linting using luacheck
luacheck sounds useful. Of course running the server from the client or from the terminal doesn't matter much in terms of time penalties, but thanks.

User avatar
rubenwardy
Moderator
Posts: 6972
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: Bristol, United Kingdom
Contact:

Re: Lua Mod Development Cycle

by rubenwardy » Post

modtea wrote:
Sat May 14, 2022 23:58
Of course running the server from the client or from the terminal doesn't matter much in terms of time penalties, but thanks.
It means you only have to close/open one process, rather than two
Renewed Tab (my browser add-on) | Donate | Mods | Minetest Modding Book

Hello profile reader

User avatar
Blockhead
Member
Posts: 1624
Joined: Wed Jul 17, 2019 10:14
GitHub: Montandalar
IRC: Blockhead256
In-game: Blockhead Blockhead256
Location: Land Down Under
Contact:

Re: Lua Mod Development Cycle

by Blockhead » Post

Luacheck is good advice. But also, when developing I usually create a world that contains a minimal set of mods to support the one I'm working on, and even use minimal development test rather than Minetest Game/Mineclone etc. where appropriate. I run the game in singleplayer unless I need to test multiplayer functionality. I also use the keyboard to quickly restart: Esc, Tabx5, then Enter to close a singleplayer game. Then Enter on the main menu will reopen the same world you were just playing. This sounds a whole lot faster than running a separate server and client and having to restart both.

There are some ways to get around needing to restart the server. Minetest Systemd is one project that can do that, but obviously it has a setup cost, and can't avoid all server restarts, so you would want to be frequently revising your mod in order to get a time saving out of it.
/˳˳_˳˳]_[˳˳_˳˳]_[˳˳_˳˳\ Advtrains enthusiast | My map: Noah's Railyard | My Content on ContentDB ✝️♂

Bastrabun
Member
Posts: 211
Joined: Mon Nov 04, 2019 19:48

Re: Lua Mod Development Cycle

by Bastrabun » Post

> Using git. :) Would you still use Visual Studio if you ran Linux?

I do run linux :)

So the answer is YES. If you're a bit concerned about Microsoft in that thing, then I heard there's an even freerererer open source Visual Studio Code called Visual Studio Codium, but I have no experience with it, never tried.
Whatever I say is CC0

User avatar
rubenwardy
Moderator
Posts: 6972
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: Bristol, United Kingdom
Contact:

Re: Lua Mod Development Cycle

by rubenwardy » Post

modtea wrote:
Sat May 14, 2022 23:58
Using git. :) Would you still use Visual Studio if you ran Linux?
VsCode isn't visual studio, it's a completely different program. I use it on Linux

There's 3 programs to choose from here: VSCode, Code - OSS, and VSCodium

VsCode is like Chrome, it's mostly open source with some proprietary Microsoft stuff.
VSCode is based on Code - OSS, which is like Chromium. It's completely opensource.
There's also VSCodium, which is a community fork of Code - OSS with some changes such as a FOSS add-on store

I use Code - OSS because that's what Manjaro/Arch has in their repos
Renewed Tab (my browser add-on) | Donate | Mods | Minetest Modding Book

Hello profile reader

User avatar
Mantar
Member
Posts: 585
Joined: Thu Oct 05, 2017 18:46
Contact:

Re: Lua Mod Development Cycle

by Mantar » Post

I hear good things about ZeroBrane Studio when it comes to IDEs, but I just use Emacs with FlyCheck, an extension that runs luacheck over my code as it's written.
Lead dev of Exile, git repo: https://codeberg.org/Mantar/Exile

modtea
New member
Posts: 3
Joined: Sat May 14, 2022 21:03
GitHub: modtea

Re: Lua Mod Development Cycle

by modtea » Post

Blockhead wrote:
Sun May 15, 2022 02:10
... when developing I usually create a world that contains a minimal set of mods to support the one I'm working on, and even use minimal development test rather than Minetest Game/Mineclone etc. where appropriate.
This actually made a bigger difference than I expected. Thanks!

I'll look into Piezo, too. :)

User avatar
Linuxdirk
Member
Posts: 3218
Joined: Wed Sep 17, 2014 11:21
In-game: Linuxdirk
Location: Germany
Contact:

Re: Lua Mod Development Cycle

by Linuxdirk » Post

modtea wrote:
Sat May 14, 2022 21:39
2. Launch Minetest Server with a world that has enabled the mod.
3. Sign into the Minetest world from a client.
4. Interact with the world in ways that involve the mod.
5. Read logs for crash data or console debugging output generated by mod.
This is basically one step. Just tab from the editor to the console (you’ll likely start MT from console anyways to have an easy accessible trace after crashing the client), press the up arrow, press enter. You only need to type the command once.

Code: Select all

minetest --world ~/.minetest/worlds/testworld --go
Replace testworld with the name/folder of a previously set up world containing your mod.

I didn’t find a way to start an “ad-hoc server” with this, though. But a singleplayer game basically is a server that is restricted to one single player named “singleplayer”.

A workaround is: start the client, set "host a server" or whatever the (option left of the worlds list is named in English) and start the world. When you then close the client and restart it, simply press enter, so: start from console one time, and then use basically the same trick as with the single player world: Press up arrow, press enter, press enter a second time. Bam, server is started and you’re logged in.

Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests