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.