pass original_content to logic
This commit is contained in:
parent
e1d09f0536
commit
f7b9ee450c
14
README.md
14
README.md
|
@ -13,9 +13,9 @@ local c_stone = minetest.get_content_id("default:stone")
|
||||||
local c_water = minetest.get_content_id("default:water_source")
|
local c_water = minetest.get_content_id("default:water_source")
|
||||||
local water_level = 0
|
local water_level = 0
|
||||||
local old_logic = luamap.logic
|
local old_logic = luamap.logic
|
||||||
function luamap.logic(noise_vals,x,y,z,seed)
|
function luamap.logic(noise_vals,x,y,z,seed,original_content)
|
||||||
-- get any terrain defined in another mod
|
-- get any terrain defined in another mod
|
||||||
local content = old_logic(noise_vals,x,y,z,seed)
|
local content = old_logic(noise_vals,x,y,z,seed,original_content)
|
||||||
-- use our own logic to add to that logic
|
-- use our own logic to add to that logic
|
||||||
-- make any nodes below sea level water and below stone level stone
|
-- make any nodes below sea level water and below stone level stone
|
||||||
if y < water_level then
|
if y < water_level then
|
||||||
|
@ -54,9 +54,9 @@ local c_stone = minetest.get_content_id("default:stone")
|
||||||
local c_water = minetest.get_content_id("default:water_source")
|
local c_water = minetest.get_content_id("default:water_source")
|
||||||
local water_level = 0
|
local water_level = 0
|
||||||
local old_logic = luamap.logic
|
local old_logic = luamap.logic
|
||||||
function luamap.logic(noise_vals,x,y,z,seed)
|
function luamap.logic(noise_vals,x,y,z,seed,original_content)
|
||||||
-- get any terrain defined in another mod
|
-- get any terrain defined in another mod
|
||||||
local content = old_logic(noise_vals,x,y,z,seed)
|
local content = old_logic(noise_vals,x,y,z,seed,original_content)
|
||||||
|
|
||||||
if y < water_level then
|
if y < water_level then
|
||||||
content = c_water
|
content = c_water
|
||||||
|
@ -92,7 +92,7 @@ luamap.register_noise("terrainmap",{
|
||||||
|
|
||||||
### luamap.logic
|
### luamap.logic
|
||||||
```lua
|
```lua
|
||||||
luamap.logic(noise_vals,x,y,z,seed)
|
luamap.logic(noise_vals,x,y,z,seed,original_content)
|
||||||
```
|
```
|
||||||
|
|
||||||
DESCRIPTION: Override this function to define mapgen logic. Best practice is to
|
DESCRIPTION: Override this function to define mapgen logic. Best practice is to
|
||||||
|
@ -121,6 +121,10 @@ The coordinates of the position to set the content for
|
||||||
|
|
||||||
The seed passed to minetest.register_on_generated()
|
The seed passed to minetest.register_on_generated()
|
||||||
|
|
||||||
|
`original_content`
|
||||||
|
|
||||||
|
The content id that the original mapgen created. Air if set to singlenode.
|
||||||
|
|
||||||
RETURNS:
|
RETURNS:
|
||||||
|
|
||||||
should return a content id such as that gotten from
|
should return a content id such as that gotten from
|
||||||
|
|
|
@ -26,10 +26,10 @@ local water_level = 0
|
||||||
|
|
||||||
local old_logic = luamap.logic
|
local old_logic = luamap.logic
|
||||||
|
|
||||||
function luamap.logic(noise_vals,x,y,z,seed)
|
function luamap.logic(noise_vals,x,y,z,seed,original_content)
|
||||||
|
|
||||||
-- get any terrain defined in another mod
|
-- get any terrain defined in another mod
|
||||||
local content = old_logic(noise_vals,x,y,z,seed)
|
local content = old_logic(noise_vals,x,y,z,seed,original_content)
|
||||||
|
|
||||||
if y < water_level then
|
if y < water_level then
|
||||||
content = c_water
|
content = c_water
|
||||||
|
|
6
init.lua
6
init.lua
|
@ -41,8 +41,8 @@ end
|
||||||
local c_air = minetest.get_content_id("air")
|
local c_air = minetest.get_content_id("air")
|
||||||
|
|
||||||
-- override this function
|
-- override this function
|
||||||
function luamap.logic(noise_vals,x,y,z,seed)
|
function luamap.logic(noise_vals,x,y,z,seed,original_content)
|
||||||
return c_air
|
return original_content
|
||||||
end
|
end
|
||||||
|
|
||||||
-- override this function
|
-- override this function
|
||||||
|
@ -131,7 +131,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
||||||
noise_vals[name] = elements.nvals[i3dy]
|
noise_vals[name] = elements.nvals[i3dy]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
data[vi] = logic(noise_vals,x,y,z,seed)
|
data[vi] = logic(noise_vals,x,y,z,seed,data[vi])
|
||||||
i3dy = i3dy + ystride
|
i3dy = i3dy + ystride
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue