Page 1 of 1

[MOD 0.17] Wood Harvester

Posted: Mon Jul 09, 2018 2:00 pm
by mg79
Wood Harvester

Description: Adds a simple machine for automatic harvesting of forests into raw wood

My first attempt at modding Factorio, sprung from starting a new game and ending up with a tiny patch of coal in my starting area, but completely surrounded by forest. Harvesting wood by hand in the early game is as we all know a major ache in the behind, and construction robots are a mid-late game technology. So with the help of Eradicator (thanks a lot!) in the Mod Ideas forum I present the automatic wood harvester. It's researched early on (as part of Automation) so if you wanted to and had plenty of forest around you could power your base entirely off wood.

The machine itself costs 10 iron plates, 5 iron gear wheels and 5 iron axes to build. It will then harvest trees at a rate of 1 raw wood per second, meaning the actual tree removal rate will depend on the type of tree.

Current version: 0.17.1
Download: https://mods.factorio.com/mod/WoodHarvester
Source: https://github.com/mikaelg79/FactorioWoodHarvester
License: MIT

Known issues
  • Will only harvest wood from trees. If other mods add additional resources to trees, those resources will be lost.
    [*] Will probably get stuck if a tree doesn't provide wood. Shouldn't happen in vanilla, but a possible conflict with other mods. Fixed
  • Won't show the affected area during placement. This is a limitation in Factorio as the AssemblingMachine prototype doesn't support overlays, only mining drills and roboports do.
  • Model is simply a recolored Assembling Machine 1 because I can't 3d model to save my life.
Planned features
  • Possibly increased harvesting area/speed through research.
  • Play better with other mods.
  • More visible harvesting rather than trees just disappearing (if possible).
Image

Changelog
  • 0.17.1
    - Harvesters no longer silently disable themselves when running out of trees to harvest, but mark themselves for deconstruction once all materials have been removed. (Can be changed in mod settings)
    - Harvester recipe changed due to removal of iron axes, now only requires 5 gears and 10 plates.

    Bugfixes:
    - Harvesters now actually stop harvesting when marked for deconstruction, and won't refill the input slot while inactive.

    Cosmetic:
    - Major/minor mod version follows Factorio, so mod version 0.17.x is compatible with Factorio 0.17
  • 0.0.10: Fixed a small bug in the recipes which would cause errors when used alongside Bob's mods.
  • 0.0.9: Fixed bugs in checkForUpdate. Shouldn't throw errors when added to an existing game now.
  • 0.0.8: Fixed the recipe sorting, now sorts after Pumpjacks in the extraction machine subcategory.
  • 0.0.8: Harvester now starts cutting trees closest to itself and works its way out, another idea (re)implemented (and improved ;) ) from eradicator's proof of concept.

Re: [MOD 0.16] Wood Harvester

Posted: Mon Jul 09, 2018 10:57 pm
by Repofme1
Wow, great work! I really appreciate this. Been looking for a mod like this for a while now, since it would go really well with my mod (Xander). A big thanks to eradicator too, since I recall he was around when I was discussing the raw wood problem in Xander Mod, and now he's helped out with this mod!

A quick look at the code shows a much better knowledge of I the Factorio API than I have - a good change for a learning experience :)

Re: [MOD 0.16] Wood Harvester

Posted: Tue Jul 10, 2018 2:13 am
by eradicator
Repofme1 wrote:A quick look at the code shows a much better knowledge of I the Factorio API than I have - a good change for a learning experience :)
Last i checked it was 80% my code btw, except he killed all the beavers :sadface: (@OP thanks for mentioning my name too ;).
Regrettable i don't think it's a valid solution for xanders becaues it only works for existing forests, and xanders needs such a huge amount of it that you can't really get around having a building that creates wood from ingredients={}.

Re: [MOD 0.16] Wood Harvester

Posted: Mon Jul 23, 2018 11:54 am
by mg79
New version released, re-implementing that the harvesters start cutting down trees closest to themselves and work their way out. And fixed the sorting, so now it's in the proper subcategory.

Had to quickly release another version after that because I discovered a bug when adding the mod to a save that didn't previously have it. (lesson learned: don't assume that mod.old_version exists) :)

Re: [MOD 0.16] Wood Harvester

Posted: Mon Jul 23, 2018 3:11 pm
by mrvn
Check out the AAI Vehicle mod. The mining vehicles can also mine wood and show a destruction animation iirc. The bluebuild / bluebuild rewritten mods also deconstruct trees with animation. Maybe you can borrow the code from them so trees simply disappear.

Feature requests:
- circuit connection setting the maximal radius to harvest trees
- reverse machine. Feed it seedlings (made from wood and water?) and it plants trees.

Re: [MOD 0.16] Wood Harvester

Posted: Tue Jul 24, 2018 8:40 am
by kaszak696
It seems to have a weird interaction with Bob's mods, specifically Bob's Library and Bob's Electronics. When they are both installed alongside Wood Harvester, Factorio throws this error:
woodharvester.png
woodharvester.png (6.98 KiB) Viewed 6896 times
Disabling either Electronics or Wood Harvester clears the issue. I tried to divine why that happens, but my knowledge about Lua and Factorio API is woefully inadequate.

Re: [MOD 0.16] Wood Harvester

Posted: Tue Jul 24, 2018 9:08 am
by mg79
kaszak696 wrote:It seems to have a weird interaction with Bob's mods, specifically Bob's Library and Bob's Electronics. When they are both installed alongside Wood Harvester, Factorio throws this error:inadequate.
I'll look into it, thanks for the report!

Re: [MOD 0.16] Wood Harvester

Posted: Wed Jul 25, 2018 3:09 pm
by mg79
Fixed it. It was a simple mistake on my behalf. In the recipes I had put quotes around the item amounts, which makes them strings. Factorio itself doesn't seem to care and makes an implicit cast to number, but it caused bob's to throw an error.

I uploaded 0.0.10 with a fix to the mod portal, it should be visible soon.

Re: [MOD 0.16] Wood Harvester

Posted: Wed Jul 25, 2018 4:58 pm
by eradicator
mg79 wrote:Fixed it. It was a simple mistake on my behalf. In the recipes I had put quotes around the item amounts, which makes them strings. Factorio itself doesn't seem to care and makes an implicit cast to number, but it caused bob's to throw an error.
Implicit cast to number sounds like a worthy bug report. Though...wouldn't be suprised it it ended in "we do it on purpose". Bleh. I don't want to call tonumber() on everything that should already be a number. (Not blaming you, just saying that if it's generally possible i don't want my scripts to run into that bug.)

Re: [MOD 0.16] Wood Harvester

Posted: Wed Jul 25, 2018 5:12 pm
by mg79
eradicator wrote:
mg79 wrote:Fixed it. It was a simple mistake on my behalf. In the recipes I had put quotes around the item amounts, which makes them strings. Factorio itself doesn't seem to care and makes an implicit cast to number, but it caused bob's to throw an error.
Implicit cast to number sounds like a worthy bug report. Though...wouldn't be suprised it it ended in "we do it on purpose". Bleh. I don't want to call tonumber() on everything that should already be a number. (Not blaming you, just saying that if it's generally possible i don't want my scripts to run into that bug.)
I'm inclined to agree. I prefer strict code semantics, not accomodating for poor practices. If Factorio had been stricter about typing I would have discovered the error immediately.

It's also possible it doesn't implicitly cast, but just interprets anything that isn't a number as 1.

Re: [MOD 0.16] Wood Harvester

Posted: Wed Jul 25, 2018 5:54 pm
by eradicator
mg79 wrote:It's also possible it doesn't implicitly cast, but just interprets anything that isn't a number as 1.
A bug report will bringt the truth to light :D.

Re: [MOD 0.17] Wood Harvester

Posted: Fri Mar 15, 2019 5:42 pm
by mg79
Mod updated for 0.17 with some bug fixes. :D

Re: [MOD 0.17] Wood Harvester

Posted: Sat Apr 02, 2022 3:58 pm
by jamiechi1
This mod can be easily updated for Factorio 1.1. I added an issue at Github with the changes I made.

Re: [MOD 0.17] Wood Harvester

Posted: Sat Apr 02, 2022 8:17 pm
by Qon
This is such a neat mod. I no longer need it for my factories that are swarming with bots. But I have fond memories of getting a little bit more automation in early game factories, collecting wood and clearing areas without waste. So it would be nice to see this mod kept alive anyways. :)

Re: [MOD 0.17] Wood Harvester

Posted: Fri Jul 15, 2022 6:13 am
by fctrusr
jamiechi1 wrote:
Sat Apr 02, 2022 3:58 pm
This mod can be easily updated for Factorio 1.1. I added an issue at Github with the changes I made.
I totally agree that this mod should be kept alive. I use it at least since version 0.0.11 and just tweaked the info.json file to keep it alive, at least in my local copy.

i am currently in the making and testing of an updated version which helps a lot to get rid of the massive ups/fps drop when used in larger amounts in huge factories.
This week i figured the root cause of the problem and implemented some new configuration parameters to be able to tweak them without restarting the game.

To fix the ups/fps problem i now added a random idle skip counter. If the harvester runs out of trees and gets not marked to be destroyed it now waits a random amount of harvest loops until it tries again to find some trees, which don't grow that fast that checking every second makes sense.

I usually use the Natural Tree Expansion Reloaded mod to grow trees and ensure my factory stays clear of trees and to have a constant source of wood without manual interaction.

Re: [MOD 0.17] Wood Harvester

Posted: Sat Sep 23, 2023 8:13 pm
by jamiechi1
fctrusr wrote:
Fri Jul 15, 2022 6:13 am
jamiechi1 wrote:
Sat Apr 02, 2022 3:58 pm
This mod can be easily updated for Factorio 1.1. I added an issue at Github with the changes I made.
I totally agree that this mod should be kept alive. I use it at least since version 0.0.11 and just tweaked the info.json file to keep it alive, at least in my local copy.

i am currently in the making and testing of an updated version which helps a lot to get rid of the massive ups/fps drop when used in larger amounts in huge factories.
This week i figured the root cause of the problem and implemented some new configuration parameters to be able to tweak them without restarting the game.

To fix the ups/fps problem i now added a random idle skip counter. If the harvester runs out of trees and gets not marked to be destroyed it now waits a random amount of harvest loops until it tries again to find some trees, which don't grow that fast that checking every second makes sense.

I usually use the Natural Tree Expansion Reloaded mod to grow trees and ensure my factory stays clear of trees and to have a constant source of wood without manual interaction.
If you still exist, could you post your changes either here or in an issue on Github? Thanks.

Re: [MOD 0.17] Wood Harvester

Posted: Thu Jan 04, 2024 3:41 pm
by fctrusr
i am still around, sorry for the late reply. While using the wood harvester with several overhaul mods i ran into a few issues which i am trying to fix first before i am going to release something.
The issues are supporting every item a tree can drop, like seeds, sap and so on or e.g. logs instead of wood when you play with pyanodon.

After the rework it will be more like a universal "collecting" Assembler ... like also for picking up rocks where you also get more than stone like coal or moss.

And happy new Year btw :D

Re: [MOD 0.17] Wood Harvester

Posted: Fri Mar 01, 2024 10:32 pm
by jamiechi1
Thanks for your reply.

It's been awhile since I looked at these forums myself. I should probably look here more often.

Re: [MOD 0.17] Wood Harvester

Posted: Sun Mar 10, 2024 12:55 pm
by mrvn
fctrusr wrote:
Fri Jul 15, 2022 6:13 am
To fix the ups/fps problem i now added a random idle skip counter. If the harvester runs out of trees and gets not marked to be destroyed it now waits a random amount of harvest loops until it tries again to find some trees, which don't grow that fast that checking every second makes sense.

I usually use the Natural Tree Expansion Reloaded mod to grow trees and ensure my factory stays clear of trees and to have a constant source of wood without manual interaction.
I haven't looked at the mod but is there an option to say that trees don't grow back? Is that the "marked to be destroyed" part?

Instead of having each harvester wait for a random amount, which could still mean that one tick 1000 harvesters will be checked at the same time, you should probably put the idle harvester into a list and then check at most one harvester per tick. You can record the time each harvester has been checked and delay processing the list till the first harvester hasn't been checked for 1 minute or so. This will work smoothly up to 3600 (idle) harvesters, at which points each harvester will be checked less frequently.

Many mods use such a work queue design where they limit the work per tick and will start working more slowly when you reach a certain number of entities. This works great for anything where you only check if there is work to be done. Checking less frequent in a large game isn't noticeable but lag spikes are annoying.