Make tower automatically scale to rift size
Tower now decides its width by the width of the world's fracture, via a global variable. Also cleaned up three files by changing content-id holding variables to use the c_ prefix.
This commit is contained in:
parent
404ffa21e2
commit
441d1c7873
@ -11,7 +11,7 @@ local blastrad_radius=100 --how wide should the blast radius be aro
|
||||
local blastrad_scatter=0.25
|
||||
local blastrad_top=100 --don't bother blasting higher than this
|
||||
local blastrad_bot=-20 --don't bother blasting lower than this.
|
||||
local blastrad_material=minetest.get_content_id("default:dry_dirt")
|
||||
local c_blastmat = minetest.get_content_id("default:dry_dirt")
|
||||
|
||||
|
||||
--caclulated constants
|
||||
@ -72,20 +72,20 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
||||
--check if we are in the last scatter% of the blast radius
|
||||
if dist/blastrad_radius < blastrad_noscatter then
|
||||
--if not, change this node and the next node down to dry dirt
|
||||
data[vi]=blastrad_material --hit surface, change to dry dirt
|
||||
data[vi] = c_blastmat --hit surface, change to dry dirt
|
||||
changed=true
|
||||
if y > ymin then
|
||||
local vi = area:index(x, y-1, z)
|
||||
data[vi]=blastrad_material --make it 2 deep
|
||||
data[vi] = c_blastmat --make it 2 deep
|
||||
end --if y > ymin
|
||||
elseif math.random() < 1-(((dist/blastrad_radius)-blastrad_noscatter)/blastrad_scatter) then
|
||||
--but if we are in the last scatter% only change one deep randomly.
|
||||
data[vi]=blastrad_material --change to dry dirt
|
||||
data[vi] = c_blastmat --change to dry dirt
|
||||
changed=true
|
||||
end -- dist/blastrad_radius < blastrad_noscatter
|
||||
end --if not air
|
||||
y=y-1
|
||||
until y < y0 or data[vi] == blastrad_material
|
||||
until y < y0 or data[vi] == c_blastmat
|
||||
end -- if in blast area
|
||||
end -- end 'x' loop
|
||||
end -- end 'z' loop
|
||||
|
@ -1,22 +1,25 @@
|
||||
-- mods/default/mapgen.lua
|
||||
|
||||
fracturerift = {} --Global container for variables accessed by other mods
|
||||
|
||||
---
|
||||
--- constants
|
||||
---
|
||||
|
||||
local fracrift_width=80 --how wide the rift will be
|
||||
fracturerift.width = 80 --how wide the rift will be --fracrift. prefix added so that it can be referenced by other mods (e.g. worldstonetower)
|
||||
|
||||
local fracrift_depth_air=33000 --how deep before the water
|
||||
local fracrift_depth_water=20 --how deep the water will be
|
||||
local fracrift_top=100 --max height to scan for land to remove
|
||||
local fracrift_bottomsmooth=0.995 --odds of bottom being smooth
|
||||
local fracrift_waterfallchance=0.997 --odds of NOT having a waterfall hole in wall
|
||||
local fracrift_material=minetest.get_content_id("default:sandstone") -- Makes more sense, no?
|
||||
local c_fracrift_material=minetest.get_content_id("default:sandstone") -- Makes more sense, no?
|
||||
minetest.get_content_id("default:sandstone")
|
||||
|
||||
--calculated constants
|
||||
local fracrift_half=fracrift_width/2
|
||||
local fracrift_edge=fracrift_half+1
|
||||
local fracrift_depth=-(fracrift_depth_air+fracrift_depth_water)
|
||||
local fracrift_half = fracturerift.width/2
|
||||
local fracrift_edge = fracrift_half+1
|
||||
local fracrift_depth = -(fracrift_depth_air+fracrift_depth_water)
|
||||
local fracrift_waterstart=-(fracrift_depth_air+1)
|
||||
|
||||
--grab content IDs -- You need these to efficiently access and set node data. get_node() works, but is far slower
|
||||
@ -88,7 +91,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
||||
else
|
||||
if (x < -fracrift_edge/3 or x > fracrift_edge/3) then -- Put limits in to make sure the chasm always stays at least some ways open
|
||||
if data[vi] == c_water then -- If there's water, make it wall material so as not to drain the oceans :P
|
||||
data[vi] = fracrift_material
|
||||
data[vi] = c_fracrift_material
|
||||
end
|
||||
else
|
||||
if (x > -fracrift_edge/3 or x < fracrift_edge/3) then -- In the limits, always hollow this
|
||||
@ -101,7 +104,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
||||
|
||||
if x == -fracrift_edge or x == fracrift_edge then -- x is on edge
|
||||
if data[vi] == c_water and math.random() < fracrift_waterfallchance and (math.abs(nvals_walls[nixyz]) - grad) > -0.1 then
|
||||
data[vi]=fracrift_material
|
||||
data[vi]=c_fracrift_material
|
||||
changed=true
|
||||
end -- change water to stone on edge
|
||||
end -- if x == -fracrift_edge or x == fracrift_edge
|
||||
|
@ -5,16 +5,16 @@
|
||||
---
|
||||
local wst_pos={x=0,y=0,z=0}
|
||||
local wst_radius=15
|
||||
local wst_length=100
|
||||
local wst_length = fracturerift.width + 20
|
||||
local wst_floorheight=8
|
||||
local wst_shrinkheight=20
|
||||
|
||||
local wst_floorholeodds=0.1
|
||||
local wst_wallholeodds=0.01
|
||||
|
||||
local wst_material_wall = minetest.get_content_id("default:obsidianbrick")
|
||||
local wst_material_floor = minetest.get_content_id("default:desert_stonebrick")
|
||||
local wst_material_stair = minetest.get_content_id("stairs:stair_obsidianbrick")
|
||||
local c_wall = minetest.get_content_id("default:obsidianbrick")
|
||||
local c_floor = minetest.get_content_id("default:desert_stonebrick")
|
||||
local c_stair = minetest.get_content_id("stairs:stair_obsidianbrick")
|
||||
|
||||
--local wst_start={x=0,y=0,z=0} --where to start trying to put the tower.
|
||||
--local wst_lookdist=100 --distance to look for starting point.
|
||||
@ -41,13 +41,13 @@ local np_dmg = {
|
||||
offset = 0,
|
||||
scale = 1,
|
||||
--spread = {x=192, y=512, z=512}, -- squashed 2:1
|
||||
--spread = {x=200, y=80, z=80},
|
||||
spread = {x=15, y=5, z=5},
|
||||
seed = 133742, --a LEET answer to life, the universe, and everything
|
||||
--spread = {x=200, y=80, z=80},
|
||||
spread = {x=15, y=8, z=8},
|
||||
seed = 314159, --everyone loves pi(e)
|
||||
octaves = 3,
|
||||
persist = 0.67
|
||||
}
|
||||
local wst_dmg_lvl=0.7
|
||||
local wst_dmg_lvl=0.7 --threshold for holes in the tower. Smaller means larger holes
|
||||
|
||||
|
||||
|
||||
@ -110,21 +110,21 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
||||
radius=wst_radius-(math.floor(xdist/wst_shrinkheight))
|
||||
if yzdist==radius then
|
||||
if math.abs(nvals_dmg[nixyz]) > wst_dmg_lvl then
|
||||
data[vi] = c_air
|
||||
data[vi] = c_air
|
||||
else
|
||||
data[vi]=wst_material_wall
|
||||
data[vi] = c_wall
|
||||
end
|
||||
elseif yzdist<radius then
|
||||
if (xdist/wst_floorheight)== math.floor(xdist/wst_floorheight) and
|
||||
math.abs(nvals_dmg[nixyz]) <= wst_dmg_lvl then
|
||||
data[vi]=wst_material_floor
|
||||
data[vi] = c_floor
|
||||
else
|
||||
data[vi] = c_air
|
||||
data[vi] = c_air
|
||||
end -- if (xdist/wst_floorheight)
|
||||
end --if yzdist
|
||||
end --if x>=wst_min.x
|
||||
nixyz = nixyz + 1
|
||||
vi = vi + 1
|
||||
nixyz = nixyz + 1
|
||||
vi = vi + 1
|
||||
end -- end 'x' loop
|
||||
end -- end 'y' loop
|
||||
end -- end 'z' loop
|
||||
|
Loading…
x
Reference in New Issue
Block a user