|
| 1 | +extends Node |
| 2 | + |
| 3 | +# Brief overview of what your mod does... |
| 4 | + |
| 5 | +# ! Comments prefixed with "!" mean they are extra info. Comments without them |
| 6 | +# ! should be kept because they give your mod structure and make it easier to |
| 7 | +# ! read by other modders |
| 8 | + |
| 9 | + |
| 10 | +const MOD_DIR = "AuthorName-ModName/" # name of the folder that this file is in |
| 11 | +const MYMOD_LOG = "AuthorName-ModName" # full ID of your mod (AuthorName-ModName) |
| 12 | + |
| 13 | + |
| 14 | +var dir = "" |
| 15 | +var ext_dir = "" |
| 16 | + |
| 17 | + |
| 18 | +func _init(modLoader = ModLoader): |
| 19 | + ModLoaderUtils.log_info("Init", MYMOD_LOG) |
| 20 | + |
| 21 | + # ! We can't use `ModLoader` because the ModLoader instance isn't available |
| 22 | + # ! at this point in the mod's loading process. Instead, the class instance |
| 23 | + # ! is passed to a mod's `_init` func via the variable `modLoader`. |
| 24 | + # ! It will be available in any other places in your mod though, such as in |
| 25 | + # ! your _ready func. |
| 26 | + dir = modLoader.UNPACKED_DIR + MOD_DIR |
| 27 | + ext_dir = dir + "extensions/" # ! any script extensions should go in this folder, and should follow the same folder structure as vanilla |
| 28 | + |
| 29 | + # Add extensions |
| 30 | + modLoader.install_script_extension(ext_dir + "main.gd") # brief description of this edit... |
| 31 | + #modLoader.install_script_extension(ext_dir + "entities/units/player/player.gd") # ! Note that this file does not exist in this example mod |
| 32 | + |
| 33 | + # ! Add extensions (longform version of the above) |
| 34 | + #modLoader.install_script_extension("res://mods-unpacked/AuthorName-ModName/extensions/main.gd") |
| 35 | + #modLoader.install_script_extension("res://mods-unpacked/AuthorName-ModName/extensions/entities/units/player/player.gd") |
| 36 | + |
| 37 | + # Add translations |
| 38 | + # ! Load translations for your mod, if you need them. |
| 39 | + # ! Add translations by adding a CSV called "modname.csv" into the "translations" folder. |
| 40 | + # ! Godot will automatically generate a ".translation" file, eg "modname.en.translation". |
| 41 | + # ! Note that in this example, only the file called "modname.csv" is custom; |
| 42 | + # ! any other files in the "translations" folder were automatically generated by Godot |
| 43 | + modLoader.add_translation_from_resource(dir + "translations/modname.en.translation") |
| 44 | + |
| 45 | + |
| 46 | +func _ready()->void: |
| 47 | + ModLoaderUtils.log_info("Ready", MYMOD_LOG) |
| 48 | + |
| 49 | + # ! This uses Godot's native `tr` func, which translates a string. You'll |
| 50 | + # ! find this particular string in the example CSV here: translations/modname.csv |
| 51 | + ModLoaderUtils.log_info(str("Translation Demo: ", tr("MODNAME_READY_TEXT")), MYMOD_LOG) |
0 commit comments