Author
Topic: [WIP] C# (Edit) (Read 1199 times)

Big shout out to Justyn! He has helped me with almost all of this project that I am working on.

I am working on a project that adds a sound effect to the game when a button is pressed. I got all the way up to the point to where you add the references, and you're supposed to add all the .dll files from the Total Miner directory. For some reason it doesn't let me add all of the .dlls, I get an error. Can someone help me out? What am I doing wrong?

It's probably better to just copy the dll's from total miner directly to your bin folder and reference the dll's from there, or create a sub folder in your project, named Libs or something, and copy the dll's into there and reference them from there.

I've tried adding all the .dlls from Total Miner directory to the references, almost all work, but CSteamworks, DSETUP, dsetup32, and steam_api wont load into the references. Also, where can I get the Total Miner plugins? That might contribute greatly to my problem

You don't need to add steamworks, dsetup etc, you only need to add whichever StudioForge, Microsoft.Xna and System assemblies your code will actually reference. See some of the examples here: https://github.com/cmartin99/TotalMinerMods

I typed this up a while ago as a reminder to myself on how to do a mod. I briefly read through it and I believe it is still correct.

Spoiler for Hidden Content:

1) Install XNA Game Studio in Visual Studio 2017 follow this tutorial: http://totalminerforums.net/index.php?topic=19324.02) Open Visual studio and create a new project for XNA Game Studio – Windows Game Library(4.0) with your mod name for the name ex: TM_ExampleMod.3) In the Solution Explorer right click on References select add reference4) Click Browse and navigate to your Total Miner steam Directory (C:\Program Files (x86)\Steam\steamapps\common\Total Miner)5) Select all the .dll files and click add, or add 1 at a time, currently there are 7 in total: StudioForge.Engine.Core.dll, StudioForge.Engine.GUI.dll, StudioForge.Engine.Services.dll, StudioForge.Engine.Integration.dll, StudioForge.Engine.Game.dll, StudioForge.BlockWorld.dll, StudioForge.TotalMiner.API.dll 6) After adding them select the ones you need with check marks and click ok7) Rename the default class1.cs file to the mod name TM_ExampleMod1.cs by right clicking on it and choosing rename.8 ) Open the cs file for editing 9) At the top add using StudioForge.TotalMiner.API; using StudioForge.TotalMiner;10) change the class name to match your mod name and make it extend ITMPlugin public class Class1 to public class TM_ExampleMod1 : ITMPlugin11) Add the required interfaces to the class: public void WorldSaved(int version){} public void PlayerJoined(ITMPlayer player){} public void PlayerLeft(ITMPlayer player){} public void Initialize(ITMPluginManager manager, string path){} public void InitializeGame(ITMGame game){} public bool HandleInput(ITMPlayer player){return false;} public void Update(ITMPlayer player){} public void Update(){} public void Draw(ITMPlayer player, ITMPlayer virtualPlayer){}12) In solution explorer right click on your mod name not the solution name and choose add new item13) find Code File C# highlight it and click add14) Rename it to TMPluginProvider.cs note: this is the required name 15) open the file for editing with required code and implement required interfaces: using StudioForge.TotalMiner.API;