Page 1 of 1

New Tree Not Growing attempt using plant_lib moretrees

PostPosted: Thu Oct 02, 2014 11:48
by gamergardencat
I am working on a new tree for my mod. Watching Stampycat on youtube I saw he tried to build a Cherry Blossom Tree which inspired me to look into making a custom blossom. I can use world edit to populate my world but I don't want to fuss with pasting the model name and guessing where the stem will show at in relation to position 1.

I had the sapling working to a point I planted one only to chuckle seeing an apple tree appear. I commented that out and I also dug around plant_lib and moretrees. New code makes the sapling disappear after a while. May the growtree function work but I am using the wrong options?

plant_lib and moretrees are somewhat complex mods I don't see any examples that show how individual functions work together.

The last alternative I think might be trying to fork moretrees and replace or add the one I want. The problem doing that is I want my mod to be somewhat independent being able to interact with everything and mods that's already loaded. Also not really interested in a biome for this tree since I want my particular imaging of the blossom to go with the theme of my mod.

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
minetest.register_node("mochathicket:mocha_blossom_leaves", {
  description = "Mocha Blossom Leaves",
  drawtype = "allfaces_optional",
  waving = moretrees_new_leaves_waving,
  visual_scale = moretrees_plantlike_leaves_visual_scale,
  tiles = { "mocha_blossom_leaves.png" },
  inventory_image = "mocha_blossom_leaves.png",
  paramtype = "light",
  groups = {snappy=3, flammable=2, leaves=1, moretrees_leaves=1},
  sounds = default.node_sound_leaves_defaults(),

  drop = {
    max_items = 1,
    items = {
      {items = {"mochathicket:mocha_blossom_sapling"}, 20 },
      {items = {"mochathicket:mocha_blossom_leaves"} }
    }
  },
})

minetest.register_node("mochathicket:mocha_blossom_trunk", {
  description = "Mocha Blossom Trunk",
  tiles = {
    "mocha_blossom_trunk_top.png",
    "mocha_blossom_trunk_top.png",
    "mocha_blossom_trunk.png"
  },
  paramtype2 = "facedir",
  is_ground_content = true,
  groups = {tree=1,snappy=1,choppy=2,oddly_breakable_by_hand=1,flammable=2},
  sounds = default.node_sound_wood_defaults(),
  on_place = minetest.rotate_node,
})

minetest.register_node("mochathicket:mocha_blossom_planks", {
  description = "Mocha Blossom Planks",
  tiles = {"mocha_blossom_wood.png"},
  is_ground_content = true,
  groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=3,wood=1},
  sounds = default.node_sound_wood_defaults(),
})

minetest.register_node("mochathicket:mocha_blossom_sapling", {
  description = "Mocha Blossom Sapling",
  drawtype = "plantlike",
  tiles = {"mocha_blossom_sapling.png"},
  inventory_image = "mocha_blossom_sapling.png",
  paramtype = "light",
  paramtype2 = "waving",
  walkable = false,
  selection_box = {
    type = "fixed",
    fixed = {-0.3, -0.5, -0.3, 0.3, 0.35, 0.3}
  },
  groups = {snappy=2,dig_immediate=3,flammable=2,attached_node=1,sapling=1},
  sounds = default.node_sound_defaults(),
})


mocha_blossom_model={
   axiom="FFFFFdddccA/FFFFFFcA/FFFFFFcB",
   rules_a="[&&&dddd^^ddddddd][&&&---dddd^^ddddddd][&&&+++dddd^^ddddddd][&&&++++++dddd^^ddddddd]",
   rules_b="[&&&ddd^^ddddd][&&&---ddd^^ddddd][&&&+++ddd^^ddddd][&&&++++++ddd^^ddddd]",
   rules_c="/",
   rules_d="F",
   trunk="mocha_blossom_trunk",
   leaves="mocha_blossom_leaves",
   angle=30,
   iterations=2,
   random_level=0,
   trunk_type="single",
   thin_branches=true
}
function grow_mocha_blossom(pos)
   minetest.remove_node(pos)
   if math.random(1,2) == 1 then
      minetest.spawn_tree(pos, mocha_blossom_model)
   else
      minetest.spawn_tree(pos, mocha_blossom_model)
   end
end
plantslib:grow_plants({
   grow_delay = 2,
   grow_chance = 4,
   grow_plant = "mochathicket:mocha_blossom_sapling",
   grow_nodes = "default:dirt_with_grass",
   grow_function = "grow_mocha_blossom"
})
--[=====[


minetest.register_abm({
   nodenames = {"mochathicket:mocha_blossom_sapling"},
   interval = 10,
   chance = 50,
   action = function(pos, node)
      local is_soil = minetest.registered_nodes[minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name].groups.soil
      if is_soil == nil or is_soil == 0 then return end
      print("A mocha blossom sapling grows into a tree at "..minetest.pos_to_string(pos))
      local vm = minetest.get_voxel_manip()
      local minp, maxp = vm:read_from_map({x=pos.x-16, y=pos.y, z=pos.z-16}, {x=pos.x+16, y=pos.y+16, z=pos.z+16})
      local a = VoxelArea:new{MinEdge=minp, MaxEdge=maxp}
      local data = vm:get_data()
      default.grow_tree(data, a, pos, math.random(1, 4) == 1, math.random(1,100000))
      vm:set_data(data)
      vm:write_to_map(data)
      vm:update_map()
   end
})
--]=====]

Re: New Tree Not Growing attempt using plant_lib moretrees

PostPosted: Thu Oct 02, 2014 23:16
by Wuzzy
I have read the source code and probably know exactly where the problem lies.

OK, your tree definition is flawed in the fields “trunk” and “leaves”. There is no node by the name “mocha_blossom_trunk” and “mocha_blossom_leaves”.
The naming convention (even enforced, I guess) of itemstrings is:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
<modname>:<nodename>


i.e. “default:trunk”, and NOT just “trunk”.

You have to enter the full itemstring. From your source code, I have seen that this has to be “mochathicket:mocha_blossom_leaves” and “mochathicket:mocha_blossom_trunk”.


The tree definition seems to work otherwise. I have tried it out by entering the definition into my L-System Tree Utility (a mod to help developing L-system trees) and used “default:trunk” and “default:leaves” as replacements.
I like the tree model, by the way. =)

Re: New Tree Not Growing attempt using plant_lib moretrees

PostPosted: Thu Oct 02, 2014 23:53
by gamergardencat
Ok I will try that. The tree model is birch which I just pulled out of moretrees and seemed like what a Cherry Blossom might look like. Maybe I will change the model to something more sensible. I will change the code and report what happens. Thank you for your reply.

Re: New Tree Not Growing attempt using plant_lib moretrees

PostPosted: Fri Oct 03, 2014 00:16
by gamergardencat
Wuzzy wrote:...
You have to enter the full itemstring. From your source code, I have seen that this has to be “mochathicket:mocha_blossom_leaves” and “mochathicket:mocha_blossom_trunk”...

This turns out to be the wrench. Now it's planting! Now for a more appropriate model. I didn't realize birch was so tall lol. Maybe I will be it since it might make an interesting tree house hehe.

Image