[MOD 0.17] Wood Harvester

Topics and discussion about specific mods
Post Reply
mg79
Burner Inserter
Burner Inserter
Posts: 18
Joined: Mon Apr 24, 2017 5:32 pm
Contact:

[MOD 0.17] Wood Harvester

Post 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.
Last edited by mg79 on Fri Mar 15, 2019 5:42 pm, edited 4 times in total.

User avatar
Repofme1
Fast Inserter
Fast Inserter
Posts: 168
Joined: Sun Aug 13, 2017 5:22 pm
Contact:

Re: [MOD 0.16] Wood Harvester

Post 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 :)

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 4327
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: [MOD 0.16] Wood Harvester

Post 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={}.

mg79
Burner Inserter
Burner Inserter
Posts: 18
Joined: Mon Apr 24, 2017 5:32 pm
Contact:

Re: [MOD 0.16] Wood Harvester

Post 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) :)

mrvn
Smart Inserter
Smart Inserter
Posts: 4284
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: [MOD 0.16] Wood Harvester

Post 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.

kaszak696
Burner Inserter
Burner Inserter
Posts: 6
Joined: Fri Jan 19, 2018 9:07 am
Contact:

Re: [MOD 0.16] Wood Harvester

Post 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 1906 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.

mg79
Burner Inserter
Burner Inserter
Posts: 18
Joined: Mon Apr 24, 2017 5:32 pm
Contact:

Re: [MOD 0.16] Wood Harvester

Post 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!

mg79
Burner Inserter
Burner Inserter
Posts: 18
Joined: Mon Apr 24, 2017 5:32 pm
Contact:

Re: [MOD 0.16] Wood Harvester

Post 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.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 4327
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: [MOD 0.16] Wood Harvester

Post 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.)
Author of: Hand Crank Generator Deluxe, Screenshot Hotkey 2.0, /sudo
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

mg79
Burner Inserter
Burner Inserter
Posts: 18
Joined: Mon Apr 24, 2017 5:32 pm
Contact:

Re: [MOD 0.16] Wood Harvester

Post 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.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 4327
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: [MOD 0.16] Wood Harvester

Post 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.
Author of: Hand Crank Generator Deluxe, Screenshot Hotkey 2.0, /sudo
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

mg79
Burner Inserter
Burner Inserter
Posts: 18
Joined: Mon Apr 24, 2017 5:32 pm
Contact:

Re: [MOD 0.17] Wood Harvester

Post by mg79 »

Mod updated for 0.17 with some bug fixes. :D

Post Reply

Return to “Mods”

Who is online

Users browsing this forum: No registered users