Mcreator for Luanti: Lcreator (beta)

Post Reply
AzureTecDevs
New member
Posts: 5
Joined: Mon Mar 03, 2025 23:10
GitHub: MuttsCanCode
In-game: azuretec

Mcreator for Luanti: Lcreator (beta)

by AzureTecDevs » Post

Image
Version: Beta 1.0 UNDER DEVELOPMENT!

There are people that have been requesting a software like Mcreator for Luanti (including me), so I decided to try making one in JavaScript and HTML. Here's the result: https://muttscancode.github.io.

Currently, Lcreator uses:
  • Blockly for the interface
  • JSZIP for exporting the mod
  • Your browser's LocalStorage to save imported PNG images and your code
Note: Clearing https://muttscancode.github.io's site data will delete your project and it's imported images.

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

Re: Mcreator for Luanti: Lcreator (beta)

by Blockhead » Post

I welcome this auspicious endeavour. It's clear you have a lot of work cut out for you to reach the kind of capabilities MCreator has, but you should be able to get there with time and effort.

First things first: I almost gave up before launching the actual app, because the link to launch it is practically hidden on the landing page. Dark green and dark blue on a pure black background that is left-aligned under a centre-aligned banner made it really hard to find when I thought I was already going to be in the app. You need more colour contrast and things shouldn't be misaligned like that. At least not when the page is that short; I can see you'll probably have a project landing page there in future.

Anyway, my 2c: There are going to be significant differences, of course, from MCreator because you're targetting a different engine. If I look at the kinds of objects present in MCreator, I see "specialised" kinds like Potion Recipes and Projectiles that aren't built into Luanti, although they are entirely possible in some of the games for Luanti. I think you will have to build it out in a modular architecture where you have the core capabilities of the engine to begin with, then capabilities of games like Mineclonia or Minetest Game and finally capabilities for mods. An MCreator forum thread tells me that there are JSON files for this sort of thing to target using MCreator for mods of mods for Minecraft. You need to make it easy enough to let others add support for mods and games into Lcreator. It would be really exciting to see, for instance, to see support for adding a new technic machine, or an Advtrains wagon, and so on.

I could go on and on about a laundry list of other things - models, capabilities, good UI & UX design - but you're probably well aware, and it's only early days. So anyway, good luck with the project.
/˳˳_˳˳]_[˳˳_˳˳]_[˳˳_˳˳\ Advtrains enthusiast | My map: Noah's Railyard | My Content on ContentDB ✝️♂

AzureTecDevs
New member
Posts: 5
Joined: Mon Mar 03, 2025 23:10
GitHub: MuttsCanCode
In-game: azuretec

Re: Mcreator for Luanti: Lcreator (beta)

by AzureTecDevs » Post

Blockhead wrote:
Tue Mar 04, 2025 02:47
I welcome this auspicious endeavour. It's clear you have a lot of work cut out for you to reach the kind of capabilities MCreator has, but you should be able to get there with time and effort.

First things first: I almost gave up before launching the actual app, because the link to launch it is practically hidden on the landing page. Dark green and dark blue on a pure black background that is left-aligned under a centre-aligned banner made it really hard to find when I thought I was already going to be in the app. You need more colour contrast and things shouldn't be misaligned like that. At least not when the page is that short; I can see you'll probably have a project landing page there in future.

Anyway, my 2c: There are going to be significant differences, of course, from MCreator because you're targetting a different engine. If I look at the kinds of objects present in MCreator, I see "specialised" kinds like Potion Recipes and Projectiles that aren't built into Luanti, although they are entirely possible in some of the games for Luanti. I think you will have to build it out in a modular architecture where you have the core capabilities of the engine to begin with, then capabilities of games like Mineclonia or Minetest Game and finally capabilities for mods. An MCreator forum thread tells me that there are JSON files for this sort of thing to target using MCreator for mods of mods for Minecraft. You need to make it easy enough to let others add support for mods and games into Lcreator. It would be really exciting to see, for instance, to see support for adding a new technic machine, or an Advtrains wagon, and so on.

I could go on and on about a laundry list of other things - models, capabilities, good UI & UX design - but you're probably well aware, and it's only early days. So anyway, good luck with the project.
Thanks for the feedback! I've been planing on changing the interface, as the landing page was temporary. Also, I've been thinking that I can use JSZIP (the library I use for exporting the mod) to have the user import "plugins" in ZIP files, like how MCreator does it. These plugins could have a JSON file, allowing them to change how Blockly's Lua generator functions. I came up with this JSON format:

Code: Select all

{
    "plugin": {
        "modifys": [
            {
                "node": "core.register_node('$((ID:${text_id}', {\r\n    description = \"${text_name}\",\r\n    tiles = {\"${text_img}.png\"},\r\n    groups = {${dropdown_grp} = ${number_hard}},\r\n    is_ground_content = ${checkbox_isgnd.toLowerCase()},\r\n    drop = '${text_did}'\r\n})"
            }
        ],
        "description": "A basic template. Does not change anything, but provides the Node generator to edit.",
        "versionId": 1,
        "name": "Basic template"
    },
    "js": {
        "init": "console.log('Hello, world!');",
        "onComplie": "console.log('exporting mod!!!');"
    }
}
No pressure, but does this look good (or understandable)?
Also, the js object lets the plugin creator add JavaScript code that runs on start (init) and when the project is exported (onCompile). I think this feature could be used for malicious purposes, should the user be able to toggle it, or should I remove it?

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

Re: Mcreator for Luanti: Lcreator (beta)

by Blockhead » Post

AzureTecDevs wrote:
Tue Mar 04, 2025 18:14
Thanks for the feedback! I've been planing on changing the interface, as the landing page was temporary.
Yep and I can see you've already done so, that's good.
AzureTecDevs wrote:
Tue Mar 04, 2025 18:14
Also, I've been thinking that I can use JSZIP (the library I use for exporting the mod) to have the user import "plugins" in ZIP files, like how MCreator does it. These plugins could have a JSON file, allowing them to change how Blockly's Lua generator functions.
This is good in theory: new kinds of blockly blocks, and additions to existing ones.
AzureTecDevs wrote:
Tue Mar 04, 2025 18:14
I came up with this JSON format:

Code: Select all

{
    "plugin": {
        "modifys": [
            {
                "node": "core.register_node('$((ID:${text_id}', {\r\n    description = \"${text_name}\",\r\n    tiles = {\"${text_img}.png\"},\r\n    groups = {${dropdown_grp} = ${number_hard}},\r\n    is_ground_content = ${checkbox_isgnd.toLowerCase()},\r\n    drop = '${text_did}'\r\n})"
            }
        ],
        "description": "A basic template. Does not change anything, but provides the Node generator to edit.",
        "versionId": 1,
        "name": "Basic template"
    },
    "js": {
        "init": "console.log('Hello, world!');",
        "onComplie": "console.log('exporting mod!!!');"
    }
}
No pressure, but does this look good (or understandable)?
First, I'd fix the two typos: modifys -> modifies and onComplie -> onCompile. Unless you have inherited these from Blocky (unlikely), then you have to try to stop typos at the source. I'm probably nitpicking too much and this is just a draft.

Next: You're using some kind of text substitution to generate Lua tables, and you end up putting very long strings inside of JavaScript Objects. I kind of cringe at seeing \r\n literals both from a Linux user perspective (knowing full well some people on Windows still edit in programs that need the \r...) but mostly this is a code smell to me.

Again, unless you inherited this from Blockly (again, I sure hope not), you should surely want to have a cleaner way that maps JSON objects to Lua Tables. I would suggest that you use serializer type functions comparable to core.parse_json and core.write_json that Luanti itself has. These are backed by a C++ library, however npm should have comparable libraries like luadata. Maybe I have neglected to think about how Blockly operates, but this is how I'd do it from first principles.

I browsed a bit through the built-in generators for Lua in Blocky. A lot of them generate strings in multiple lines of code throughout the function body, based on the Blockly-block data, which seems a lot better than doing an entire table at once with just a single string with text substitutions. Surely this is something you could use as a pattern.

AzureTecDevs wrote:
Tue Mar 04, 2025 18:14
Also, the js object lets the plugin creator add JavaScript code that runs on start (init) and when the project is exported (onCompile). I think this feature could be used for malicious purposes, should the user be able to toggle it, or should I remove it?
Security always makes us ask hard questions. I think that as long as the plugins are provided under free software licences, they are probably trustworthy. The browser sandbox is reasonably secure, so you're usually only risking the contents of the Mcreator project tab and some of the browser fingerprint data (useragent etc). Browser exploits that are powerful enough to escape that sandbox are usually targetted at more valuable targets than making mods for Luanti, like stealing credit card info - which is to say, I don't expect malware authors to choose Lcreator as their target. Blender ships with a number of community-created plugins pre-installed but disabled; you could do something similar, as a kind of rubber stamp.
/˳˳_˳˳]_[˳˳_˳˳]_[˳˳_˳˳\ Advtrains enthusiast | My map: Noah's Railyard | My Content on ContentDB ✝️♂

AzureTecDevs
New member
Posts: 5
Joined: Mon Mar 03, 2025 23:10
GitHub: MuttsCanCode
In-game: azuretec

Re: Mcreator for Luanti: Lcreator (beta)

by AzureTecDevs » Post

Next: You're using some kind of text substitution to generate Lua tables, and you end up putting very long strings inside of JavaScript Objects. I kind of cringe at seeing \r\n literals both from a Linux user perspective (knowing full well some people on Windows still edit in programs that need the \r...) but mostly this is a code smell to me.
I made this as a draft with a JSON editor, hence the \r\n literals. Also, I am a linux user (Ubuntu 20.04) *random fact.
would suggest that you use serializer type functions comparable to core.parse_json and core.write_json that Luanti itself has. These are backed by a C++ library, however npm should have comparable libraries like luadata. Maybe I have neglected to think about how Blockly operates, but this is how I'd do it from first principles.
Blockly generates the blocks' code by registering a function to the lua.luaGenerator.forBlock array. This function tells the generator how to generate the code from blocks by returning a string that contains the code. You can find more at Google's Blockly for Developers website. NOTE: Lcreator is a static website, so NPM (from what I know) can not be used. I usually find a plain JS file of a library, and add it as a script tag.

Code: Select all

lua.luaGenerator.forBlock['blockId'] = function(block, generator) { }
PS: I updated the landing page and editor, go check it out! (no pressure)

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

Re: Mcreator for Luanti: Lcreator (beta)

by Blockhead » Post

AzureTecDevs wrote:
Wed Mar 05, 2025 03:48
NOTE: Lcreator is a static website, so NPM (from what I know) can not be used. I usually find a plain JS file of a library, and add it as a script tag.
NPM isn't just for servers running node.js, it's for fetching client-side JavaScript libraries as well. As long as it runs without the Node special sauce it should be fine. I'm really not familiar with the ecosystem though.
/˳˳_˳˳]_[˳˳_˳˳]_[˳˳_˳˳\ Advtrains enthusiast | My map: Noah's Railyard | My Content on ContentDB ✝️♂

AzureTecDevs
New member
Posts: 5
Joined: Mon Mar 03, 2025 23:10
GitHub: MuttsCanCode
In-game: azuretec

Re: Mcreator for Luanti: Lcreator (beta)

by AzureTecDevs » Post

Blockhead wrote:
Wed Mar 05, 2025 10:09
NPM isn't just for servers running node.js, it's for fetching client-side JavaScript libraries as well. As long as it runs without the Node special sauce it should be fine.
Thanks, I didn't know that until you told me. I assume that 'Node special sauce' is the stuff dependent on Node.js. As long as I can find a library that doesn't depend on Node.js, I think I could be fine downloading libraries from npm.
... would suggest that you use serializer type functions comparable to core.parse_json and core.write_json that Luanti itself has. These are backed by a C++ library, however npm should have comparable libraries like luadata.
Do you mean core.parse_json as in parsing the Plugins, or something else? Sorry if I'm not understanding, as I code in Python and JS, and this project is my first time using Lua for a major project. The only time I've ever used Lua outside of making mods is in the CC: Tweaked mod for Minecraft Java, when I wrote "Hello, world!". I feel like I'm getting off topic here, but I do like the Digilines mod, it's what got me interested in Luanti in the first place.

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

Re: Mcreator for Luanti: Lcreator (beta)

by Blockhead » Post

AzureTecDevs wrote:
Wed Mar 05, 2025 21:05
As long as I can find a library that doesn't depend on Node.js, I think I could be fine downloading libraries from npm.
I was really just using it as a search engine, do whatever helps you find packages.

... would suggest that you use serializer type functions comparable to core.parse_json and core.write_json that Luanti itself has. These are backed by a C++ library, however npm should have comparable libraries like luadata.
AzureTecDevs wrote:
Wed Mar 05, 2025 21:05
Do you mean core.parse_json as in parsing the Plugins, or something else? Sorry if I'm not understanding, as I code in Python and JS, and this project is my first time using Lua for a major project.
What I mean is producing an entire JS object and then transforming it with a function into a whole Lua table. This is just one approach, you can transform the blockly blocks whatever way works. I'm talking about ways to try to do it in an organised way so you don't pile hacks on top of hacks and lose track of the code.
AzureTecDevs wrote:
Wed Mar 05, 2025 21:05
The only time I've ever used Lua outside of making mods is in the CC: Tweaked mod for Minecraft Java, when I wrote "Hello, world!". I feel like I'm getting off topic here, but I do like the Digilines mod, it's what got me interested in Luanti in the first place.
Digilines is pretty fun. For some, techage is preferable, with its specialised kinds of nodes for different jobs, but digilines is great for getting you into Lua. Funny actually, to come full circle, something like blocky could work inside of Luanti instead of Luacontrollers :)
/˳˳_˳˳]_[˳˳_˳˳]_[˳˳_˳˳\ Advtrains enthusiast | My map: Noah's Railyard | My Content on ContentDB ✝️♂

AzureTecDevs
New member
Posts: 5
Joined: Mon Mar 03, 2025 23:10
GitHub: MuttsCanCode
In-game: azuretec

Re: Mcreator for Luanti: Lcreator (beta)

by AzureTecDevs » Post

Oh, bet you someday we'll get Linux running in Luanti! They've already done it in CraftOS (Lua terminal for Minecraft) (https://github.com/MCJack123/lunatic86)

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest