Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: How to "refactor" a mod from old DF to new DF?  (Read 1169 times)

Valikdu

  • Bay Watcher
  • Ruin... has come to our family.
    • View Profile
How to "refactor" a mod from old DF to new DF?
« on: February 13, 2024, 03:20:16 pm »

Is there a guide somewhere for doing this?

My mod (which rewrote most of the default raw files) is from years ago, and now I see that the current DF has a different resource structure...

Telgin

  • Bay Watcher
  • Professional Programmer
    • View Profile
Re: How to "refactor" a mod from old DF to new DF?
« Reply #1 on: February 13, 2024, 10:18:11 pm »

I don't think there are any specific guides for that, but the overall raws work almost identically to before so you probably won't have that much work to do.

I think it should mostly be a matter of moving your mod raws into a mod folder under your mods directory, adding an info text file to describe it to the game, and add [CUT] tags for creatures, entities, and so on that you're replacing instead of just adding.

So, most mods from older versions of the game would need to be moved to something like

[dwarf fortress path]/mods/your_mod/objects

And add this file:

[dwarf fortress path]/mods/your_mod/info.txt

with contents like this:

Code: [Select]
[ID:reptilian_kobolds]
[NUMERIC_VERSION:105]
[DISPLAYED_VERSION:1.0.5]
[EARLIEST_COMPATIBLE_NUMERIC_VERSION:105]
[EARLIEST_COMPATIBLE_DISPLAYED_VERSION:1.0.5]
[AUTHOR:Telgin]
[NAME:Reptilian Kobolds]
[DESCRIPTION:Replaces the vanilla kobolds with playable reptilian, civilized kobolds.]

Then try firing up the testing arena with the mod enabled and see what breaks.

One source of frustration and complication comes from the fact that once a mod is used, it gets copied to [dwarf fortress path]/data/installed_mods/[your_mod], and you need to edit that to reflect changes to the game.  Just copy those back to the original directory to package it for distribution.
Logged
Through pain, I find wisdom.

DPh Kraken

  • Bay Watcher
  • [PRONOUNS:it:its:itself]
    • View Profile
Re: How to "refactor" a mod from old DF to new DF?
« Reply #2 on: February 15, 2024, 05:56:26 pm »

If you know what your edits are, you can use the [SELECT_x] tokens to add new tags to existing entries rather than writing them from the ground up.
You can use that token to add, plus [APPLY_CURRENT_CREATURE_VARIATION] to remove tags from creatures while maintaining compatibility.
Logged
[CHEESE_PLANT] and [CHEESE_GRAPHICS] biggest fan
I make mods! http://www.bay12forums.com/smf/index.php?topic=181821.0

Button

  • Bay Watcher
  • Plants Specialist
    • View Profile
Re: How to "refactor" a mod from old DF to new DF?
« Reply #3 on: February 18, 2024, 03:08:37 pm »

If you edited creature variations or material templates, you've got a fair bit more work cut out for you. Vanilla creature variations and material templates can't be edited or replaced using the new modding paradigm.

For creature variations, you'll need to create new creature variations containing your changes, and apply them individually to each creature you're modifying. So for example if you had changed the GIANT creature variation to make all giant creatures TRAINABLE_WAR and also remove the MEANDERER tag, you'll need to make your patch file something like this:

Code: [Select]
c_variation_valikdu

[OBJECT:CREATURE_VARIATION]

[CREATURE_VARIATION:VALIKDU_GIANT]
[CV_NEW_TAG:TRAINABLE_WAR]
[CV_REMOVE_TAG:MEANDERER]

[SELECT_CREATURE:GIANT_TOAD]
[APPLY_CREATURE_VARIATION:VALIKDU_GIANT]

[SELECT_CREATURE:GIANT_BLUEJAY]
[APPLY_CREATURE_VARIATION:VALIKDU_GIANT]

[SELECT_CREATURE:GIANT_CARDINAL]
[APPLY_CREATURE_VARIATION:VALIKDU_GIANT]

and so on for every giant creature in the game.

Material templates are a little harder because there's no system for applying changes to the things that use them. For example, I used to add [REACTION_CLASS:AM_FRUIT] to the fruit material template, and used that as a shorthand for various reactions involving fruit. If I wanted to do that now I'd need to make a copy of the fruit template, add that line in, and then cut-and-replace every plant that used the FRUIT template to now use FRUIT_COPY instead. (I decided it wasn't worth it and have put off porting those reactions.)
Logged
I used to work on Modest Mod and Plant Fixes.

Always assume I'm not seriously back

FantasticDorf

  • Bay Watcher
    • View Profile
Re: How to "refactor" a mod from old DF to new DF?
« Reply #4 on: March 21, 2024, 04:45:08 pm »

Anything else like learning graphics or DFhack, id refer to Boltgun's and Topples's DFhack mods for reference in practice.

The old DFhack methodology is changed compared to 47.05 (old mods for pre 50. are recommended to have versions made for them, either downloaded as a package or dragging the correct DFhack resource into the root DF file from the DFhack github and not using the steam DFhack), and creating shiny graphics often requires a little bit more legwork if you can do the art on your own for graphic mode alongside setting up the coding to make it all snap together.

Jumping onto the DFhack discord would put you in the right place to learn about which scripts have survived (ones like -createunit no longer work due to data changing)
Logged