Modding Tutorials

Discuss modding questions and implementation details.
Post Reply
User avatar
Hazelnut
Posts: 3015
Joined: Sat Aug 26, 2017 2:46 pm
Contact:

Re: Modding Tutorials

Post by Hazelnut »

Seems a very reasonable policy, I didn't mean to imply everything should be easily moddable. However it would still be nice to be able to extend core classes to add new behaviours. Is that possible with the c# scripting facility for mods? Can you at least implement an interface from the DFU codebase?

Basically I'm trying to think how modders could add new guilds. I will need to write the hooks/events etc, that's fine as long as the guild behaviour class can be implemented by modders either by abstract class extension or interface implementation.

This may be a stupid question due to c# runtime assemblies or that kind of thing since I know almost nothing about them. (remember I'm a Java guy :geek: )
See my mod code for examples of how to change various aspects of DFU: https://github.com/ajrb/dfunity-mods

User avatar
Interkarma
Posts: 7236
Joined: Sun Mar 22, 2015 1:51 am

Re: Modding Tutorials

Post by Interkarma »

I believe it should be possible for the MCS compiler to inherit from an abstract class and plug itself in if given a way to register itself. Nystul's enhanced terrain does something just like this by implementing and registering its own TerrainSampler as part of the mod. The core DaggerfallUnity class allows for a plug-in replacement TerrainSampler to be injected by an event. Load order of mods will determine which new TerrainSampler "wins" as only one can be active in this case.

Adding new guilds this way is a really intriguing concept!

One of biggest limitations is compiling new enums with the runtime C# compiler. Provided modder can just override and plug-in like the TerrainSampler model, they should be able to get a lot done.

User avatar
Hazelnut
Posts: 3015
Joined: Sat Aug 26, 2017 2:46 pm
Contact:

Re: Modding Tutorials

Post by Hazelnut »

Great, I'm off to peruse Nystul's distant terrain mod code then... :arrow:
See my mod code for examples of how to change various aspects of DFU: https://github.com/ajrb/dfunity-mods

User avatar
Nystul
Posts: 1501
Joined: Mon Mar 23, 2015 8:31 am

Re: Modding Tutorials

Post by Nystul »


User avatar
Hazelnut
Posts: 3015
Joined: Sat Aug 26, 2017 2:46 pm
Contact:

Re: Modding Tutorials

Post by Hazelnut »

I tried to create a mod with a json file in it (Assets/StreamingAssets/WorldData/RESIAM10.RMB-543-building10.json) to test I can include world data override json files in a mod. Unfortunately I get this error "Unrecognized assets cannot be included in AssetBundles" and I have no idea what I can do about it. One possibility is simply have these files as loose files that need installing along with the dfmod file.

Any advice modding experts?
See my mod code for examples of how to change various aspects of DFU: https://github.com/ajrb/dfunity-mods

User avatar
Interkarma
Posts: 7236
Joined: Sun Mar 22, 2015 1:51 am

Re: Modding Tutorials

Post by Interkarma »

Probably need to make it a .json.txt file and that should allow it in the asset bundle. Or just a straight .txt file should do the trick too.

User avatar
Hazelnut
Posts: 3015
Joined: Sat Aug 26, 2017 2:46 pm
Contact:

Re: Modding Tutorials

Post by Hazelnut »

This page implies to me that json extension should be supported. https://docs.unity3d.com/560/Documentat ... Asset.html

I'll try changing to .txt tonight in case it does work.
See my mod code for examples of how to change various aspects of DFU: https://github.com/ajrb/dfunity-mods

Skipper
Posts: 14
Joined: Fri Mar 02, 2018 9:06 pm

Re: Modding Tutorials

Post by Skipper »

Is there any way to make a list of all assets and calculate how many times each one is used? It could help to decide what stuff to remake in the first place. Because who wants to spend time on stuff that is rarely seen in the game?

Al-Khwarizmi
Posts: 177
Joined: Sun Mar 22, 2015 9:52 am

Re: Modding Tutorials

Post by Al-Khwarizmi »

Skipper wrote:Is there any way to make a list of all assets and calculate how many times each one is used? It could help to decide what stuff to remake in the first place. Because who wants to spend time on stuff that is rarely seen in the game?
Perfectionists :)

But what you say makes sense, anyway.

User avatar
Hazelnut
Posts: 3015
Joined: Sat Aug 26, 2017 2:46 pm
Contact:

Re: Modding Tutorials

Post by Hazelnut »

LypyL wrote: Known Issues

enums - scripts with enum types defined will fail to compile. You can still use any of the enum types already in the project. This is an issue with the mcs compiler.

generic functions / classes - similar to the above, due to an issue with the compiler scripts that try to define generic functions will not compile.

Unity Versions - mods created in newer versions of unity might not be compatible with older versions of unity. This is noticeable if the mod is in the mod directory, but doesn't show up in the list of mods.
No idea if this is somewhere later in the thread, but we really need to update this list of known issues with this one:

Type.GetType() - You can't get the type of a class added in a mod from a class outside the mod i.e. DFU core. You have to register the type from the mod code and use that Type instance.

I spent ages trying to figure out why code would work in debug but not when packaged into a modfile.
See my mod code for examples of how to change various aspects of DFU: https://github.com/ajrb/dfunity-mods

Post Reply