Creating a Mod

From King Arthur's Gold Wiki
Jump to: navigation, search

Adding the Mod to the Loader

Creating mods in 1.0 is fairly simple; just add your mod directory to the Mods/ subdirectory in your KAG directory, and then edit the DefaultMods.as file. For example, if you had a Mod called "herobrine", you would just place it in the following directory:

KAG/Mods/herobrine/

Then, you'd go into /mods.cfg, and add this:

herobrine

This would load your mod whenever KAG loads. (Make sure to separate multiple mods with linebreaks)

Never, ever put files in the Base/ folder. Always put them in your mod in the Mods/ folder. The Base/ folder is erased and reloaded during upgrades, so anything you place in here will get nuked on an upgrade.

What Happens When a Mod is Loaded

When a mod is loaded with AddMod, KAG will automatically add all of your files to the front of the auto-file-loading engine that KAG uses to load the scripts in Base/. This means that your mod's scripts will *replace* any scripts with the same relative path in Base. For example, if I were to make a file in my herobrine mod at this location:

KAG/Mods/herobrine/Entities/Characters/Archer/ArcherCommon.as

Then KAG would not load the Base/Entities/Characters/Archer/ArcherCommon.as file, and instead load mine. So I'd need to make sure that my modded file contains all that file used to have plus my modifications, so I didn't break functionality.

Resolving Conflicts

Since the above method can obviously cause conflicts when two mods override the same file (the last loaded mod will take preference), it is recommended to not override files if possible, but rather just create new Entities, Rules, gamemodes, etc. That way you can plug-and-play them in, rather than modifying the existing base sets.