A shout-out to our dear Devs! I’d really like someone from the team to read this post. After examining some files I think some changes are needed. More specifically, using separate entities whenever possible is a must if Stonehearth is to be kept modular and mod-friendly. Crops and renewable resource nodes will be discussed here as examples which bother me now.
We have an amazing component at our hands: stonehearth:evolve_data
. It allows to replace one entity with a different one after some time. Turning one entity into another is extremely simple and powerful way to make complex things possible. What we are lacking is the ability to do the same not after specified time, but when harvest action is performed on an entity.
Renewable resource node chains could be achieved this way. If an entity (e.g. ripe Berry Bush) after being harvested changed into a different one (e.g. empty Berry Bush) with stonehearth:evolve_data
set to change into the previous entity things would work the same way. But let’s say I want to make a plant which produces a gigantic, red fruit over a long period of time. Right now it can only have two models: unripe and ripe. No fruit - kaBOOM! - gigantic red fruit. With renewable resource nodes evolving into separate entries I could make the ripe fruit change into flowering plant and, via stonehearth:evolve_data
, could make it go through several stages just like a crop. This would actually be extremely useful if we think in modding categories: if the only thing happening after a harvest was changing an entity one could make objects requiring Hearthling’s intervention in order to proceed to the next phase simply by making a node which provides no resources.
Crop stages should be separate entities as well. Current implementation makes it impossible to apply any more sophisticated ideas to crop stages just because of the crop component structure. If the stages pointed to entities instead of providing model information I could implement the deploy mechanics easily, all I’d need would be to link the iconic form of a crop to the plant’s iconic form instead of creating the crop’s own iconic form. As a consequence: stonehearth:growing
would not be needed because stonehearth:evolve_data
applied to each stage would do the same thing. If stages were separate entities they could have different model origins, model variations, growth times etc. This is actually so bizarre that even the Devs have to use workarounds to get it working like expected, for reference see how rotting in the field is handled in silkweed_crop.json (these empty brackets are a bit of a shock).
Now, the last thing is a mix of both which started this topic: a renewable crop. This would be the hardest, but certainly easier if stages were separate entities. Right now the game stores crop stages as a part of mother crop entity. I’d recommend making it more liberate by just listing the stages and make them progress into one another via stonehearth:evolve_data
. The renewable crop would then become just a Farmer-maintained version of a renewable resource node, because instead of being destroyed via self:_destroy_crop()
, a loop in ai/harvest_adjacent_crop.lua would check whether there is an entry named like after_harvest
in stonehearth:crop
and change into that entity instead of emptying the field. The downside is one could point it to a non-crop entity and the game would need to mark the spot as empty so the Farmer know a new plant is needed there.