Page 1 of 1

minetest.register_on_generated()?

PostPosted: Sat Feb 16, 2013 00:28
by 0gb.us
To better understand minetest.register_on_generated(), I added this code to my game:

minetest.register_on_generated(function(minp, maxp, seed)
local debug = "minp="..(minetest.pos_to_string(minp))..", maxp="..(minetest.pos_to_string(maxp))..", seed="..seed
print(debug)
minetest.chat_send_all(debug)
end)


The output was quite strange though.

minp=(0,0,0), maxp=(15,15,15), seed=0
minp=(0,0,0), maxp=(15,15,15), seed=0
minp=(0,0,0), maxp=(15,15,15), seed=0
minp=(-30832,-112,30768), maxp=(-30753,-33,30847), seed=782612992
minp=(-30832,-112,30848), maxp=(-30753,-33,30927), seed=3833351712
minp=(-30832,48,30768), maxp=(-30753,127,30847), seed=789352672
minp=(0,0,0), maxp=(15,15,15), seed=0
minp=(0,0,0), maxp=(15,15,15), seed=0
minp=(0,0,0), maxp=(15,15,15), seed=0
minp=(0,0,0), maxp=(15,15,15), seed=0
minp=(0,0,0), maxp=(15,15,15), seed=0
minp=(0,0,0), maxp=(15,15,15), seed=0
minp=(0,0,0), maxp=(15,15,15), seed=0
minp=(0,0,0), maxp=(15,15,15), seed=0
minp=(-30832,-32,30688), maxp=(-30753,47,30767), seed=2030211408
minp=(0,0,0), maxp=(15,15,15), seed=0
minp=(-30912,-32,30688), maxp=(-30833,47,30767), seed=2030209568
minp=(0,0,0), maxp=(15,15,15), seed=0
minp=(0,0,0), maxp=(15,15,15), seed=0
minp=(-30832,48,30688), maxp=(-30753,127,30767), seed=2033581248
minp=(-30832,-112,30688), maxp=(-30753,-33,30767), seed=2026841568


The seed keeps changing, which I imagine is because the seed used by the function is some permutation to the coordinates and the world seed or something. But almost every line is "minp=(0,0,0), maxp=(15,15,15), seed=0" (My exert doesn't show that, but about 90% of the time, that's the line that is displayed.) Is there some reason why it keeps trying to edit the center map chunk? I'm at the edge of the world (to insure new chunks are generated) and the most common coordinates are still positioned in the spawn area.

PostPosted: Sat Feb 16, 2013 15:13
by PilzAdam
The seed param is the blockseed, so its different for each block.

PostPosted: Sat Feb 16, 2013 15:20
by 0gb.us
Okay. I figured something like that. But why does it keep trying to generate the map chunk at the very center of the map when I am steps away from the very edge of the map? "minp=(0,0,0), maxp=(15,15,15)"

PostPosted: Sat Feb 16, 2013 15:38
by PilzAdam

PostPosted: Mon Feb 18, 2013 12:01
by 0gb.us
So it's an edge of the map issue. Thanks! I just tested a bit closer in, and I was able to get better test data.

PostPosted: Mon Feb 18, 2013 22:02
by 0gb.us
Apparently, the map generator tries to regenerate the map chunk in the center when it would normally generate nodes beyond the edge of the game.

Hmmm. I wonder if the center chunk would be regenerated if a player stood there to keep it loaded while another player stood at the edge .... I'll have to test that. My guess it that the C++ mapgen won't replace the center chunk, but the Lua scrtpts are clearly being used. So if someone build a stone structure there for example, it may end up with ore in it.

EDIT: My hunch was right. There are no signs of C++ mapgen regenerating the center chunk, but coal ore pops up in the stone I left there. No iron ore though, with my seed. With a different seed, iron may appear as well. Or if it is a desert, it may respawn cactus and dry shrubs.

PostPosted: Tue Feb 19, 2013 14:55
by PilzAdam
0gb.us wrote:Apparently, the map generator tries to regenerate the map chunk in the center when it would normally generate nodes beyond the edge of the game.

Hmmm. I wonder if the center chunk would be regenerated if a player stood there to keep it loaded while another player stood at the edge .... I'll have to test that. My guess it that the C++ mapgen won't replace the center chunk, but the Lua scrtpts are clearly being used. So if someone build a stone structure there for example, it may end up with ore in it.

EDIT: My hunch was right. There are no signs of C++ mapgen regenerating the center chunk, but coal ore pops up in the stone I left there. No iron ore though, with my seed. With a different seed, iron may appear as well. Or if it is a desert, it may respawn cactus and dry shrubs.

Thats because the Lua API call ignores the no_op flag.
http://irc.minetest.ru/minetest-dev/2013-02-16#i_2875750

PostPosted: Tue Feb 19, 2013 22:15
by Chinchow
So possibly renewable coal?

PostPosted: Tue Feb 19, 2013 22:27
by 0gb.us
PilzAdam wrote:Thats because the Lua API call ignores the no_op flag.
http://irc.minetest.ru/minetest-dev/2013-02-16#i_2875750


That's very interesting. Though this is nowhere near being worthy of being on the priority list yet, I wonder if there's a way to fix it in the distant future. Maybe after I find the time to learn C++ ....

Chinchow wrote:So possibly renewable coal?


Not truly renewable, at least not until stone is renewable. This just converts some of the stone to coal.

PostPosted: Wed Feb 20, 2013 13:09
by rarkenin
0gb.us wrote:
PilzAdam wrote:Thats because the Lua API call ignores the no_op flag.
http://irc.minetest.ru/minetest-dev/2013-02-16#i_2875750


That's very interesting. Though this is nowhere near being worthy of being on the priority list yet, I wonder if there's a way to fix it in the distant future. Maybe after I find the time to learn C++ ....

Chinchow wrote:So possibly renewable coal?


Not truly renewable, at least not until stone is renewable. This just converts some of the stone to coal.


Actually, if done correctly, you would be able to use renewable wood to smelt cobble to stone, place it, and trigger the bug. Then again, that would require cobble generators.

PostPosted: Wed Feb 20, 2013 21:42
by 0gb.us
rarkenin wrote:Actually, if done correctly, you would be able to use renewable wood to smelt cobble to stone, place it, and trigger the bug. Then again, that would require cobble generators.


Yes, I understand that. You know I only smelt using renewable fuels. But stone/cobble are not renewable.

PostPosted: Sun Feb 24, 2013 04:59
by shadowwraith
What about charcoal

In minecraft you could smelt wood, using wood sticks as a fuel to make charcoal which can thenn be used if there is no coal available.

Since trees can be replanted it is therefore a renewable fuel.

just a thought :)

PostPosted: Sun Feb 24, 2013 06:11
by 0gb.us
shadowwraith wrote:What about charcoal

In minecraft you could smelt wood, using wood sticks as a fuel to make charcoal which can thenn be used if there is no coal available.

Since trees can be replanted it is therefore a renewable fuel.

just a thought :)


Renewable fuel, and more importantly (as trees are ALREADY renewable fuel), renewable torches.

In Minetest, you used to be able to smelt wood to get coal, but that was removed. Since it already existed but was removed, it's likely we won't get it back.

PostPosted: Wed Mar 06, 2013 12:46
by deivan
About stones, after corrected the mod "lava cooling" is possible construct a stone factory. I have one in my game. :)