Jump to content

Can I make my own mod?


Recommended Posts

35 minutes ago, iiitttsss said:

@SharraShimada

So how i make my own mod?

You're going to have to wait for a little bit longer.

The devs are currently trying to figure out how to make mods. Mind telling us what you'd like to create a mod for so the devs know what to focus on? 

If you're unable to wait, you can check this out in the meantime:

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

Link to comment
Share on other sites

On 4/9/2019 at 1:44 PM, iiitttsss said:

 

Can I make my own mod?

 

It depends on your knowledge.

If you are a programmer chance is good you can learn it easy enough especially if youre making unity3d games.

If you are not you start there: https://www.tutorialspoint.com/csharp/

If you know c# you start there: https://github.com/javisar/ONI-Modloader

Under creating a Mod.

Then you got to learn Harmony and get to know oni.

This is the tricky part Harmony is bad documented and oni has little direct modding support.

I think if anyone writes a proper tutorial for Harmony he will get MANY likes on the other hand i think its hard to properly make a oni modding manual without having a Harmony tutorial.

Link to comment
Share on other sites

42 minutes ago, Rainbowdesign said:

Then you got to learn Harmony and get to know oni.

This is the tricky part Harmony is bad documented and oni has little direct modding support.

I think if anyone writes a proper tutorial for Harmony he will get MANY likes on the other hand i think its hard to properly make a oni modding manual without having a Harmony tutorial.

While the Harmony documentation isn't great, there is an even bigger issue. Harmony works on a very low level, meaning you encounter problems you wouldn't normally really consider when writing your own code, like what is the internal difference between a method and a property. What happens internally with yield return. It takes a lot of programming theoretical knowledge to fully use Harmony.

 

Looking around in the current mods, it seems that the Harmony usage primary consist of the same structure, which consist of a prefix or postfix, meaning it adds a method call before or after another method. This is likely primary copy paste, which is fine considering that it works. Klei apparently has a tendency to make member variables public, which helps a lot when modding like this. Harmony also has the Transpiler feature, which reads an existing method and allows it to be rewritten. This is awesome because it allows more or less everything to be modded, even stuff not modable by prefix and postfix. The problem with Transpiler is that it requires the code to be written in assembler, or more specifically IL ASM.

 

Example of what it looks like:

Spoiler

// AirConditionerConfig
public override void DoPostConfigureComplete(GameObject go)
{
	GeneratedBuildings.RegisterLogicPorts(go, LogicOperationalController.INPUT_PORTS_0_1);
	go.AddOrGet<LogicOperationalController>();
	go.AddOrGetDef<PoweredActiveController.Def>();
}

The same code in IL ASM


.method public hidebysig virtual 
	instance void DoPostConfigureComplete (
		class [UnityEngine.CoreModule]UnityEngine.GameObject go
	) cil managed 
{
	// Method begins at RVA 0x19c6e2
	// Code size 27 (0x1b)
	.maxstack 8

	IL_0000: nop
	IL_0001: ldarg.1
	IL_0002: ldsfld valuetype LogicPorts/Port[] LogicOperationalController::INPUT_PORTS_0_1
	IL_0007: call void GeneratedBuildings::RegisterLogicPorts(class [UnityEngine.CoreModule]UnityEngine.GameObject, valuetype LogicPorts/Port[])
	IL_000c: ldarg.1
	IL_000d: call !!0 EntityTemplateExtensions::AddOrGet<class LogicOperationalController>(class [UnityEngine.CoreModule]UnityEngine.GameObject)
	IL_0012: pop
	IL_0013: ldarg.1
	IL_0014: call !!0 EntityTemplateExtensions::AddOrGetDef<class PoweredActiveController/Def>(class [UnityEngine.CoreModule]UnityEngine.GameObject)
	IL_0019: pop
	IL_001a: ret
} // end of method AirConditionerConfig::DoPostConfigureComplete

 

To this day I haven't seen a single ONI mod using Transpiler.

 

We do not need a Harmony guide to understand all of Harmony. What we need for ONI modding is Harmony templates meaning people can look up the 2-4 different ways of commonly use Harmony with ONI and then copy paste the setup for it. Anybody who plans to teach all modders all of Harmony will fail hard and we just have to accept that most modders are stuck with a Harmony subset.

 

In fact I think that should be the way to tell modders how to get started. Templates of the commonly used approaches. People need to be able to do something before they can start experimenting and make something of their own.

Link to comment
Share on other sites

3 minutes ago, Nightinggale said:

To this day I haven't seen a single ONI mod using Transpiler.

I urge you to look harder then :p However it's not common because most of the folks aren't programmers.

 

For mod examples in general, my repo is quite big and and reading existing mods code surely can help figuring out how to do stuff: https://github.com/Cairath/ONI-Mods

 

Small changes are usually very easy with harmony. It's got big potential because you can patch the actual code and not just be limited to some certain APIs, but for anything more advanced you *need* some programming knowledge - ;level depending on how complicated stuff you want to do. 

Link to comment
Share on other sites

5 minutes ago, Cairath said:

I urge you to look harder then :p

I stand corrected. Apparently you used Transpiler 3 times, Prefix 48 times and Postfix 98 times. I have to admit my manual search wasn't detailed enough to locate those 2% of your patch calls.

 

For once I'm happy to be wrong. It means I'm not the only one who have tried using Transpiler. However it still doesn't change the conclusion that trying to teach all of Harmony to everybody will fail and that the correct approach is to figure out a subset "good enough to get started".

Link to comment
Share on other sites

@Nightinggale I agree - but I believe it's a good balance between having templates for the non-coding folks to still be able to do some stuff, and give the folks that are enthusiastic to learn coding (or are programmers) the potential to write more advanced stuff. I'm very excited for the release, until now I wasn't sure where harmony would stand when we get mod support but personally I'm 100% pleased and can go ahead nolife some more :p 

Link to comment
Share on other sites

2 hours ago, Nightinggale said:

We do not need a Harmony guide to understand all of Harmony. What we need for ONI modding is Harmony templates meaning people can look up the 2-4 different ways of commonly use Harmony with ONI and then copy paste the setup for it. Anybody who plans to teach all modders all of Harmony will fail hard and we just have to accept that most modders are stuck with a Harmony subset.

Sure copy paste is a start but i did find many features undocumented or little documented and that makes it near to impossible to learn more than copy paste if you use only tutorials. And say copy paste can go only so far there might always be the point where you need to do something that is no where else.

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...