Post your mapgen questions here (modding or engine)

Gerald
Member
Posts: 93
Joined: Sun Dec 28, 2014 10:35
In-game: gerald7
Location: Germany

Re: Post your mapgen questions here (modding or engine)

by Gerald » Post

I need to start a node timer of a decoration. My current solution is to generate placeholder nodes and replace them by an lbm.
Spoiler

Code: Select all

minetest.register_decoration({
  decoration = "mod:placeholder",
  [...]
})
minetest.register_lbm({
  nodenames = "mod:placeholder",
  run_at_every_load = true,
  action = function(pos, node)
    node.name = "mod:real_node"
    minetest.swap_node(pos, node)
    minetest.get_node_timer(pos):start(time)
  end,
})
Can this be done any better? I know that LOTT uses an abm instead of an lbm for a similar task.

FaceDeer
Member
Posts: 506
Joined: Sat Aug 29, 2015 19:01
GitHub: FaceDeer

Re: Post your mapgen questions here (modding or engine)

by FaceDeer » Post

Could perhaps get rid of the need for a placeholder node by doing this?
Spoiler

Code: Select all

minetest.register_lbm({
  nodenames = "mod:real_node",
  action = function(pos, node)
    local timer = minetest.get_node_timer(pos)
    if not timer:is_started() then
        timer:start(time)
    end
  end,
})

Gerald
Member
Posts: 93
Joined: Sun Dec 28, 2014 10:35
In-game: gerald7
Location: Germany

Re: Post your mapgen questions here (modding or engine)

by Gerald » Post

FaceDeer wrote:Could perhaps get rid of the need for a placeholder node by doing this?
Yes, but then the lbm is executed more often.

FaceDeer
Member
Posts: 506
Joined: Sat Aug 29, 2015 19:01
GitHub: FaceDeer

Re: Post your mapgen questions here (modding or engine)

by FaceDeer » Post

Gerald wrote: Yes, but then the lbm is executed more often.
I removed the run_at_every_load = true bit, it should still only run once. Unless lbms don't run at all for freshly-mapgenned nodes, in which case you'd need to put that back and it would indeed execute more often. Doesn't seem like all that huge a load on the server, though, since it's only for a decoration node and not default:stone or something similarly widespread.

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

Re: Post your mapgen questions here (modding or engine)

by paramat » Post

Maybe use 'gennotify'? https://github.com/minetest/minetest/bl ... .txt#L3580
Use that in an 'on generated' function to get a list of positions of all decorations placed. Maybe there is a way to get the decoration id for the decoration with the node timer so that you can select the corresponding positions.
When do you want to start the nodetimer, at mapgen only? On every mapblock load?

Gerald
Member
Posts: 93
Joined: Sun Dec 28, 2014 10:35
In-game: gerald7
Location: Germany

Re: Post your mapgen questions here (modding or engine)

by Gerald » Post

FaceDeer wrote: I removed the run_at_every_load = true bit, it should still only run once. Unless lbms don't run at all for freshly-mapgenned nodes, in which case you'd need to put that back and it would indeed execute more often.
Just tested it, if run_at_every_load = false new nodes are not processed.
Another problem is that the node timer will replace the node, what resets the lbm status.
paramat wrote:Maybe use 'gennotify'? https://github.com/minetest/minetest/bl ... .txt#L3580
Use that in an 'on generated' function to get a list of positions of all decorations placed. Maybe there is a way to get the decoration id for the decoration with the node timer so that you can select the corresponding positions.
When do you want to start the nodetimer, at mapgen only? On every mapblock load?
This seems better but complex.
Mapgen only is sufficient.

User avatar
TumeniNodes
Member
Posts: 2943
Joined: Fri Feb 26, 2016 19:49
GitHub: TumeniNodes
IRC: tumeninodes
In-game: TumeniNodes
Location: in the dark recesses of the mind
Contact:

Re: Post your mapgen questions here (modding or engine)

by TumeniNodes » Post

Image

Time to poke around :P
Thank you! (just noticed it)

make sure you watch the vid below:
https://www.youtube.com/watch?v=218iXiKhKlg
Attachments
a river runs through it THANK YOU M.png
a river runs through it THANK YOU M.png (754.36 KiB) Viewed 481 times
A Wonderful World

User avatar
azekill_DIABLO
Member
Posts: 7507
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO
Location: OMICRON
Contact:

Re: Post your mapgen questions here (modding or engine)

by azekill_DIABLO » Post

epic.
Gone, but not dead. Contact me on discord: azekill_DIABLO#6565
DMs are always open if you want to get in touch!

User avatar
Devy
Member
Posts: 133
Joined: Sat Jan 21, 2017 02:31
GitHub: DevyHeavy
In-game: devy

Re: Post your mapgen questions here (modding or engine)

by Devy » Post

Hello, I'm working on a mod that will generate layer upon layer of different types of rocks. I'm having trouble figuring out how to start doing this. I have made some small mods before in minetest, but don't know how to start this mod.

All I need is direction on what I need to read for generating rock under biomes that already exist. Thank you!

User avatar
azekill_DIABLO
Member
Posts: 7507
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO
Location: OMICRON
Contact:

Re: Post your mapgen questions here (modding or engine)

by azekill_DIABLO » Post

blob ore?
Gone, but not dead. Contact me on discord: azekill_DIABLO#6565
DMs are always open if you want to get in touch!

User avatar
TumeniNodes
Member
Posts: 2943
Joined: Fri Feb 26, 2016 19:49
GitHub: TumeniNodes
IRC: tumeninodes
In-game: TumeniNodes
Location: in the dark recesses of the mind
Contact:

Re: Post your mapgen questions here (modding or engine)

by TumeniNodes » Post

Hey paramat,

I am posting this here because the former thread is no longer accessible.
I am extremely happy with canyons, and minetest.generate_decorations(vm, pos1, pos2) works perfectly (aside from jungletress getting a bit confused about where they should, and should not be : P )
But that is not an issue at all. I am getting some really awesome landscapes with it. It's actually a very awesome mod

This, however..., is. Which lines might address these terrain cuts, so I can set them higher to finish the job?
Image

I'm still experimenting and tweaking.., have made only a couple minor changes in code.
When I have enough nice images I will post a link to an album
Attachments
ummmm.png
ummmm.png (720.69 KiB) Viewed 481 times
A Wonderful World

User avatar
Wuzzy
Member
Posts: 4803
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy
Contact:

Re: Post your mapgen questions here (modding or engine)

by Wuzzy » Post

Consider this situtation: I have a schematic (MTS file) with chests and furnaces.
When I place it it with minetest.place_schematic, the chest and furnaces are lacking metadata, which means they are useless.

IIRC metadata is not set for “bulk node placement”. Okay. So I place the schematic anyway. Is there any way I can setup the metadata manually after I placed the schematic? I need a solution which works for arbitrary schematics, so I don't neccessarily know where the chests and furnaces are. Actually, all I need to know are the positions of furnaces and chests for any given schematic. Is there some way to extract this information?

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

Re: Post your mapgen questions here (modding or engine)

by paramat » Post

TumeniNodes, what mapgen is that and can you link the code?

User avatar
TumeniNodes
Member
Posts: 2943
Joined: Fri Feb 26, 2016 19:49
GitHub: TumeniNodes
IRC: tumeninodes
In-game: TumeniNodes
Location: in the dark recesses of the mind
Contact:

Re: Post your mapgen questions here (modding or engine)

by TumeniNodes » Post

heh, sorry.
it's your canyon mod, I should have thought to mention that, and paste the code.

Code: Select all

-- Parameters

-- Water factor is proportion of water surface level to removed stone surface level
local WAFAV = 0.2 -- Water factor average
local WAFAMP = 0.1 -- Water factor amplitude
local MINDEP = 5 -- (0-30) Minimum river depth
local MAXDEP = 7 -- (0-30) Maximum river depth
local TRIVERL = -0.15 -- width
local TRIVERH = 0.10 -- bank slope

-- 2D noise for river channel

local np_river = {
	offset = 0,
	scale = 2,
	spread = {x = 384, y = 384, z = 384},
	seed = 5192098,
	octaves = 1,
	persist = 0.1
}

-- 2D noise for depth variation

local np_depth = {
	offset = 0,
	scale = 1,
	spread = {x = 192, y = 192, z = 192},
	seed = 924,
	octaves = 4,
	persist = 0.5
}

-- 2D noise for water factor

local np_factor = {
	offset = 0,
	scale = 1,
	spread = {x = 512, y = 512, z = 512},
	seed = 13050,
	octaves = 2,
	persist = 0.4
}


-- Stuff

local depran = MAXDEP - MINDEP
local noiran = TRIVERH - TRIVERL
I can't seem to figure where to make changes so the cuts can reach the top of the hills for mg_flat
I have not altered the height of hills for mg_flat btw

after I feel I have everything just right..., I "may" attempt to figure out how to work this into mg_flat
I know it is completely diff but, I want to try to figure it out to see what a mess I can make :D
A Wonderful World

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

Re: Post your mapgen questions here (modding or engine)

by paramat » Post

Mgv6 does not extend above y = 47, so canyon mod may not excavate above y = 47. In the 'on generated' function there may be a condition that stops generation if maxp.y > 47 or minp.y > -32 or something similar.
You'll need to link to the mod code on Github for me to see it.

User avatar
TumeniNodes
Member
Posts: 2943
Joined: Fri Feb 26, 2016 19:49
GitHub: TumeniNodes
IRC: tumeninodes
In-game: TumeniNodes
Location: in the dark recesses of the mind
Contact:

Re: Post your mapgen questions here (modding or engine)

by TumeniNodes » Post

A Wonderful World

Sokomine
Member
Posts: 4290
Joined: Sun Sep 09, 2012 17:31
GitHub: Sokomine
IRC: Sokomine
In-game: Sokomine

Re: Post your mapgen questions here (modding or engine)

by Sokomine » Post

Wuzzy wrote: IIRC metadata is not set for “bulk node placement”. Okay. So I place the schematic anyway. Is there any way I can setup the metadata manually after I placed the schematic? I need a solution which works for arbitrary schematics, so I don't neccessarily know where the chests and furnaces are. Actually, all I need to know are the positions of furnaces and chests for any given schematic. Is there some way to extract this information?
In handle_schematics, the list of nodes contained in the schematic gives a first hint about which nodes will need special handling (on_construct, fill chests, place doors, grow trees, ..). The placement of the schematics happens manually via VoxelManip. Each position of a node that requires special treatment is stored in a table. After all work is done (all nodes set, VoxelManip written back), the necessary calls to set up metadata correctly are done.

handle_schematics.analyze_mts_file reads the .mts file and returns (among other data) scm_data_cache[y][x][z], which contains information of which node is to be placed where. Maybe you can get a similar result with minetest.serialize_schematic. You'd still have to apply rotation and offset to the coordinates and search the table once for the nodes that need special handling.
A list of my mods can be found here.

User avatar
stu
Member
Posts: 923
Joined: Sat Feb 02, 2013 02:51
GitHub: stujones11
Location: United Kingdom

Re: Post your mapgen questions here (modding or engine)

by stu » Post

Suppose I have several mods doing stuff in 'on_generated', is there any way I can control the order in which these take place? Does the order of registration matter here or would the outcome be undefined? I suspect it will be but thought it was worth asking anyway. TIA

User avatar
duane
Member
Posts: 1715
Joined: Wed Aug 19, 2015 19:11
GitHub: duane-r
Location: Oklahoma City
Contact:

Re: Post your mapgen questions here (modding or engine)

by duane » Post

Wuzzy wrote:IIRC metadata is not set for “bulk node placement”. Okay. So I place the schematic anyway. Is there any way I can setup the metadata manually after I placed the schematic? I need a solution which works for arbitrary schematics, so I don't neccessarily know where the chests and furnaces are. Actually, all I need to know are the positions of furnaces and chests for any given schematic. Is there some way to extract this information?
I've got code to extract this from a volume and put it back after the mapgen runs, in Squaresville. All the houses have furnishings, including cabinets and stoves that work after placement. In this case, I saved the data together as worldedit files, but the metadata is still added after the voxelmanip writes.

You can just copy the meta section of a worldedit grab for the specifics for your case.
Believe in people and you don't need to believe anything else.

User avatar
duane
Member
Posts: 1715
Joined: Wed Aug 19, 2015 19:11
GitHub: duane-r
Location: Oklahoma City
Contact:

Re: Post your mapgen questions here (modding or engine)

by duane » Post

stu wrote:Suppose I have several mods doing stuff in 'on_generated', is there any way I can control the order in which these take place? Does the order of registration matter here or would the outcome be undefined? I suspect it will be but thought it was worth asking anyway. TIA
You can control it, and it does make a difference.

Code: Select all

table.insert(minetest.registered_on_generateds, 1, vmg.generate)
The on_generated hooks are stored in a standard table, so inserting yours first will give it first priority. However, that requires that your mod runs last (ideally), so you haven't actually solved much.

The best way to do it is with your depends.txt file. Add a line to each mod's depends for your main mapgen, or mapgens, that need to run first. Or, you can add lines to your main mapgen's depends.txt for each other mod and use the table insert above to override them.
Believe in people and you don't need to believe anything else.

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

Re: Post your mapgen questions here (modding or engine)

by paramat » Post

Tumeninodes

Code: Select all

minetest.register_on_generated(function(minp, maxp, seed)
	if not (minp.y < 1 and maxp.y > 1) then -- if not surface chunk
		return
	end
That conditional return is restricting generation to the mapchunk containing y = 1.

User avatar
TumeniNodes
Member
Posts: 2943
Joined: Fri Feb 26, 2016 19:49
GitHub: TumeniNodes
IRC: tumeninodes
In-game: TumeniNodes
Location: in the dark recesses of the mind
Contact:

Re: Post your mapgen questions here (modding or engine)

by TumeniNodes » Post

Oh boy... now I get to figure out where the increase needs to be made :P

I tried to change maxp.y > 3 but got an error, originally, so I switched it back and have not looked at it again yet.
So I need to figure out all the instances this needs to be adjusted?

And, do manp.y < and > have to be the same value?
because as far as I "think" I understand this is, manp.y < cuts into the surface below water, and > above?

rrrggggg I feel so stupid with this stuff. but I keep chuggin along
A Wonderful World

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

Re: Post your mapgen questions here (modding or engine)

by paramat » Post

minp and maxp are the opposite corners of the mapchunk being generated, mapchunks are by default 80^3 nodes and the surface mapchunk extends from y = -32 to y = 47. Since you want the mapchunk above to be excavated too try:

if maxp.y < -32 or minp.y > 127 then
return
end

If your hills get very high increase the '127' by 80 or 160.

User avatar
TumeniNodes
Member
Posts: 2943
Joined: Fri Feb 26, 2016 19:49
GitHub: TumeniNodes
IRC: tumeninodes
In-game: TumeniNodes
Location: in the dark recesses of the mind
Contact:

Re: Post your mapgen questions here (modding or engine)

by TumeniNodes » Post

Ahhh, now I understand.
Thank you very much paramat : )
A Wonderful World

User avatar
TumeniNodes
Member
Posts: 2943
Joined: Fri Feb 26, 2016 19:49
GitHub: TumeniNodes
IRC: tumeninodes
In-game: TumeniNodes
Location: in the dark recesses of the mind
Contact:

Re: Post your mapgen questions here (modding or engine)

by TumeniNodes » Post

paramat wrote:minp and maxp are the opposite corners of the mapchunk being generated, mapchunks are by default 80^3 nodes and the surface mapchunk extends from y = -32 to y = 47. Since you want the mapchunk above to be excavated too try:

if maxp.y < -32 or minp.y > 127 then
return
end

If your hills get very high increase the '127' by 80 or 160.
this definitely cuts through those mountains all the way..., however, it also produces a mirrored river above in the sky, which then flows down :P
I have tried with different numbers but to no avail. I am missing something... (besides my brain) :P thought I'd beat you to it :D
A Wonderful World

Post Reply

Who is online

Users browsing this forum: No registered users and 10 guests