Fractal Block World

Fractal Block World

View Stats:
noncom Dec 12, 2024 @ 6:51pm
A couple of questions about scripting
So I looked at it briefly, and got a couple of questions;
  • It seems that scripting uses Lua 5.2? Why not the latest? I would think it's because of locking on LuaJIT, but 5.2 doesn't mean LuaJIT either, right?
  • I wanted to see how the xar world was built, as an example, but I found almost no descriptions of nodes in its WorldNodes folder. There are just a few block scripts, but not nearly for everything that's in the game. As I understood, the world structure and topology should mostly reside there, but it's not there. But where is it then?
  • Are the world-generation scripts pre-executed only once at the start of the game, to get all the block data, like in MineTest, or does the game call the generation functions each time a block is requested anew during runtime? I mean, is it possible to dynamically generate blocks during the game?

Sorry if I'm missing something obvious here, but I only had a little time to read the manual and look at the files, and got no answers.
< >
Showing 1-8 of 8 comments
Carbo♦lemons Dec 12, 2024 @ 9:27pm 
I can't answer about why not Lua 5.2, but Dan has stated in the official community made discord that Xar's WorldNodes are baked into the c++ engine, and that they will not be ported over because it is a lot of code
fractal_dev_team  [developer] Dec 13, 2024 @ 3:56am 
The game calls the __main function of a block script every time a block of that type is expanded into a chunk. And yes, the xar block types are hard coded in C++ so you do not have access to them. However you can override xar blocks with Lua block scripts.
Last edited by fractal_dev_team; Dec 13, 2024 @ 3:57am
noncom Dec 14, 2024 @ 7:22am 
I see, yeah, was thinking it was like this. Would be great if they'd be moved to Lua though, even from the POV of robustness of everything, because otherwise it kind of speaks against scripting itself :D But I know that it might be not so easy, and that scripting is kind of experimental atm, as the manual states.

But still: why Lua 5.2? Are there any plans to update to the latest one? This influences what libraries can be used, and what compat-mode to target for those that support it.

Maybe I should join Discord, the project is quite interesting, it would be cool to keep up with what's up.
Hmm what's the official Discord server though? There's no link anywhere I can see, but I remember I saw a mention of it somewhere...
Last edited by noncom; Dec 14, 2024 @ 7:31am
fractal_dev_team  [developer] Dec 15, 2024 @ 5:26am 
You should join the discord server. Also, you cannot use any Lua libraries. You can only use the API the program provides. I will periodically consider a switching to to more recent version of Lua, but only if we have a Windows binary. I am not going to compile the Lua library from source. You can do anything you can do with the C++ wordgen with Lua worldgen. I am making a second game where the worldgen is entirely in Lua (which works with the current engine). The C++ wordgen is 150,000 lines of code, so it would be a waste of my time to convert it to Lua. Just look the tutorial packages that use Lua worldgen for how to create Lua wordgen. The only thing you would get from the C++ worldgen ported to Lua is the shear quantity and repetition of it, all the essentials are already in the tutorial Lua worlgen packages.
Last edited by fractal_dev_team; Dec 15, 2024 @ 5:54am
fractal_dev_team  [developer] Dec 15, 2024 @ 5:29am 
Here is the discord server: https://discord.gg/MdRmg5vpDa
fractal_dev_team  [developer] Dec 15, 2024 @ 6:55am 
I also don't want to convert the xar C++ worldgen code to Lua because I don't want someone to be able to run the xar package on a 3rd party engine. That is a bigger concern than just the amount of work it would take to port the code.
Last edited by fractal_dev_team; Dec 15, 2024 @ 6:56am
noncom Dec 15, 2024 @ 5:51pm 
Thanks for the answers!

I see, yeah so the sheer size tbh already justifies leaving the xar world description in C++, especially taking into consideration that you now keep working on the next further stuff, which is great to know!

And yeah I think I remember something about speedrunning, so making the world opensource would probably compromise that quite much. People would be able to do all kinds of unfair stuff and honest people would suffer.

But also, from just the normal play view, the world is mysterious, so it's kind of good to keep it that way as well!

Actually I joined that Discord before, but it was saying it's unofficial so I left it, but ok now I rejoined!

Also, about Lua, I think there's no #suggestions channel or smth like it on the server, and I'm not sure this discussion fits #mods. But just to say, when I use Lua, I usually either get the pre-built binaries from here[joedf.github.io] or the ready-to-build-on-windows source with prepared makefiles, from which these binaries are built from here[github.com]. These are maintained by the creator of AutoHotkey, and always have the latest stable build available. Also, building Lua is literally one command with MinGW-w64 installed, when gcc is available in PATH. If it's possible, I think it would really be neat to have the latest and greatest Lua tbh, since the new versions have cool stuff, and are more performant as well.

As for not using libraries -- hmm, that's one thing too bad tbh, Lua has a lot of nice libraries already, including maths, etc.. I kind of understand the sandboxing limitations, prohibition to use C-based Lua libraries, but pure Lua libs would've been a great help in development. Of course one can copy-paste the library source, and call it a day maybe, idk.
fractal_dev_team  [developer] Dec 16, 2024 @ 4:23am 
Thank you for the links about Lua binaries! Those are very helpful. The build system of the fractal block world program uses MinGW as a compiler, so I am glad to see they have such builds.
< >
Showing 1-8 of 8 comments
Per page: 1530 50