Jump to content

Dll editing


actionxboy

Recommended Posts

Hi! This doesn't really fit anywhere else, so I put it here. I'm trying to create and code something, but I can't edit a .dll or even open one in the original code it was written in. Is anyone able to help with that?

Thanks!

-action

Link to comment
Share on other sites

Perhaps you're thinking of modifying an existing DLL? In that case I've moved this to the add-ons section but HebaruSan is correct, you'll find it much easier with the source code to make any modifications, unless you're good with a hex editor and know exactly what values you'd need to change.

Link to comment
Share on other sites

Visual Studio Community Edition is available for free from Microsoft. Fully fledged dev environments like that can feel extremely intimidating at first, what with their sheer mass of features not immediately relevant to you and their tendency to treat you like you have perfect knowledge of what's going on (you won't have a clue), but using the provided tutorials I found it surprisingly easy to settle into. If you want to get into programming in C#, it's hard to find a better start IMHO.

As for how to code - well, the internet is chock full of C# tutorials. Do the ones on the Visual Studio download page (you'll need them to grok VS itself anyway), then google up some more and do them too, then look at the source code of an existing mod to see if you can get at least the basic gist of what it's doing. Then you can see about tweaking it.

Edited by Streetwind
Link to comment
Share on other sites

4 minutes ago, Benjamin Kerman said:

Do you write them, or are they autogenerated?

(Trying to get into modding myself...)

You write C# code (plus accompanying project data), and then you run a program called a compiler, which reads your code and creates a DLL for you based on it. Here's an example C# file from my mod to give you a sense of what it looks like:

In combination with other C# files and this project file:

... the C# compiler generates a DLL that implements the logic of the mod (anything other than part shapes, sounds, and graphics).

Link to comment
Share on other sites

7 hours ago, Benjamin Kerman said:

The .dll files tell the game what to do with the .mu files?

 

7 hours ago, Benjamin Kerman said:

Do you write them, or are they autogenerated? 

(Trying to get into modding myself...) 

You're basically asking about the difference between "asset modding",  "config modding", and "plugin modding".

If you do config modding, you're writing a .cfg file. Either a completely new one, or a Module Manager patch. Config files are used in many areas of the game to define content. For example, if you want to add a new part, or a new resource, or a new contract type, or a new strategy, or even a custom tech tree - you can do so with a config file. This file also points the game towards various assets where required.

An asset is something that's required to show the player what's going on. It could be the model of a part - that's the .mu file. It could be the texture that's applied to the part's model to give it its final look and surface detail - that's usually a .dds file. It could also be a soundbit, such as the startup and/or running noise of an engine. It could even be a song to add to the ingame playlist (though that's actually pretty complicated to pull off). When you do asset modding, you're an artist. You create things that config files need to do their job.

The same is also often true for plugin modding. Whereas the above two add content and assets, plugin modding adds game mechanics. For example: creating a new engine part requires a config file, and a model, and a texture, and usually even a sound and an exhaust effect. With that, you can make any chemical or nuclear or ion engine you want, because the game already knows how those are supposed to work. But what if you want that engine to be an Alcubierre FTL drive? That's something that stock KSP doesn't know how to do. For this, you must write yourself a plugin (a .dll file). The plugin usually defines a new PartModule that you then add to the config file, so the part actually implements that functionality, and adds a relevant button to its rightclick menu. Then when you press the button ingame, the PartModule in the config calls the plugin and the C# code in the plugin is executed. In this example, it would suspend the physics simulation and move the ship forward at lightspeed in the direction it is currently facing, up until you either run out of propellant (Ec or whatever else you defined it should need) or the button is pressed again.

Most of the time, config files and assets survive many KSP version updates without any need for updates. On the other hand, plugins generally require at least a recompile, and sometimes even code changes, everytime KSP updates.

 

The TL;DR is therefore: anytime you want to do something that stock KSP already supports doing, you write a config file and perhaps create some assets. Anytime you want to do something that stock KSP doesn't support doing, you write a plugin that takes over the support... and then you write a config and perhaps create some assets.

Link to comment
Share on other sites

On 3/15/2017 at 4:03 PM, HebaruSan said:

"Editing" is not something one is intended to do with DLL files. Rather, they're built from source files using a compiler, generally C# files in the case of KSP mods.

What exactly are you trying to accomplish?

 

On 3/15/2017 at 4:23 PM, sal_vager said:

Perhaps you're thinking of modifying an existing DLL? In that case I've moved this to the add-ons section but HebaruSan is correct, you'll find it much easier with the source code to make any modifications, unless you're good with a hex editor and know exactly what values you'd need to change.

Sorry for not replying sooner; I had robotics all week. I'm trying to read the original source code of it before the DLL was compiled so I can modify it a bit and make a copy of that.

-action

Link to comment
Share on other sites

12 minutes ago, actionxboy said:

 

Sorry for not replying sooner; I had robotics all week. I'm trying to read the original source code of it before the DLL was compiled so I can modify it a bit and make a copy of that.

-action

You need to download the source code of the mod you want to tinker with. You cannot access it from the dll.  

dlls are not like zip folder that you can just open. 

And, writing plugins requires knowledge in Unity and KSPs API. It's a lot to learn. I'm telling you this so you won't be discouraged when you look at the source and it looks like a foreign language.  

I assume you don't have much experience with visual studio or Unity since you are asking this question, so, if you want to do this, be ready  and willing to learn a whole lot. 

Edited by Galileo
Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...