General Compatibility Patch

Looking for a mod? Have a review on a mod you'd like to share?
Post Reply
User avatar
MrGrim
Fast Inserter
Fast Inserter
Posts: 231
Joined: Sat Apr 09, 2016 7:58 pm
Contact:

General Compatibility Patch

Post by MrGrim »

Hello,

I was attempting to combine Treefarm Lite with the mod "Magnets, Motors, Transformers, and More!" which adds a 10% chance to mine Resin from trees, but I learned that both mods had issues working together. After delving into the Treefarm code I learned that the output of a tree farm is not actually related to the minable output of the trees a farm grows so I could farm trees all day but never actually get any of the new Resin from that mod.

It seems the output of harvesting a tree is the result of the field "output" in the table "global.tf.seedPrototypes.<treeType>". I found this perplexing, and I couldn't find a reason why this was so. If anybody knows why it was done this way please let me know!

However, since I couldn't find such a reason I rewrote the harvesting function to base the output on the mature trees minable properties in its prototype. For vanilla this doesn't change the behavior at all. I also double checked the prototype definitions for mature trees in DyTech just to make sure this change wouldn't break the special trees it has, and it doesn't seem like it will.

This will, however, fix any mods that are not written with TreeFarm in mind that add resources to the games tree types. On the down side, it adds a failure case. It cannot handle mining more resource types from a mature tree than the farm has result inventory slots. I upped the result inventory slots to 4 to help prevent issues if mods add several possible items to tree mining. If, however, the amount of minable item types mined exceeds the number of output slots the script will immediately error out.

Let me know what you think.
Attachments
Treefarm-Lite_0.3.6.diff.gz
(928 Bytes) Downloaded 123 times

User avatar
Blu3wolf
Fast Inserter
Fast Inserter
Posts: 202
Joined: Thu Apr 09, 2015 5:20 am
Contact:

Re: General Compatibility Patch

Post by Blu3wolf »

An interesting idea. There was no issue with adding inventory slots to the treefarms? I was under the impression furnaces needed a specific number of inventory slots. Also, did you apply this change to the mk2 fields as well?

User avatar
Ralord89
Inserter
Inserter
Posts: 26
Joined: Sat Jul 25, 2015 6:06 am
Contact:

Re: General Compatibility Patch

Post by Ralord89 »

So where do we put this to make it work?

User avatar
MrGrim
Fast Inserter
Fast Inserter
Posts: 231
Joined: Sat Apr 09, 2016 7:58 pm
Contact:

Re: General Compatibility Patch

Post by MrGrim »

Blu3wolf wrote:An interesting idea. There was no issue with adding inventory slots to the treefarms? I was under the impression furnaces needed a specific number of inventory slots. Also, did you apply this change to the mk2 fields as well?
I'm still pretty new to modding this game so I was unaware of any potential problems with upping the result inventory slots. It seems to work OK with my limited testing thus far.

As for the mk2 fields, I haven't gotten to them yet. However, if I understand them correctly they work by marking the mature trees for deconstruction by logistics bots. I think in that case the tree objects mineable properties will be respected. This does need to be verified, and I'll attempt to do so probably this weekend.
Ralord89 wrote:So where do we put this to make it work?
This file is a unified diff designed to be used to modify an existing file. On unix based systems the "patch" command does this. I'm not sure what software is available for Windows platforms. Maybe somebody else can assist?

Alternatively, you can try manually applying the changes in the diff file.

Post Reply

Return to “Questions, reviews and ratings”