Tree Saplings (Redux)


A small mod that adds craftable saplings that grow into vanilla trees, and a way to farm them. Based on the 'Revisited-RevivePatch' version, this one reduces the costs and heavily rewrites the control code to fix a few bugs and reduce overall UPS impact.

Content
1 year, 9 months ago
1.1
3.73K
Mining Manufacturing
Owner:
FuryoftheStars
Source:
N/A
Homepage:
https://forums.factorio.com/viewtopic...
License:
MIT
Created:
2 years ago
Latest Version:
1.0.6 (1 year, 9 months ago)
Factorio version:
1.1
Downloaded by:
3.73K users

Preface note: I’m in the market for a graphic artist to improve/replace the graphics in use with this mod. I’m a coder, not an artist. I’ve done the best I can with scaling existing assets and cropping/merging some images I got online that, imo, is passable, but I’d love to make it better.

This is an update of Tree Saplings (Revisited+RevivePatch), which was an update of Tree Saplings (Revisited), which in turn was an update of Tree Sapling Mod. I’ve fixed several bugs, made significant improvements to UPS, and added several new features.

The basic premise of the mod is to allow growing of trees (and even automate farming them for wood) via craftable saplings.

The whole process starts with petroleum gas and water in a chemical plant to create ammonia. Ammonia is then combined with (more) water to create nitric acid, and then both are combined to create fertilizer. Finally, the fertilizer is combined with wood in an assembler to create your sapling grow bag that you can either plant manually, or place in a planter box to allow it to grow. Saplings manually planted will grow into full grown vanilla trees, at which point you can either leave them for their pollution absorbing properties, or you can harvest them for their wood. Saplings placed in planters will automatically be harvested for their wood as soon as they reach full growth.

And yes, saplings will absorb pollution as they are growing, but they are not as efficient as a full-grown tree. Saying that, I want to make this point: if you're using an automated grow farm, the point behind it is the production of wood. If your goal is pollution absorption, you should manually plant them and then leave the resulting adult trees alone after. Makes sense, yes?

This mod would also pair well with other mods that give a use for wood, like a wood gasification mod, like the Wood to Oil Processing mod.

For users of the Revisited+RevivePatch and Revisited editions, I have included migration code for switching over to this one. When loading this mod in an existing save with one of these other mods for the first time, please leave all settings from this mod at default, load your save, then make a new save before adjusting the settings to your liking. There are a couple of quirks that happen if you adjust the min/max grow times of the saplings too low before migrating.


New features with this edition of the mod

  • Saplings now have 6 growth stages: planted seed, sprout, seedling, sapling, "young" tree, then the adult full-grown tree.
  • Saplings can now die in environments with too much pollution before reaching maturity (determined by existing game mechanics). Manually planted saplings that die will be converted into a dead tree variant, while saplings in planters will just be harvested for however much wood they were worth when they died.
  • Planters can now be removed/destroyed while leaving the sapling in place (I mean, it's just a wooden frame box laying around the sapling...).
  • Saplings now have a couple snap-to-grid options for manual placement (for the OCD among us...). The traditional no snap/off-grid placement option remains and is default, but it now also includes snap to tile center and snap to tile grid (the space between the tiles) options.
  • There is now a new "UPS Friendly" mode that changes planters so that instead of them having actual, separate sapling entities growing in them, they are now just an animation for the planter. This removes all per entity monitoring of the planters in the code, but has the side effects of all the saplings in the planters looking bland and identical, as well as removing the features of saplings dying (in the planters) in heavily polluted areas and being able to remove the planter and leave the sapling behind. Important note: It appears as though with animated entities, if you have a lot of them (and possibly even have to have them near each other), the game will automatically offset the animations from each other. My animations are supposed to be of a sapling growing through all of the stages, starting from when the planter starts to when it finishes, but because of this, the animations will be out of sync with the actual planter progress. I have not found a way to correct this.
  • Made the overall costs of the recipes cheaper, giving a net effect of changing the petroleum gas used to saplings produced ratio from 60:1 (manual planting) and 120:1 (for planters) to 6:1 (for both).

Other differences from previous edition of the mod

  • Sapling grow bags are now used directly for manual planting of saplings. As such, the old sapling item and its related recipe and tech unlock have been removed, and the sapling grow bag is now unlocked with the first tech.
  • Productivity modules no longer affect sapling growth in planters. This doesn’t make sense, anyway.
  • Increased (default) sapling grow times from 1-11 minutes to 14-21 minutes (the equivalent of 2-3 in game days).
  • Decreased sapling pollution absorption rate. The previous edition set them to 18x better than a full-grown vanilla tree. Each stage of the sapling grow process has different pollution absorption rates, but all told it averages out to roughly 31% of a vanilla tree over the life of the sapling.

Settings

  • There are 2 startup settings for controlling the minimum and maximum grow times of the saplings. Decreasing these will increase your wood yield over time from your automated grow yards, while increasing them will allow the same infrastructure to support larger grow yards and allow each sapling to absorb more pollution during its life span.
  • Startup setting for the number of ticks in which to spread updating planters over. Decreasing this will decrease the delay between when a sapling grow bag gets placed into a planter and the sapling actually starts growing, while increasing it will reduce the UPS impact it has on your game.
  • Startup setting for controlling the snap to grid/tile center and no snap placement of saplings behavior.
  • Startup setting for toggling UPS Friendly mode.

Technical improvements

  • Massive code rewrite that improves UPS over the previous edition by upwards of 20x. In my test setup, with the previous edition, I experienced UPS drops at around 4k planters with about 3k of them growing saplings. As of this release, I can have roughly 80k planters, with or without saplings, before noticing the same UPS drops. (This was with both mods set for an update interval of 300 ticks.) This code rewrite includes changing the code so it no longer loops over every sapling and instead stores them based on the tick they reach the next stage, allowing faster indexing and processing of only what's needed this tick. Also changed how it loops through and checks available planters, using a different method that appears to be faster and more reliable.

Known issues

None that I know of at this time!


Future plans

  • My next project is a mod that prevents laying of concrete and other artificial tiles under trees and vice versa. Once that mod is released, I will update this mod for support of the new mod. Edit: Done!! Restrictions On Artificial Tiles
  • Did I mention I'm looking for better graphics?
  • I want to look into the feasibility of having the tree type the sapling grows into be determined by the tile type it's planted on and auto-placement settings of the trees. It'd be a rather simplistic system (1 sapling type can be any tree type at adult), but I feel that's better than the complexity (both logistically and technically) of having different seed types for each tree type.
  • Add mod support of other mods that add trees and tile types (eg, Alien Biomes)