Custom mod¶
You can find our mod on GitHub, it was a bunch of random trial and error, trying different things like
Placing a mod in the game menu Placing a UI element on the game GUI Accessing the building data and exporting it in JSON format. It was created following the documentation cslmodding, paradoxwikis modding and trying to imitate other available mods on the steam community.
General idea¶
The game modification relies on extending from an interface List of all available interfaces. You can find the initial layout of the script here https://skylines.paradoxwikis.com/Snippets
Prerequisites¶
Before we start writing our script mod, we need to figure out how the game is working. Here we will find modtools is handy to explore the scene elements and see the debugging messages with stacktrace and all.
Create script mod¶
To create a mod you have two options
-
Create a script and let the game compile it to .dll
Following the guide here To get started on your first mod all you have to do is create a folder for your mod in the mods folder. See Folder Structure basically it's located in
%LOCALAPPDATA%\ColossalOrder\Cities_Skylines\Addons\Mods.Create a folder with the name of your mod in there, then create a Source folder within that, and then create a C# file within the Source folder.
It should look like this:
/Mods/YourModName/Source/YourModName.cs. ├─ Mods/ └─ YourModName └─ YourModName.dll ( automatically compiled) └─ Source └─ YourModName.cs -
Create a VS solution that builds the source files into a .dll that places the generated dll into the game , like most of the mods are doing. Create and Configure VS project
Known issues¶
Referencing an external dll, In VS solution when you add reference to a dll it’s not really creating a reference to be executed in the solution, the reference according to VS is just for the sake of IntelliSense and auto complete. So uptell now if you need to use an external dll you can decompile it to its source files then reference those source files into the solution after been encapsulated into a namespace
You can use jetbrains/decompiler or ilspy or dnspy to view the dll source code or fields.