Page 1 of 1

How can I make new trees?

PostPosted: Fri Aug 12, 2016 15:08
by burli
I want to create a more bush like tree from default wood an leaves including saplings. How can I do this? Can I use some of the code from trees.lua or do I have to write my own code?

Image

Re: How can I make new trees?

PostPosted: Fri Aug 12, 2016 15:15
by lisacvuk
Of course you can use the default game stuff, as long as you respect the licence. You should probably start with reading Rubenwardy's modding book :D

Re: How can I make new trees?

PostPosted: Fri Aug 12, 2016 15:19
by burli
I don't mean copy and paste the code. I know that I can do that. I mean calling the existing code

Re: How can I make new trees?

PostPosted: Fri Aug 12, 2016 15:24
by lisacvuk
http://dev.minetest.net/minetest.place_schematic
Create some schematics, save them, and give a random chance to place each of them.

Re: How can I make new trees?

PostPosted: Fri Aug 12, 2016 15:37
by burli
Never worked with schematics. How can I create them?

Re: How can I make new trees?

PostPosted: Fri Aug 12, 2016 16:03
by lisacvuk
I think you can use the worldedit mod. There's a manual for it :D

Re: How can I make new trees?

PostPosted: Fri Aug 12, 2016 16:40
by burli
Ok, but with a schematic I just get one tree. I want more random leaves. And worldedit seems to save the schematic in a different format

Re: How can I make new trees?

PostPosted: Fri Aug 12, 2016 17:43
by KCoombes
are you using //mtschemcreate (tree name)? you could save several, slightly different trees (tree_1, tree_2, etc) and randomize the decoration placement in mapgen.

Re: How can I make new trees?

PostPosted: Fri Aug 12, 2016 18:02
by burli
found this. It's working now.

viewtopic.php?f=12&t=9400

Will they be randomly selected if I use _# like other media files or do I have to generate the filename myself?

What I don't like is that I can only use the corner to place schematics, not the center.

Re: How can I make new trees?

PostPosted: Fri Aug 12, 2016 20:14
by KCoombes
burli wrote:found this. It's working now.

viewtopic.php?f=12&t=9400

Will they be randomly selected if I use _# like other media files or do I have to generate the filename myself?

What I don't like is that I can only use the corner to place schematics, not the center.


you would need to create the filename yourself for each tree schematic you save, but the random generation is handled by code in the mapgen file

Re: How can I make new trees?

PostPosted: Fri Aug 12, 2016 21:16
by burli
KCoombes wrote:you would need to create the filename yourself for each tree schematic you save, but the random generation is handled by code in the mapgen file

I know that I have to enter the filename myself. I just want to know if multiple files with _# ending will be loaded randomly like with textures or sound files or if I have to code this myself

For example: I have the files tree_1.mts, tree_2.mts, tree_3.mts

can I use the code

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.place_schematic(pos, "tree.mts", rotation, replacements, force_placement)


and one of the three files is selected randomly?

Re: How can I make new trees?

PostPosted: Sat Aug 13, 2016 01:07
by twoelk
Somebody else once asked "How to make Trees?"
Sokomine started a trees_lib
Vanessa's plants/biome library plants the stuff for More-Trees and others.
Duane's Schematic Saver might be useful

Re: How can I make new trees?

PostPosted: Sat Aug 13, 2016 01:18
by KCoombes
burli wrote:
KCoombes wrote:you would need to create the filename yourself for each tree schematic you save, but the random generation is handled by code in the mapgen file

I know that I have to enter the filename myself. I just want to know if multiple files with _# ending will be loaded randomly like with textures or sound files or if I have to code this myself

For example: I have the files tree_1.mts, tree_2.mts, tree_3.mts

can I use the code

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.place_schematic(pos, "tree.mts", rotation, replacements, force_placement)


and one of the three files is selected randomly?


Try this:
Adapted from Ethereal NG - WTFPL

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
local add_schem = function(a, b, c, d, e, f, g, h, i)

   minetest.register_decoration({
      deco_type = "schematic",
      place_on = a,
      sidelen = 80,
      fill_ratio = b,
      biomes = c,
      y_min = d,
      y_max = e,
      schematic = f,
      flags = "place_center_x, place_center_z",
      spawn_by = h,
      num_spawn_by = i,
   })
end

local path = minetest.get_modpath("modname") .. "/schematics/"

-- Basic Tree
add_schem({"a"}, 0.02, {"b"}, 3, 80, path .. "tree_1.mts", nil, nil, nil)
add_schem({"a"}, 0.02, {"b"}, 3, 120, path .. "tree_2.mts", nil, nil, nil)

Re: How can I make new trees?

PostPosted: Sat Aug 13, 2016 03:17
by Sokomine
Saving schematics for trees can also quite easily be done with my handle_schematics mod.

Re: How can I make new trees?

PostPosted: Sat Aug 13, 2016 06:39
by burli
KCoombes wrote:Try this:
Adapted from Ethereal NG - WTFPL


Thx, I will try this

Re: How can I make new trees?

PostPosted: Sat Aug 13, 2016 07:16
by paramat
Saving schematics with Worldedit has problems, you cannot set per-node probability for "air" or per-node force-place.
For full control and often faster working create schematic files using tables in this way https://github.com/minetest-mods/saveschems

Re: How can I make new trees?

PostPosted: Sat Aug 13, 2016 07:41
by burli
twoelk wrote:Sokomine started a trees_lib
Vanessa's plants/biome library plants the stuff for More-Trees and others.


They both use L-Trees, which is buggy as far as I know. moretrees causes ugly shadows. Don't know how it is with trees_lib

paramat wrote:Saving schematics with Worldedit has problems, you cannot set per-node probability for "air" or per-node force-place.
For full control and often faster working create schematic files using tables in this way https://github.com/minetest-mods/saveschems


Thx, will take a look

Re: How can I make new trees?

PostPosted: Sat Aug 13, 2016 08:43
by Wuzzy
Using schematics for tress has the huge drawback that they always look the same. Also, I heard that schematics were originally intended for small decorations and not full trees and entire buildings and such.

You may want to look into L-system trees, look here:
http://dev.minetest.net/Introduction_to_L-system_trees

L-system trees have the benefit that they can be more random. L-systems are really powerful tools IMO.

I even wrote a mod for helping people creating new L-system trees (to save your time and sanity):
viewtopic.php?f=11&t=9458

Re: How can I make new trees?

PostPosted: Sat Aug 13, 2016 08:53
by burli
Wuzzy wrote:Using schematics for tress has the huge drawback that they always look the same.


This sounds like there as some randomization

Sokomine wrote:Not exactly true, although most schematics are used that way and most of us don't care about the random factors that can be applied. Hmmm was a bit upset when learning that his schematics where used for storing houses and the like instead of the decorations he intended the file format and decorations mechanism to be used for :-)


Wuzzy wrote:Also, I heard that schematics were originally intended for small decorations and not full trees and entire buildings and such.

But as far as I can see the default mapgens use schematics for trees. And they don't look equal

Wuzzy wrote:You may want to look into L-system trees, look here:
http://dev.minetest.net/Introduction_to_L-system_trees

L-system trees have the benefit that they can be more random. L-systems are really powerful tools IMO.

I even wrote a mod for helping people creating new L-system trees (to save your time and sanity):
viewtopic.php?f=11&t=9458


I thought L-System is buggy and causes the ugly shadows in moretrees

Re: How can I make new trees?

PostPosted: Sat Aug 13, 2016 12:03
by Wuzzy
Has “L-system trees are buggy” been proven yet? Like, is there an issue on that or something?

OK, schematics are not completely static, some randomization is indeed possible. I checked it in documentation.

Let's just say L-system trees and schematics are both possible ways to make random trees.

Re: How can I make new trees?

PostPosted: Sat Aug 13, 2016 12:18
by burli
I have this with l-system from this thread
viewtopic.php?f=6&t=14194

Can you post a link to schematics doc plz? Didn't found one yet

Re: How can I make new trees?

PostPosted: Sat Aug 13, 2016 15:13
by Sokomine
burli wrote:They both use L-Trees, which is buggy as far as I know. moretrees causes ugly shadows. Don't know how it is with trees_lib

trees_lib just offers all known methods of placing trees - be it an algorithm, L-System or schematics (either file or table) The lib can optionally register all the necessary nodes and grow trees from saplings on suitable grounds. It is possible to provide several growing methods per tree type.

Wuzzy wrote:Using schematics for tress has the huge drawback that they always look the same. Also, I heard that schematics were originally intended for small decorations and not full trees and entire buildings and such.

You can use more than one schematic, make each schematic have a variable height and rotate them automaticly. That's usually more than enough. In addition, trees placed by mapgen often overlap. And if I'm not mistaken, decorative trees where definitely something hmmm wrote the decorations for. He just got a bit annoyed when I started using them for houses :-)

burli wrote:Can you post a link to schematics doc plz? Didn't found one yet

They're sometimes called "decoration" in lua_api.txt

Re: How can I make new trees?

PostPosted: Sun Aug 14, 2016 09:47
by azekill_DIABLO


omg thank you so much i'm searching this since one month

Re: How can I make new trees?

PostPosted: Mon Aug 15, 2016 14:06
by paramat
> I thought L-System is buggy and causes the ugly shadows in moretrees

Yes it has always created subtle shadows in water, but more recently it creates dark shadows in all non-mgv6 mapgens. Something about l-system code triggers extreme lighting bugs in core 'updateLighting', both need work.
To only get subtle shadows make sure to grow l-system trees from saplings, don't create trees at mapgen time.