make precalc make sense
This commit is contained in:
parent
0d5e698bcb
commit
bd54be7147
30
README.md
30
README.md
|
@ -175,16 +175,40 @@ if the position passed to `luamap.logic` is outside of the y-range, then
|
|||
sure to set the y-range to completely encompass the range that you expect to
|
||||
find your noises.
|
||||
|
||||
|
||||
### luamap.precalc
|
||||
|
||||
```lua
|
||||
luamap.precalc(data, area, vm, minp, maxp, seed)
|
||||
```
|
||||
|
||||
DESCRIPTION: An overridable function called just before calculating the noise
|
||||
and calling the logic function for each node. Best practice is to save the old
|
||||
function and call it before adding one's own logic, just like with
|
||||
`luamap.logic`
|
||||
|
||||
|
||||
### luamap.postcalc
|
||||
|
||||
```lua
|
||||
luamap.postcalc(data, area, vm, minp, maxp, seed)
|
||||
```
|
||||
|
||||
DESCRIPTION: An overridable function called just before setting the map lighting
|
||||
and data. It offers compatability with biomegen, which needs these parameters to
|
||||
function. Best practice is to save the old function and call it before adding
|
||||
one's own logic, just like with `luamap.logic`
|
||||
and data after the noise has been calculated and luamap.logic has been called
|
||||
for each node in the mapblock. It offers compatability with biomegen by Gaël de
|
||||
Sailly, which needs these parameters to function. Best practice is to save the
|
||||
old function and call it before adding one's own logic, just like with
|
||||
`luamap.logic`
|
||||
|
||||
example:
|
||||
```lua
|
||||
local old_postcalc = luamap.precalc
|
||||
function luamap.postcalc(data, area, vm, minp, maxp, seed)
|
||||
old_postcalc(data, area, vm, minp, maxp, seed)
|
||||
biomegen.generate_all(data, area, vm, minp, maxp, seed)
|
||||
end
|
||||
```
|
||||
|
||||
### luamap.set_singlenode
|
||||
|
||||
|
|
10
init.lua
10
init.lua
|
@ -50,6 +50,12 @@ function luamap.precalc(data, area, vm, minp, maxp, seed)
|
|||
return
|
||||
end
|
||||
|
||||
-- override this function
|
||||
function luamap.postcalc(data, area, vm, minp, maxp, seed)
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- Set mapgen parameters
|
||||
function luamap.set_singlenode()
|
||||
|
@ -78,6 +84,8 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||
local minpos3d = {x=minp.x, y=minp.y-16, z=minp.z}
|
||||
local minpos2d = {x=minp.x, y=minp.z}
|
||||
|
||||
luamap.precalc(data, area, vm, minp, maxp, seed)
|
||||
|
||||
for name,elements in pairs(noises_2d) do
|
||||
if emin.y >= elements.ymin and emax.y <= elements.ymax then
|
||||
noises_2d[name].nobj = noises_2d[name].nobj or minetest.get_perlin_map(noises_2d[name].np_vals, chulens2d)
|
||||
|
@ -132,7 +140,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||
end
|
||||
i3dz=i3dz+zstride
|
||||
end
|
||||
luamap.precalc(data, area, vm, minp, maxp, seed)
|
||||
luamap.postcalc(data, area, vm, minp, maxp, seed)
|
||||
vm:set_data(data)
|
||||
vm:calc_lighting()
|
||||
vm:write_to_map(data)
|
||||
|
|
Loading…
Reference in New Issue