FaceDeer / dfcaverns

Replicating Dwarf Fortress' underground flora in Minetest
Other
16 stars 9 forks source link

Sapling Functions #25

Closed tenplus1 closed 1 year ago

tenplus1 commented 2 years ago

I'm trying to add support for my bonemeal mod so that df_cavern saplings can be grown quickly, and while some of them are done so far others are a tad more difficult as there is no simple function supplied to grow the sapling e.g.

df_trees:black_cap_sapling has df_trees.spawn_black_cap(pos) as a helper but..

df_primordial_items:fern_sapling does not and instead selects a rotation and gets the fern schematic before placing it, so a helper was required to make this work:


    local function fern_fix(pos)
        minetest.set_node(pos, {name = "air"})
        local rotations = {0, 90, 180, 270}
        mapgen_helper.place_schematic(pos,
            df_primordial_items.get_fern_schematic(), rotations[math.random(1,#rotations)])
    end
FaceDeer commented 2 years ago

Been thinking of coming out of modding retirement, and between this and alerikaisattera's issues I take it as a sign. :) I'll dust off the lua brain a bit and see what I can do.

What sort of API hooks would suit your mod's needs best? Are there popular farming mods out there that I should be getting in synch with?

tenplus1 commented 2 years ago

Simple hooks that tie in with default behaviour e.g. mymod.mytree(pos) that can be called from any mod to remove sapling and grow tree.

FaceDeer commented 1 year ago

Functions added. These now exist:

df_trees.spawn_black_cap df_trees.spawn_blood_thorn (note that this is a mapgen function, there's no bloodthorn sapling. They behave like cacti, you place a block and it grows taller) df_trees.spawn_fungiwood df_trees.spawn_goblin_cap df_trees.spawn_nether_cap df_trees.spawn_spindlestem (these are sort of halfway between a tree and a crop plant, when they spawn they start as just a cap on the ground and then the stem grows over time) df_trees.spawn_spore_tree df_trees.spawn_torchspine (this one is also a bit of an oddball, it grows over time too) df_trees.spawn_tower_cap df_trees.spawn_tunnel_tube df_primordial_items.spawn_giant_fern df_primordial_items.spawn_jungle_mushroom df_primordial_items.spawn_jungle_tree df_primordial_items.spawn_primordial_mushroom

Would you like me to put the relevant saplings into groups, or add these functions as a member on their node definitions?

tenplus1 commented 1 year ago

Many thanks for adding the helper grow functions, I downloaded latest code to test and subterrane and mapgen_helper mods are both empty and causing errors.

alerikaisattera commented 1 year ago

Many thanks for adding the helper grow functions, I downloaded latest code to test and subterrane and mapgen_helper mods are both empty and causing errors.

Should work if you download them separately

FaceDeer commented 1 year ago

There's also a particular flag you can set when calling git to sync that tells it to sync sub-projects like those two as well. Been years since I did this though, I can't remember it offhand. I created those two mods as separate projects because other mapgen mods could use them, they're not dfcaverns-specific. When I get through this current spate of issues and update the contentDB version of this I'll package it up so it'll remain a one-click upgrade for general users, though.

FaceDeer commented 1 year ago

There's also a particular flag you can set when calling git to sync that tells it to sync sub-projects like those two as well. Been years since I did this though, I can't remember it offhand. I created those two mods as separate projects because other mapgen mods could use them, they're not dfcaverns-specific. When I get through this current spate of issues and update the contentDB version of this I'll package it up so it'll remain a one-click upgrade for general users, though.

FaceDeer commented 1 year ago

If these functions are what's needed I'll close this issue. Let me know if any other helper functions or standardized APIs would be useful, I could do things like add these grower functions to the saplings' definitions or expose things like how fast these grow.