Designing the "MiniScript in Godot" Framework
Designing a full-stack implementation of MiniScript in Godot requires careful thought. In this article, I will outline what I believe are the essential modules needed to achieve a complete full-stack solution. Each module will be loosely coupled to the ones above it, allowing game developers to decide how far up the stack they want to use my implementation before stopping with my modules and finishing the stack with their code. The higher you implement, the simpler it should become; however, each added layer is likely to have some performance impact on the resulting game. The extent of this impact remains to be seen.
This layer comprises two modules. The first module is the base interpreter, which accepts a string containing MiniScript code as input and executes the script, returning the output result (assuming it's a string output) through a signal. A separate signal is also triggered for error/log information. That's all that is required in the base layer.
The second optional module of the first layer extends the MiniScript language with custom intrinsics and properties, enabling messaging back and forth with Godot. As a GDExtension must define these mechanisms at compile time, it serves as a C++ middle layer provided to the developer as a template of best practices or a conversion library layer. This necessitates a solid understanding of GDExtensions and the ability to build your own, as well as familiarity with MiniScript integration techniques for adding your intrinsics.
Additionally, as part of this module, I aim to offer an implementation of a generic set of methods and properties for creating MiniScript customizations from GDScript (refer to the layers mentioned above). This approach will be less efficient than coding directly in this layer using C++.
This layer is the GDScript implementation layer, which comprises two distinct modules. Although independent, these modules can function collaboratively. The first module is the MiniScript Data Store. From this point forward, the implementation begins to adopt my design goal paradigm, which envisions an Artificial Intelligence "Brain" used to enhance the game elements with intelligence.
This encapsulates the previous layers into a Godot Node for use within GDScript, offering methods and properties for transferring raw data types between MiniScript and GDScript. Developers can then utilize this to implement their game logic. I can accommodate generic data types, but if developers desire their custom game types, they must implement this themselves by modifying the data store code to include their additions, following the provided examples.
Closely related to the Data Store, yet capable of being used independently, is the Interface. This is where the GDScript implementation of custom MiniScript extensions takes place. Essentially, it serves as a higher-level abstraction of the Extensions layer, either purely passing through the base generic extension methods or wrapping those methods into simpler, game design-focused methods, which are then employed to write the game code in GDScript. Alternatively, or additionally, this may be inserted into the running user script as MiniScript helper code, following Joe Strout's design pattern in his Unity implementation guide. Note that using the generic translation methods provided will likely be less performant than coding directly in the Extensions layer.
This layer serves as a helper layer, featuring a few UI modules to facilitate the integration of code into the game. The first module is the developer tools, essentially a console that allows developers to test and examine the Godot/MiniScript data and handshaking. It is important to note that this module is entirely optional and has no role in the final game produced.
Lastly, another useful feature is the Player MiniScript Manager. This is a library and UI module accessible to developers, offering a basic Player MiniScript IDE for file management, editing, and storage of Player MiniScript code.
Once all the layers are finished, I can create my own "game" (currently under the working title of Godot MiniScript Playground). This will be a fully-featured implementation of all my layers, serving as a demonstration project.
I'm not sure if everything will work out as planned. The core module is essentially complete, with only some final testing and tidying up left to be done. In the process, parts of the player script manager have been created, allowing me to test the core functionality. However, I expect that it will undergo numerous changes before the final version is completed.
Until next time...
Did you find this article valuable?
Support MiniScript News, Reviews and Development by becoming a sponsor. Any amount is appreciated!