General Compatibility Patch
Posted: Sun Apr 10, 2016 1:57 am
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.
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.