Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Built Time Scripts #11641

Open
shinspiegel opened this issue Jan 26, 2025 · 1 comment
Open

Built Time Scripts #11641

shinspiegel opened this issue Jan 26, 2025 · 1 comment

Comments

@shinspiegel
Copy link

Describe the project you are working on

Multiple projects, including:

  • RPG Game: A traditional jRPG with multiple weapons, creatures, and special abilities. All abilities and powers are stored in CSV files, which contain the main stats, equipment, and behaviors for each creature and item.

  • Shoot 'Em Up: A fast-paced arcade-style game inspired by titles like Sonic Wings or Gradius. The game features numerous enemy types, variations, and level wave definitions, all described in separate CSV files.

Both projects rely heavily on external files for game data, which must be parsed and converted into usable in-game Resource objects.

Describe the problem or limitation you are having in your project

I need to parse multiple external files, such as CSV, markdown, or other formats, into Resource objects that are usable in-game. Doing this parsing at runtime consumes significant time and resources, even though the parsing only needs to occur once for static data. It would be more efficient to perform this conversion at build time so the final game can include pre-parsed data, minimizing runtime overhead and improving load times.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

I propose introducing Build Time Scripts to the Godot Engine. These scripts would execute during the project's build process (akin to how _Singletons/Autoloads function at runtime). Build Time Scripts would allow developers to parse local files—such as CSV files—into Resource objects during the build process. The resulting Resource files could then be included directly in the game package, avoiding runtime parsing altogether.

For example:

  • During the build process, the Build Time Script parses CSV data for enemies, weapons, and levels.
  • It converts this data into Godot's Resource class (or other)
  • The game package then includes the pre-parsed Resource files, which can be loaded directly at runtime without further processing.

This feature would streamline workflows, improve runtime performance, and ensure a cleaner separation between data preparation and gameplay.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

The feature would introduce a new category in the Project Settings, similar to how Autoloads are configured. Developers would specify GDScript files that should run at build time. These scripts would have access to the file system and Godot's Resource APIs, allowing them to manipulate files, parse data, and generate new Resource files.

Example workflow:

  • Add a Build Time Script in the Project Settings under a new "Build Time Scripts" section.
  • The script implements logic to parse external files and create resources:
extends Object

func _init():
    var csv_file = FileAccess.open("res://data/enemies.csv", FileAccess.READ)
    var parsed_data = parse_csv(csv_file)
    var resource = create_enemy_resource(parsed_data)
    ResourceSaver.save("res://resources/enemies.tres", resource)
  • The _init() function is called during the project build, generating the required Resource files.

If this enhancement will not be used often, can it be worked around with a few lines of script?

While this feature can be partially worked around using external tools or custom-build pipelines (such as bash scripts, which is my current case), doing so is cumbersome and lacks integration with Godot's existing workflows. It also requires developers to rely on external dependencies, reducing portability and maintainability. Embedding this capability into Godot would make it more accessible and efficient for all users.

There is also the option to create a plugin with a single checkbox to run these, but I often came to the realization that I forgot to press this checkbox to run the script and/or can't do this at the bash script that automated the exporting for all the platforms.

Is there a reason why this should be core and not an add-on in the asset library?

It's possible, but this would require a deep integration with the engine, and this steps could improve the workflow for the game generation.

@KoBeWi
Copy link
Member

KoBeWi commented Jan 26, 2025

"Built-time" you mean project export? Check EditorExportPlugin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants