Lua Mod Development Cycle
Lua Mod Development Cycle
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.
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.
Re: Lua Mod Development Cycle
modtea wrote: ↑Sat May 14, 2022 21:39First 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)
Re: Lua Mod Development Cycle
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.
> 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
- rubenwardy
- Moderator
- Posts: 6977
- Joined: Tue Jun 12, 2012 18:11
- GitHub: rubenwardy
- IRC: rubenwardy
- In-game: rubenwardy
- Location: Bristol, United Kingdom
- Contact:
Re: Lua Mod Development Cycle
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
VsCode is a pretty common editor, there are Lua extensions that provide linting using luacheck
Re: Lua Mod Development Cycle
Using git. :) Would you still use Visual Studio if you ran Linux?
snippets mod looks great! Thanks! I'll look into luacheck, too.
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.rubenwardy wrote: ↑Sat May 14, 2022 22:10You 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
- rubenwardy
- Moderator
- Posts: 6977
- Joined: Tue Jun 12, 2012 18:11
- GitHub: rubenwardy
- IRC: rubenwardy
- In-game: rubenwardy
- Location: Bristol, United Kingdom
- Contact:
Re: Lua Mod Development Cycle
It means you only have to close/open one process, rather than two
- Blockhead
- Member
- Posts: 1673
- 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
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.
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 ✝️♂
Re: Lua Mod Development Cycle
> 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.
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
- rubenwardy
- Moderator
- Posts: 6977
- Joined: Tue Jun 12, 2012 18:11
- GitHub: rubenwardy
- IRC: rubenwardy
- In-game: rubenwardy
- Location: Bristol, United Kingdom
- Contact:
Re: Lua Mod Development Cycle
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
Re: Lua Mod Development Cycle
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
Re: Lua Mod Development Cycle
This actually made a bigger difference than I expected. Thanks!
I'll look into Piezo, too. :)
- Linuxdirk
- Member
- Posts: 3219
- Joined: Wed Sep 17, 2014 11:21
- In-game: Linuxdirk
- Location: Germany
- Contact:
Re: Lua Mod Development Cycle
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
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.
Who is online
Users browsing this forum: No registered users and 7 guests