What would make the game easier to mod?

Started by Tynan, June 10, 2016, 04:01:27 PM

Previous topic - Next topic

etoire

An Object Testing Arena similar to the one in Dwarf Fortress to quickly get into a world to test a mod.

skullywag

read the readme that comes with the game, game in devmode when testing mods and use the -quicktest (or whatever it is now) command line parameter on the games shortcut.
Skullywag modded to death.
I'd never met an iterator I liked....until Zhentar saved me.
Why Unity5, WHY do you forsake me?

System.Linq

I will sacrifice my firstborn to get Tynan to stop marking things private and forcing me to reflect them.

GiantSpaceHamster

#168
Quote from: Psychology on December 24, 2016, 02:13:16 PM
I will sacrifice my firstborn to get Tynan to stop marking things private and forcing me to reflect them.

Hah, I feel your pain! A number of times I have run across a static method and thought "yesss! it's static, i can send it all the necessary params!" and then realized it was private and had to copy the whole method. I suppose I could have used reflection...but that doesn't seem like any less of a hack than copying the logic.

Also, composability is an issue. There are a LOT of methods that do too much where I would really love to have a helper method that does part of whatever the logic is so I can use just that. This has also caused me to copy methods, ripping out for example one if statement that separates two cases. A great example here is drawing the mood bars in the colonist sheet. It draws the mood bar and the label all at once. It would be really helpful if this kind of thing was multiple methods.

System.Linq

It's called an accessor method, Tynan! You can keep your precious private values AND make them accessible to other methods.

Also, it would be nice if there was some documentation on how to use the various Rand methods. Rand.MTBEventOccurs() is kind of baffling.

Quote from: GiantSpaceHamster on December 27, 2016, 04:58:07 PM
I suppose I could have used reflection...but that doesn't seem like any less of a hack than copying the logic.
Reflection in general is a standard that increases compatibility with other mods. You don't want to touch anything you don't have to, and reflection is just looking.

zlj

#170
Hi,

i'm pretty sure i and like half the people that (try to) make mods for Rimworld have already requested repeatedly. Kindly make all variables and methods public! If you want to make the game easier to mod!

I just stumbled over your most recent questionable use of the above in the GenFilePaths class. ModsConfigFilePath is public, its required ConfigFolderPath on the other hand is private, as is FolderUnderSaveData which is used by ConfigFolderPath. And finally you have SaveDataFolderPath, used by FolderUnderSaveData, which is again public. Now kindly explain to me what sense does that make?

Also, it wouldn't hurt to implement a generic Mod Options Tab/Menu (similar to what CCL had with its ModConfigurationMenu), so that people that want to make configurable mods don't have to interfere with/reflect general game option tabs.

Thanks

regards

zlj


GiantSpaceHamster

When I attempt to put the .pdb file that has the debug info for my mod's dll into my mod's assembly folder Rimworld crashes on startup. It would be great if I was able to hook in to debug so I can use a profiler to see where the performance problems in my mod are.

System.Linq

So pawn.Faction is public, but pawn.factionInt is protected? But they are both Faction objects? What is the difference between them? Why does factionInt have to be protected, especially when you use both in the same method?

GiantSpaceHamster

Quote from: Psychology on December 31, 2016, 10:21:49 PM
So pawn.Faction is public, but pawn.factionInt is protected? But they are both Faction objects? What is the difference between them? Why does factionInt have to be protected, especially when you use both in the same method?

This is a perfect opportunity for a bit of a design/C# lesson. Pawn.Faction is a getter for Pawn.factionInt. It's a way to expose the ability to retrieve the value of factionInt without exposing the ability to change the value. If you look at the code for Pawn.Faction, there is only a getter declared ("get"), no setter ("set"). This also provides the ability to change how the faction is defined without changing the API. If factionInt was renamed or turned into a calculation the value could still be exposed with the Faction accessor and mods using it would not need to change their code.

This is proper design.

System.Linq

Quote from: GiantSpaceHamster on January 01, 2017, 08:12:39 PM
Quote from: Psychology on December 31, 2016, 10:21:49 PM
So pawn.Faction is public, but pawn.factionInt is protected? But they are both Faction objects? What is the difference between them? Why does factionInt have to be protected, especially when you use both in the same method?

This is a perfect opportunity for a bit of a design/C# lesson. Pawn.Faction is a getter for Pawn.factionInt. It's a way to expose the ability to retrieve the value of factionInt without exposing the ability to change the value. If you look at the code for Pawn.Faction, there is only a getter declared ("get"), no setter ("set"). This also provides the ability to change how the faction is defined without changing the API. If factionInt was renamed or turned into a calculation the value could still be exposed with the Faction accessor and mods using it would not need to change their code.

This is proper design.

No, it's not, because you then proceed to use pawn.factionInt instead of pawn.Faction. If you make a getter, use it to get!! I'm well aware of accessor/mutator methods. The problem is the lack of consistency.

On that note, why is every Recipe class public except for Recipe_RemoveBodyPart?!

Hydromancerx

This sounds kinda of obvious but maybe less game breaking updates? I know its alpha but it seems kinda of odd that each update breaks all the mods. I have seen other games in alpha that don't break all their mods each version update.

jjcm04

#176
I know that some of this may be obvious, but having a detailed API for anyone with little to no programming experience, also maybe us JSON? Starbound uses it and its relativly easy to mod the game as well as patch (update vanilla files) without a dirty copy (just replacing vanilla files. This would also ensure that the vanilla files stay safe and avoid unnecessary errors. I know this may involve redoing parts, but you did ask what would make the game easier to mod, also with Unity, not sure if you can use JSON.

Fluffy (l2032)

Guys, this is turning into a debate on coding standards. We should keep this to small(ish) things that are easy to do for Tynan. For example, asking Tynan to switch to JSON is pretty ludicrous, it's not gonna happen at this stage.

Also, for the accessor/private field access being used intermittently, we might just be seeing compiler optimizations. Not sure that's the case here, but it's entirely possible simple getters are being inlined.

jjcm04

Quote from: Fluffy (l2032) on January 06, 2017, 12:43:46 PM
For example, asking Tynan to switch to JSON is pretty ludicrous, it's not gonna happen at this stage.

We are technically still in Alpha... He did ask what would make modding easier, so I just gave my 0.02 cents that is all.

System.Linq

First of all, hediffs are a glorious, incredibly effective modding tool. I love them. A customizable, class-linked property that can be placed on pawns at my discretion without conflicting with any other mods? Hell to the yes, what a great feature. However, AFAIK there's no easy way to add HediffGiverSets to vanilla races without overwriting the core XML. Using HugsLib, I can just grab the list of ThingDefs with OrganicStandard and add my own custom givers to the set, but it would be great if there were a way to do it with XML, like with ThinkTrees.