Small code change suggestion within ResourceCallHandler:harvest_entity()

In that ResourceCallHandler:harvest_entity() function, we have this piece of code:

   if renewable_resource_node and renewable_resource_node:get_harvest_overlay_effect() then
      renewable_resource_node:request_harvest(session.player_id)
   elseif resource_node then
      ...
   end

If the entity have a renewable option, it will always try to harvest the renewable resource, even when it has not replenished yet. It will never try the non-renewable option.

In the archipelago, I modded that, into this:

	if renewable_resource_node and renewable_resource_node:get_harvest_overlay_effect() and renewable_resource_node:is_harvestable() then
		renewable_resource_node:request_harvest(session.player_id)
	elseif resource_node then
		...
	end

Just one extra condition, renewable_resource_node:is_harvestable() was added.
This forces it to fail in case the entity was harvested and have not replenished yet, and finally try the non-renewable option instead.
It is what makes palm/papaya trees work, you harvest it for renewable coconuts, then if you try again, it will chop the tree, unless you gave it enough time to grow the coconuts back.

1 Like

Makes sense. Will be in the next release.

2 Likes

Yay, one less override.

2 Likes

for the apple trees in brewery i had add both the renewable_resource_node and the resource_node - with the normal harvestcommand they will get only the renewable and if someone will cut it dow they can manually select the tree and use the cut button ^^

so they dont will cut it accidentally ^^

1 Like