New decoration type

Post Reply
User avatar
oleastre
Member
Posts: 81
Joined: Wed Aug 13, 2014 21:39
GitHub: oleastre
In-game: oleastre

New decoration type

by oleastre » Post

I'm currently playing with map generation.
I started with MTDad simplev7 and was a little bit annoyed by the schematics tree, and asked myself: why not using default mod tree growing functions ?

So, I started a big rewrite of the mod you can see the work in progress here:
https://github.com/oleastre/simplev7/tree/advanced

To get trees working, I just add saplings as decoration and use minetest.set_gen_notify to get a list of generated saplings, and make them grow in an on_generated function.

As you can see in the code, the growing function always have the same signature: grow(vm_data, area, pos) .

So I'm thinking about adding a new type of decoration that will work roughly like the schematic one, but call a lua defined function instead.

Registration should look like:

Code: Select all

minetest.register_decoration({
  deco_type = "function",
  place_on = "default:dirt_with_grass",
  sidelen = 16,
  fill_ratio = 0.17,
  biomes = {"forest"},
  flags = "place_center_x, place_center_z",
  size = {x=4, y=4, z=4}
  on_gen = mymod.grow_tree
})
Where:
- mymod.grow_tree is my custom function
- size should be the expected area size in which my function can manipulate the content
- flags works like the schematic one to place the decoration position in the given area.

Before I start coding, does it seems interesting ? Any advice ?

User avatar
paramat
Developer
Posts: 3700
Joined: Sun Oct 28, 2012 00:05
GitHub: paramat
IRC: paramat
Location: UK

Re: New decoration type

by paramat » Post

Lua defined schematic decorations are already a feature, i'm working on the biomes for mgv5/v7 right now in this development mod https://github.com/paramat/biomesdev, that mod shows how to add trees to mgv5/v7.
These schematics are added by core code and are much faster than growing trees from saplings.

jin_xi
Member
Posts: 165
Joined: Mon Jul 02, 2012 18:19

Re: New decoration type

by jin_xi » Post

this would be nice indeed for all sorts of generated stuff. it can currently only be done with workarounds.

User avatar
oleastre
Member
Posts: 81
Joined: Wed Aug 13, 2014 21:39
GitHub: oleastre
In-game: oleastre

Re: New decoration type

by oleastre » Post

Nice to see some progress on standard biomes for mg v5/7, thanks for all that work !

Of course my current solution using saplings is only a workaround...

Lua defined schematics is maybe sufficient to generate trees, but it's just a predefined structure with some random variation.

Allowing to call a lua function will allow you to create almost anything. Of course probably this will have some performance cost.

User avatar
rubenwardy
Moderator
Posts: 6972
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: Bristol, United Kingdom
Contact:

Re: New decoration type

by rubenwardy » Post

You may be interested in L system trees.
Renewed Tab (my browser add-on) | Donate | Mods | Minetest Modding Book

Hello profile reader

User avatar
oleastre
Member
Posts: 81
Joined: Wed Aug 13, 2014 21:39
GitHub: oleastre
In-game: oleastre

Re: New decoration type

by oleastre » Post

And currently there is no way to register L system based trees as decoration (from what I've seen, there is some initial code, but that never calls the actual generation )...

Aside of that, my suggestion is more generic than trees... it's just that's what triggered the idea.

jin_xi
Member
Posts: 165
Joined: Mon Jul 02, 2012 18:19

Re: New decoration type

by jin_xi » Post

ugh. the lsystem trees are kinda meh. in short lsystems is a weird way to create turtle programs, and for fauna in mt the scale is all wrong. it would be better to have a more generic turtle system in cpp and feed it with lua generated ltree grammar or whaterver else.

oloastre, i did some work trying to achieve what you want, but its an ugly workaround:

1. register some decoration, have it place air.
2. register gen_notify function, have it notify your decos id
3. get positions of placed decos from gennotify object
4. spawn whatever lua voxel manipulator according to deco id at position

User avatar
oleastre
Member
Posts: 81
Joined: Wed Aug 13, 2014 21:39
GitHub: oleastre
In-game: oleastre

Re: New decoration type

by oleastre » Post

I came to the same conclusion, that's what I did in my simplev7 branch to generate trees, and what triggered this idea.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests