Modding:C Sharp Scripting: Difference between revisions

Jump to navigation Jump to search
Added info about the mods.json generator
No edit summary
(Added info about the mods.json generator)
Line 34: Line 34:
# Open Visual Studio, then open the csproj file a ~/Qud_Code/Assembly-CSharp.csproj
# Open Visual Studio, then open the csproj file a ~/Qud_Code/Assembly-CSharp.csproj


'''Modding Using Visual Studio Code (Quick Setup)'''


'''Modding Using Visual Studio'''
Follow these steps in order to get Visual Studio Code to correctly parse and include the base game methods in Intellisense and similar tools (assuming you have the C# VSCode Extension):
 
# On the Caves of Qud main menu, with Mouse Overlay UI toggled on, go to "Modding Utilities" and select "Generate JSON". This will automatically create a JSON file describing the setup needed that VSCode can read.
#Find the Mods.json file in your CoQ Saves folder.
#Move it to your main modding directory you intend to work from. It is not recommended that this be a mod folder itself, as that will include both this JSON and additional VSCode generated files in the mod itself - it is a better idea to keep mods in their own folders and place the JSON and other exterior files into a parent folder. If you want to keep your Mods folder tidy, you can create your individual Mod folder elsewhere and then create a hardlink/junction to that folder inside of the Mods folder.
#Open VSCode in the folder that contains the Mods.json, you should now be able to reverence Qud namespaces, classes and methods from your own code. As this just links directly to the DLL's, however, you will only get metadata information about those classes and such, which tends to include function signatures, variable names and similar, but not the actual code within those functions. You can look at the actual code using a decompiler as mentioned above, or if you want your code to directly reference the decompiled code follow the optional step 5.
#(Optional) In order to reference the decompiled code rather than the real DLL's, take save the decompiled code into a folder in the same directory as your mods then, to prevent conflicts, delete the "Assembly-CSharp.dll" line from your Mods.json
 
Note: I sometimes have issues with VSCode or Visual Studio attempting to pull in additional dependencies, which often leads to errors and are not necessary for Qud modding. I do not recommend clicking the "Resolve Dependencies" button if it appears, and if it does you may have to delete the generated ".vs" and "bin" folders in order to get it to work properly again.
 
 
'''Modding Using Visual Studio (Manual Setup)'''


Follow these steps in order to get Visual Studio to correctly parse and include the decompiled code while you are writing your mod code (there are other methods, but this is the one I used):
Follow these steps in order to get Visual Studio to correctly parse and include the decompiled code while you are writing your mod code (there are other methods, but this is the one I used):
Line 55: Line 67:
UnityEngine.Debug.LogError()
UnityEngine.Debug.LogError()
</syntaxhighlight>Or by using other standard UnityEngine.Debug methods, as detailed here[https://docs.unity3d.com/ScriptReference/Debug.html]. Various options for ingame error popups and such can be found in the Debug section of the ingame options.
</syntaxhighlight>Or by using other standard UnityEngine.Debug methods, as detailed here[https://docs.unity3d.com/ScriptReference/Debug.html]. Various options for ingame error popups and such can be found in the Debug section of the ingame options.
Errors that occur during the initial build of the game, when all the dependencies such as mods are pulled in are included in build-log.txt which can be useful to look at if there is no useful information in the player.log.


==Detailed Scripting Topics==
==Detailed Scripting Topics==
Anonymous user

Navigation menu