Hello everyone,
I’m new to Infraspace and have recently discovered modding. I’ve already explored JSON modding and now I want to try script modding. Unfortunately, I’m encountering some difficulties, especially with the ismodkit.
To learn and understand it, I wanted to take a look at it, edit it, and test it. The problem is that when I try to open the ismodkit -Salt Mine project in Unity, the Infraspace menu is missing from the Unity toolbar. I could manually create asset bundles myself, but my skills aren’t quite there yet, and time is also a factor.
My question is: is there an official modding toolkit that I could use to learn and work more efficiently? I’m still new to this, but I want to stay involved and contribute some good ideas and mods in the future.
An answer would be greatly appreciated. Best regards, Wiki
Hey @WikiWick, nice to have you here.
One important thing: Unity is only used to create the 3D asset bundles. It has nothing to do with scripts or configs. So that’s why there is no menu in Unity, it doesn’t know anything about the game at all.
For script mods, you have to follow this tutorial: InfraSpace Modding Tutorial: Introduction to Script Mods
Which means compiling the mod into a .dll and then running that with the game.
@BaYoNeTTe is probably the most experienced modder, maybe he has advice if you have more questions. He is also on Discord.
Hi
Okay,
thanks for the information, that helps me a lot.
Best regards, Wiki
Welcome to IS modding
If you have questions, feel free to ask. Modding is a bit more complicated and might require discussing code and explaining things with screenshots, so the forum is a good place. I’m also available on Discord but not very reliably anymore in the near future. Also I’m traveling these days, but in general I’m excited that somebody else is picking up modding for the game.
When it comes mods there are 3 levels of programming involvement:
- No scripting at all
- Create a mod class like in the tutorial and do everything in your own code
- Use patching to modify existing parts of the game
First you need to figure out which type of mod you are going to make. It sounds like you are on level 2 or 3. To be honest, what you can do with level 2 is so limited, that you are almost always directly at level 3. What exactly do you have in mind for your mod?
I did all script modding with Visual Studio 2022 Community Edition and it worked really well for me. Not sure if I would use a different setup these days. For the decompiler I recommend ILSpy which is available as an extension for VS2022. You also need to download the Harmony patching library if you want to do level 3 mods. Get it here. You’ll also want to read the documentation there. If it helps then I can upload the source of one of my mods (but earliest would be around 7th October).
Hello BaYoNeTTe
Thank you for your reply.
I’m still at the beginning of my modding journey. The basics are simple and easy to understand in Infraspace. Adding new buildings, however, is already more complicated. I’ve looked closely at the Salt Mine project, and that’s my next goal. New buildings, new resources, and houses that require these new resources. I’d also like to improve the roads, but that seems difficult. For example: I can adjust the speed of train tracks via the roads.json file, but it doesn’t seem to work for roads; you can’t change the speed via JSON. As I said, I’m still new to this and am working my way through it step by step. A roundabout would be a great feature, but it probably won’t be possible to implement it as a circle. But better roads with highway on-ramps seem feasible. Thanks again, I’ll follow you on Discord.
Now I’ll get to work
Project 1: Create a new production building.
Best regards, Wiki
If you want to add a simple building then you probably don’t even need code. Make sure you use Unity 2021.03.34f1. I think the modding tutorial and maybe the ISModKit may be outdated and still use 2020. You’ll be in for some pain if you try to use 2020. Where do you get the model and texture from? Are you going to create them yourself?
As for the shader, I strongly recommend to use the custom/masked shader that the devs also used for their own assets. If you use the standard shader, some features will not work correctly with your assets, in particular the color tint when a building needs to be dyed blue or red because of selection/collision.
There are probably a couple of other pitfalls that I had to learn about and you’ll encounter as well. Don’t hesitate to ask if there’s a problem.
Thank you for your reply.
I looked at the SaltMine project, disassembled it, analyzed it, and recreated it myself to understand it better. After a lot of hard work and research, I managed to recreate it independently. Regarding your question, @BaYoNeTTe: I will probably create the textures and models myself in Unity, but I’m not yet sure if I only need Unity or if I might also need to use Blender. Unless there’s a resource where I can obtain pre-made textures and models? I think there was a link to such a website in one of the tutorials, wasn’t there?
The important thing is that I can now start my own projects independently of SaltMine, and I understand how to work with buildings in Unity to make them functional, and what settings and connections are necessary. One problem I’ve noticed is with roads and highways. I’ve found that the speed isn’t defined in the JSON file. For trains and tracks, the speed is defined in JSON, but I couldn’t find anything for roads. From what I can tell, working with roads is more complex than with buildings, isn’t it?
@BaYoNeTTe, it would be very nice if you could perhaps share some additional resources with me I can’t say exactly what I need yet, though ^^ hehe
I’m working diligently and am currently creating a completely new building to get more practice.
Thanks and best regards
If you managed to get the salt mine to work with your setup then you’re already on a good path to creating your own mod
I used Blender to create both the models and the textures (plus some basic image manipulation). If you want to do everything with Unity then that’s going to be difficult, if not impossible beyond the most basic geometries. Fortunately there are a lot of great tutorials for Blender on YouTube. A lot of people use separate software to create textures, but I didn’t want to spend that extra learning effort. There are also a lot of models available on the internet. You’ll have to check license information very carefully not to violate anything. Also these models need some adaption probably (size, texture format).
Roads are quite complicated if you want to do anything there. The speeds of roads is as follows (gleaned from source code):
Road | speed |
---|---|
Side road | 20 |
Gravel Road | 30 |
Concrete road | 60 |
Highway | 120 |
Super Highway | 240 |
If you haven’t seen it yet, I’d also like to advertise Modding Reference
These are realized with constants in the C# code. The problem with constants is that they can’t be changed with mods, because they are replaced with literals during compilation of the game. So what you have to do is to use a mod to patch every place where they are used in the original DLLs. Fortunately those places aren’t too many, I believe, but it’s hard to find all of them in the decompiled source.
I saw two specific projects that you want to realize, the roundabout the highway ramps. Both are going to be quite complicated. And to be honest, you don’t really need to create separate new structures for them. Roundabouts can already be created with the existing roads. Just making them circular is tricky. I had the idea of expanding the road construction menu to allow building round roads that behave like train track construction. That would make creating reasonable roundabouts with normal roads a decent task. As for the ramps, what you basically can do with existing tools, for example: create a 4 lane 2 way highway (so 2 lanes per direction). Connect a 1 lane 1 way highway to it as your ramp. From the intersection on, make the main highway 6 lane 2 way. Adapt the intersection settings and you basically have your ramp. The only things that are missing are convenient ways of constructing this and maybe the minimum angle between roads at intersections is too wide.
But don’t let me discourage you. If you have some cool ideas, then try to realize them. I’d recommend making as clear as possible a specification for yourself, so you have a picture of what you’re trying to achieve.
I’ll upload something later. Not in front of my computer for a couple more days. What you can do in the meantime is to subscribe to one of my mods and decompile the DLL to see how the script works. I’m not sure if it’s possible to decompile (or maybe rather „unzip“) the asset files.
846 / 5.000
Hello
Thank you for this detailed answer.
It contains a lot of important information.
Okay, I already figured that creating roads would be quite complex.
That’s a pity, because it requires knowledge that I don’t have. Thanks for this important information.
Okay, that’s not a problem for now, since I’m currently focusing on new buildings and new resources. I’m really enjoying that. I’ll also start using Blender; I still have a lot to learn about it, though but that’s fine. Thank you very much, BaYoNeTTe.
It would also be helpful to know how to add new resources, such as sulfur or iron. I haven’t had time to look into that yet, so maybe you could give me a brief explanation so I don’t have to figure it out all by myself.
Thanks, and it’s good to know that there’s someone here to help.
Best regards, Wiki
P.S. By “new resources” I mean resources that are displayed on the map and can be mined, similar to iron or sulfur. This is something I want to learn to implement in addition to building structures.
Creating a new resource is indeed what I would have requested as a first step anyway, and maybe the research that goes with it. I recommend downloading the Mines and Diamonds mod, because it has examples of that.
I see that you already changed JSON files (JSON patches). Creating the JSON for a new resource is even easier than changing an existing one. Create a resources.json file in your mod folder and add your new resource in there. It uses the same format as from the vanilla IS config files. If you have questions about the meaning of items, ask away. Also you’ll need an icon which you need to add in Unity as an asset.
Then I recommend to change existing buildings to use your resource so you can test it in the game. For example, add it as a product to the sand mine and as an ingredient to the concrete factory.
Creating a new research is even easier because you only need a JSON structure but no icon. It goes into the techs.JSON.
Next, you’ll need localizations. Create localizations.json and add the key value pairs for your resource and tech, e.g.:
{
// techs
"tech_diamondCoatedTools": {
"english": "Diamond Coated Tools"
},
"techDesc_diamondCoatedTools": {
"english": "Cover mining tools with diamonds to increase their hardness. Improves mine yield."
},
"tech_seismology": {
"english": "Seismology"
},
"techDesc_seismology": {
"english": "Helps reveal the extend of underground mineral deposits."
},
// resources
"resource_diamond": {
"english": "Diamond"
},
}
Very good, thank you so much!
Well, then I have quite a bit to do in the coming days.
Thank you for the information; this gives me everything I need to get started on creating new buildings, including defining their resource requirements and consumption, and incorporating them into the research system. That’s great!
I’ll let you know if I encounter any problems I can’t solve.
Creating the model and texture will take some time, so I’ll get started on that now.
Thanks again!
See you soon, Wiki
Good luck with your little project!