Jump to content

New Automation Logic


Recommended Posts

I recently made a new object mod on the Steam Workshop and after playing with it for a bit decided it would be better if it had its own automation output instead of one of the preset ones. I have yet to find any modding documentation for this game, and I am used to having an API to work with for programming.

If anyone knows of any documentation for this game that would help me with creating a new type of automation logic, or if anyone knows how to do this, some advice would be appreciated.

Link to comment
Share on other sites

Unfortunately their isn't any documentation yet. At least I haven't heard of any. Luckily there is already a lot of examples out there and most is open-source, so GitHub is a good reference.

For your particular question, it's not very difficult. Although I would need to know what you are working with to help you. Primarily I am confused with "preset ones [automation output]". I wouldn't know that would be a thing, unless we are talking about an existing building, but that is in contradiction to "new object mod".

Maybe you can be a bit more specific. What's your mod called?

 

Link to comment
Share on other sites

On 12/28/2019 at 6:43 PM, Candide said:

Unfortunately their isn't any documentation yet. At least I haven't heard of any. Luckily there is already a lot of examples out there and most is open-source, so GitHub is a good reference.

For your particular question, it's not very difficult. Although I would need to know what you are working with to help you. Primarily I am confused with "preset ones [automation output]". I wouldn't know that would be a thing, unless we are talking about an existing building, but that is in contradiction to "new object mod".

Maybe you can be a bit more specific. What's your mod called?

 

I'll have to see if I can find some of those examples. When I try looking up modding examples or tutorials, I just find links to Steam workshop mods instead unfortunately, I wasn't specifically searching for GitHub though.

What I meant by preset automation logic is stuff already in the game.

My currently uploaded mod is called "Cold Storage Container" and my hopes for the automation is to have it send a green signal based on the warmest item in the storage.

Link to comment
Share on other sites

You need to get a decompiler like ILSpy and decompile the core game. You can also decompile other mods, or search git hub to find the original source of those mods. Decompiling is the most dependible method, but sometimes original sources are a little bit higher quality.

Link to comment
Share on other sites

You find quite a lot when you search for the game's name on Github. These were very useful in my work:

https://github.com/javisar/ONI-Modloader-Mods

https://github.com/Cairath/ONI-Mods

https://github.com/peterhaneve/ONIMods

 

If you already have a logic port, all you need to do is use the SendSignal function to change the output to either 0 or 1. For example I do that here: https://github.com/Truinto/ONI-Modloader-SimpleMods/blob/89320ef334e8201505ca844b9ae809e9b18031e5/src/CustomizeBuildings/Reservoir.cs#L169

If you are missing this component, you need to add it during the "Config" phase and then later get it with the various GetComponent functions of the GameObject. If you don't get it to work, let me see the source code. Shouldn't be too difficult :)

Link to comment
Share on other sites

On 1/7/2020 at 4:14 AM, Candide said:

You find quite a lot when you search for the game's name on Github. These were very useful in my work:

https://github.com/javisar/ONI-Modloader-Mods

https://github.com/Cairath/ONI-Mods

https://github.com/peterhaneve/ONIMods

 

If you already have a logic port, all you need to do is use the SendSignal function to change the output to either 0 or 1. For example I do that here: https://github.com/Truinto/ONI-Modloader-SimpleMods/blob/89320ef334e8201505ca844b9ae809e9b18031e5/src/CustomizeBuildings/Reservoir.cs#L169

If you are missing this component, you need to add it during the "Config" phase and then later get it with the various GetComponent functions of the GameObject. If you don't get it to work, let me see the source code. Shouldn't be too difficult :)

Thanks for the information. I think something that would really help me a lot is a way to debug my code, or error logs that give me more than "Assert failed" when the mod load fails, so that I can learn from trial and error without just making random guesses as to what the error is. The Better Mod Load Logs mod doesn't seem to work, even though it was supposedly updated for the current version of the game. Do you know of any other way to debug a failing mod?

Link to comment
Share on other sites

I always was able to debug my mods. My most common issue is having the wrong Harmony properties, causing it to not load the mod at all. Like if a original method is overloaded, you need to specify which to patch. If you don't it just doesn't load at all.

My way of debugging is commenting out code until it doesn't crash. Then work from there. It also helps putting in Debug.Log("Hello World") to check what parts of code get executed before it crashes or whenever or not certain methods get called at all.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...