Skip to content

Importing and Exporting

Andrew Hernandez edited this page Jun 25, 2026 · 15 revisions

System Summary

The user can import the level from a folder stored locally on their computer, they can also export a level to this folder to enable easy sharing of all assets and data.


Connected Systems

Connecting Systems:

Related Controls

N/A


Bugs

Importing and Exporting custom assets is not fully implemented on a per-level basis.


Feature List / Breakdown of Features

New Level Creation:

  • Create file structure for new level at specified location in user's Roaming folder
  • Copy over all default assets into the files so the user can easily see what they should change. Exporting:
  • Copy over all player data into a JSON file and save it.
  • Copy over all tile data into a CSV file, including rotation if applicable, then save it.
  • Copy over all files in user://Assets, which contains all the level's custom assets.

Importing:

  • Read a JSON file and set up the player's properties to match the data.
  • Read a CSV file and copy all of it's data into the current tileSet, including rotations
  • Copy the assets directory in the level's folder into user://Assets
  • If the player is present, make sure the EditorManager knows it

CSV Structure:

  • Exact copy of the tileSet, with the tiles being represented by their ID integer (-1 for no tile, 0 solid, etc.)
  • All sceneCollections additionally have a vertical bar separating their entity's ID and what scene they are.
  • All slopes additionally have a vertical bar separating their ID from their rotation when applicable JSON Structure:
  • Enemy data goes first
    • Stores location of enemy in tileSet
    • Stores all associated enemy properties
  • Player data is next
    • Stores all player properties

Important Variables

Name the most important variables, their type, and what their purpose is

  • levelPath: String = The path of the exporting level.
  • defaultPath: String = The default path of assets for cloning.

Important Functions

Name of the most important functions, their parameters, and what they do.

  • func make_new_level(name: String) -> void: Create a new level with the given name in the levelPath folder.

  • func export_level(tileSet: TileMapLayer, playerData: Panel, worldSize: Vector2) -> void: Exports the current level using the tileSet, with any specific player changes using playerData, and the world size using worldSize. Tile data is stored in a CSV file, while player data is stored in JSON.

  • func import_level(tileSet: TileMapLayer, playerData: Panel, directory: String) -> int: Imports a level from the given directory to the tile map using tileSet, along with the player data from playerData. Tile data is grabbed from a CSV file, while more in-depth data, such as the player information, is taken from a JSON.

  • func clone_data(directory: String) -> void: Clones all data from the default folders so that there are basic assets when creating a new level.

  • func match_enemy_type(enemy: Dictionary, locatedEnemy: Node2D) -> void: Matches enemy type to the correct one, and imports their data correctly.

  • func repair_corrupted_enemies(tileMap: TileMapLayer) -> void: Repairs any broken/corrupted enemies with the default data.


Future Work / Risks

Future Work:

  1. Importing doesn't change world size yet since we don't have a level of a different size to test with.
  2. Without enemies being implemented, they aren't included in the JSON yet.
  3. A proper menu with buttons to save/load from.
  4. Copy assets from the specified import to replace current sprites and assets, not done since I'm not sure of the final structure inside the Godot project yet.

Risks:

  • Adding more information requires adding more to save.

Miscellaneous Notes

A place for miscellaneous notes pertaining to this system.

  • None

Clone this wiki locally