Modding crops: regrow fruit, move to inventory, sapling spacing?

I wanted to mod a berry bush as a crop but I’d like it to work a bit differently, that is: the bushes have 4 stages of growth: 2 sapling stages, grown bush and fruiting bush. The thing is I’d like the bush to go back to stage 3 after harvesting the berries instead of being removed and planted again. Would it be possible without altering farming behaviour?

Another thing is I’d like to be able to move a grown bush to the inventory, so it can be placed as a normal berry bush and used in recipes (e.g. potted berry bush).

For berry bushes to work properly it would make sense not to plant them next to each other, but to leave gaps between plants, is it possible in any way?

2 Likes

To do this just don’t add "hide_undeploy_ui": true in the “stonehearth:entity_forms” section inside the components of the berry bush json file (or set it to false).

Maybe playing with the scale of the models? I think right now all the crops occupy the same space, so things like pumpkin/watermelon look closer to each other than say carrots or turnips .

There’s an optional script for the growing component that could make it go back to the stage you want if you add a condition that checks for your current stage (examples at acacia/oak saplings). However it sounds like it would cause more problems than do what you want to do. I think nobody has tried to combine a renewable resource node with a crop yet. It might need changes in the crop or growing components, I think the farming system doesn’t really support it.

What you can do is adding berry bushes as crops, generating the potted plant (just like the tree crops) and then plant them as normal berry bushes on the ground. That should work without problems.

I will suggest this to the devs, seems like an interesting mechanic for farming.

4 Likes

I’m also still trying to make similar models.

But like Relyss said. For now i think the only possibility (without changing the Farming LUA) is to make models like the Trees that evolves.

Wouldn’t "hide_undeploy_ui": true make any stage of a crop collectable? I want it to work only for the grown bushes. Also: if I apply it to existing plants won’t I be able to speed up the harvest by simply collecting and placing the plant or will the collected plant remember its last harvest time?

I suppose farming the saplings will be the temporary solution, with the downside of manual harvesting.

I see the sense of replanting when the whole plant is harvested, but that is not always the case. Why we can re-harvest from wild herbs and silkweeds, but have to replant the cultivated ones? And why is it impossible to plant them as individual plants while we can move the wild specimens and grow new ones from seeds?

Besides: it would look super cool to have Berry Bush orchards and it would be possible to introduce some slowly growing plants without creating unnecessary delay between harvest and growing. Take a crop with 3 growth stages, 1 grown stage and 1 fruiting stage with several days between each stage (for Berry Bush it’s 22h), a total of 4 stage times to get the resource). With regrowing, the first resource takes 4 stage times, but the next ones need only 1 stage time.

2 Likes

Kinda like “perennial” and “annual” crops in Starbound - some can be harvested repeatedly (tomatoes, coffee beans, cocoa, bananas etc) while others must be replanted completely (potatoes, carrots, rice etc).
Perennial crops “reverse” to earlier stages after harvesting, and take some time to regrow.

1 Like

Nope, that option is only for items placed in the world. It is the reason why you can’t undeploy berry bushes and wild silkweed, nor the town banner. I think it would have side effects if you were to add it to the crop’s json file.

It will remember its last harvest time, just like when you move a berry bush.

They are implemented differently, they don’t have the same code even if they have similar models. The silkweed you see in a farm is not the same one as you see in the wild.

This happened when we introduced the herbalist. In order to keep a steady supply of herbs, flower seeds were introduced. But this meant we couldn’t plant flowers that gave placeable flowers (like trees). Crops can only produce one item.

The way farming works for all crops is that harvesting them gets rid of the planted crop, and produces an item. The crops are auto-harvested by farmers, which is easier/faster than having to manually harvest the placeable bushes and other plants. You might have set your town in a place without wild flowers and silkweed, and you probably want to have a supply of those resources most of the times (you want the plant because you want the resource that it produces).
But many of us want the option to have farms of placeable plants (for different recipes and/or for placing them in the world for decoration), so this might come eventually.

Like I said, they have different components; and this can be easily modded, like how you can cultivate trees.

For the record, there was a time they weren’t movable, and there was a mod for making them so.

This reminds me of Harvest Moon, yes. It would be a matter of revisiting the farming system and see if/why/how this would fit into the gameplay. I’ll ping @Brackhar for thoughts.

I like your suggestion, and I’m sad it’s kind of difficult to implement it right now in a mod, but we’ll see. You could try fiddling with the Lua files, I’m not sure if it would be possible but maybe there’s a way right now (would require changing many things to keep all crops compatible, I guess).

4 Likes

I think we misunderstood a bit. I want to undeploy the grown Berry Bush crop (stage 3 or 4) so I can plant it wherever I want. I have no idea how to mod that at the moment.

I thought all I need to make regrowing crops is to make Farmer change the crop’s stage instead of removing it. A workaround of insta-planting an already grown crop in place of the removed one would also do the trick if obtaining resources from crops is tied to removing them.

I understood you. Right now you can make (in a mod) a berry crop that when the farmer harvests it, it gets the berry bush (the potted one). But the crop will disappear from the farm, and the farmer will replant it just like when planting any other crop. You can then place the potted berry bush in the world and it will act as any other berry bush.

I think the stages are sequential. And when the harvesting stage is reached, the farmer will harvest the crop so the field will become empty and restart the stages. That’s why it’s more complicated to make it happen right now. :confused:

Not sure how to do that, but I think the farm field would still demand the crops to be planted there, so you would need to change a lot of code to make that happen.

2 Likes

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.

1 Like

Another question: will the time towards next harvest count when an item is in inventory? I cannot find relevant part of the code in renewable_resource_node_component.lua nor in evolve_component.lua and growing_component.lua which face the same problem. As a general question: does the time flow stop in inventory?

Sorry for the late reply.

Not sure right now, but food used to spoil inside containers too, so maybe just change their regrow time to be shorter for testing and give it a try?

1 Like