minetest.generate_decorations() crashing server.

Post Reply
LC Creations
Member
Posts: 157
Joined: Mon Feb 18, 2019 02:53

minetest.generate_decorations() crashing server.

by LC Creations » Post

So I'm working on a mod that replaces nodes with ash nodes near a "fire:basic_flame" node in an abm. Eventually, through another ABM, that ash node will return back to a the node it originally was. For example, 'default:dirt_with_grass' > 'mymod:ash' > 'default:dirt_with_grass'. If it was a dirt node, it goes back to dirt. Anyway... For example, if i want to burn down a rainforest, i also want the forest to grow back and not just the soil nodes. I thought "minetest.generate_decorations()" was a good way to accomplish this in the abm after replacing the ash node with it's original node but using this crashes the server.

My code is as follows:

Code: Select all

local p1 = {x=0,y=0,z=0}
local p2 = {x=5,y=5,z=5}
local vm = VoxelManip(p1,p2)
minetest.generate_decorations(vm)
Minetest crashes with NO debug information. Minetest stops responding in windows 10.

ShadMOrdre
Member
Posts: 755
Joined: Mon Dec 29, 2014 08:07
GitHub: ShadMOrdre
In-game: shadmordre
Location: USA

Re: minetest.generate_decorations() crashing server.

by ShadMOrdre » Post

I don't think this function works outside of on_generate.

You might consider node timers or an LVM instead.
MY MODS: lib_ecology lib_materials lib_clouds lib_node_shapes ---- Inspired By: Open Source Virtual World Simulator Opensimulator.

LC Creations
Member
Posts: 157
Joined: Mon Feb 18, 2019 02:53

Re: minetest.generate_decorations() crashing server.

by LC Creations » Post

ShadMOrdre wrote:
Mon Jul 27, 2020 07:59
I don't think this function works outside of on_generate.

You might consider node timers or an LVM instead.
This won't work. An LVM can only work on load. Thats it. My code needs to execute all the time.

User avatar
Krock
Developer
Posts: 4587
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker
Location: Switzerland
Contact:

Re: minetest.generate_decorations() crashing server.

by Krock » Post

Code: Select all

local vm = minetest.get_voxel_manip()
local emin, emax = vm:read_from_map(p1, p2)

minetest.generate_decorations(vm)

vm:calc_lighting()
vm:write_to_map()
vm:update_liquids()
Not tested. Based off copy&paste from lualandmg.
Look, I programmed a bug for you. >> Mod Search Engine << - Mods by Krock - DuckDuckGo mod search bang: !mtmod <keyword here>

Skamiz Kazzarch
Member
Posts: 197
Joined: Fri Mar 09, 2018 20:34
GitHub: Skamiz
In-game: Skamiz
Location: la lojbaugag.

Re: minetest.generate_decorations() crashing server.

by Skamiz Kazzarch » Post

That also causes an instanteous crash.

While playing around I did notice though that in one of several worlds I tried it in it did not cause a crash. Curious.

edit:
Tried changing the cooridnates to 2000, 2000, 2000 and 2005, 2005, 2005. Now the world which didn't crash before, did crash. Changing the coordinates back resulted in that one world not crashing again.

ShadMOrdre
Member
Posts: 755
Joined: Mon Dec 29, 2014 08:07
GitHub: ShadMOrdre
In-game: shadmordre
Location: USA

Re: minetest.generate_decorations() crashing server.

by ShadMOrdre » Post

I don't think this function works outside of on_generate.
The lua_api.txt document clearly states that a VM must be used. Hence the LVM suggestion.

IIRK, this question has been answered a few times in the mapgen thread, by paramat, or in a related topic regarding the use of generate ores, decorations, and such. I do believe that these functions are stated therein to be only available, and thus usable, in a minetest.register_on_generated definition. Maybe better to ask mapgen questions on the mapgen thread. Paramat pays somewhat closer attention to that thread, me thinks.

I currently use these two functions to ensure that lib_materials / lib_ecology biomes, ores, decorations, schematics, and other things generate at mapgen. They are functional, and do not crash. These are used daily, within my custom mapgen.

I use stable 5.2.0, atm. I cannot verify functionality in any later release or dev version.
MY MODS: lib_ecology lib_materials lib_clouds lib_node_shapes ---- Inspired By: Open Source Virtual World Simulator Opensimulator.

Skamiz Kazzarch
Member
Posts: 197
Joined: Fri Mar 09, 2018 20:34
GitHub: Skamiz
In-game: Skamiz
Location: la lojbaugag.

Re: minetest.generate_decorations() crashing server.

by Skamiz Kazzarch » Post

LC Creations wrote:
Mon Jul 27, 2020 16:26
This won't work. An LVM can only work on load. Thats it. My code needs to execute all the time.
You are confusing an LVM(Lua Voxel Manipulator) for a LBM(Loading Block Modifier).
ShadMOrdre wrote:
Mon Jul 27, 2020 22:15
The lua_api.txt document clearly states that a VM must be used. Hence the LVM suggestion
To my understanding VM(VoxelManip) and LVM(Lua Voxel Manipulator) both refer to the same thing. Which they are already using. So I don't quite understand what it is you are suggesting.
ShadMOrdre wrote:
Mon Jul 27, 2020 22:15
... only available, and thus usable, in a minetest.register_on_generated definition.
This is false, just now I managed to succesfully call it from a chatcommand to generate decorations in the current chunk.

Code: Select all

minetest.register_chatcommand("gendeco", {
	params = "",
	description = "generate decorations in current mapchunk.",
	privs = {server=true},
	func = function(name, param)
		local player = minetest.get_player_by_name(name)
		local pos = player:get_pos()
		local minp = {x = 80 * math.floor((pos.x + 32) / 80) - 33,
					y = 80 * math.floor((pos.y + 32) / 80) - 33,
					z = 80 * math.floor((pos.z + 32) / 80) - 33}
		local maxp = {x = minp.x + 81, y = minp.y + 81, z = minp.z + 81}

		local vm = minetest.get_voxel_manip()
		local emin, emax = vm:read_from_map(minp, maxp)

		minetest.generate_decorations(vm)

		vm:write_to_map()
	end,
})

A thing to note: The VoxelManip allways retrieves the mapdata in whole blocks(16*16*16) and 'generate_decorations' generates decorations only in blocks which aren't at the edge of the volume loaded into the VM. That is, to generate decorations in one block, you need to load 3*3*3 blocks into the VM.
That's why the code loads an area of 82 nodes across into the voxelmanip. The extra node in each direction causes the VM to load a whole block more in each direction. Otherwise only the interior 3*3*3 blocks of the chunk would get decorations.


Edit: Ignore the last part, that only applies when no explicit coordinates are provided to 'generate_decorations'.
And, as it turns out, if you do provide the the explicit coordinates it doesn't seem to crash.

So if I were to take the original example, it should look like this:

Code: Select all

local p1 = {x=0,y=0,z=0}
local p2 = {x=5,y=5,z=5}
local vm = VoxelManip(p1,p2)
minetest.generate_decorations(vm, p1, p2)
that should work.

So the issue causing the crash seems to be, that for small areas and some other mysterious conditions (seriously, sometimes it caused a crash in one world, but not another) if 'generate_decorations' is left to figure out the coordinate limmits of decorations on it's own, it will run into a fatal crash.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest