Skip to content

Commit

Permalink
Improved oregen
Browse files Browse the repository at this point in the history
  • Loading branch information
pyrollo committed Jun 4, 2019
1 parent 3c0a2b1 commit 09278d1
Show file tree
Hide file tree
Showing 8 changed files with 178 additions and 35 deletions.
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Map generator with hills and craters. The idea is to create a map generator for

![Presentation image of Crater MG](screenshot.png)

**Version**: Proof of concept
**Version**: Alpha

**Dependancies**: default

Expand All @@ -18,12 +18,14 @@ Map generator with hills and craters. The idea is to create a map generator for

To test Crater MG:
* create a new world
<<<<<<< HEAD
* select *minetest_game* game
=======
* select *minetest_game* game
>>>>>>> 1dcfb5a62bad446ca099bd8b5bda54ef5ad8a1ab
* choose *single node* map generator
* enable *cratermg* mod

And explore lunar landcape !

## Remaining todo before beta
* Improve crater minerals (meteorite stones ?)
* Make ore nodes groups consistant with original minetest_game ones
* Add planet stone based recipes (cook, grind, bricks, blocks)
* Separate cobble and sediment (sediment could be like clay) ?
3 changes: 3 additions & 0 deletions config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
-- by custom config
cratermg.use_cratermg_nodes = true

-- Change sky and fog color for better ambiance
cratermg.chamge_ambiance = true

-- Mean surface level
cratermg.surface = 0

Expand Down
1 change: 1 addition & 0 deletions depends.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
default
technic_worldgen?
10 changes: 10 additions & 0 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,14 @@ dofile(cratermg.path..'/mapgen.lua')

if cratermg.use_cratermg_nodes then
dofile(cratermg.path..'/nodes.lua')
if minetest.get_modpath('technic_worldgen') then
dofile(cratermg.path..'/technic.lua')
end
end

if cratermg.chamge_ambiance then
minetest.register_on_joinplayer(function(player)
player:set_sky("#e2aa8c", "plain")
player:set_clouds({density=0})
end)
end
15 changes: 6 additions & 9 deletions mapgen.lua
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ minetest.register_on_generated(function (minp, maxp, blockseed)
else
mapdata[vmiy] = c.vacuum
end
vmiy = vmiy + yinc
vmiy = vmiy + yinc
end
p.stop('base generation')

Expand All @@ -406,8 +406,8 @@ minetest.register_on_generated(function (minp, maxp, blockseed)
if crater.maxp.x >= x and crater.minp.x <= x and
crater.maxp.z >= z and crater.minp.z <= z
then
local d2 = (x-crater.x)*(x-crater.x)
+(z-crater.z)*(z-crater.z)
local d2 = (x-crater.x)*(x-crater.x) +
(z-crater.z)*(z-crater.z)

if d2 <= crater.totalR2 then
ground_level, min_level, max_level,
Expand Down Expand Up @@ -452,10 +452,8 @@ minetest.register_on_generated(function (minp, maxp, blockseed)
n3dy = n3dx
for y = minp.y, maxp.y do
local proba = cracksizemap[n3dy] * (1000 - y + cratermg.surface) / 1000
if math.abs(crack1map[n3dy]) < proba
or math.abs(crack2map[n3dy]) < proba
-- debug for testing
or x>=0
if math.abs(crack1map[n3dy]) < proba or
math.abs(crack2map[n3dy]) < proba
then
mapdata[vmiy] = c.vacuum
end
Expand Down Expand Up @@ -487,8 +485,7 @@ or x>=0
vm:write_to_map()
p.stop('save')
p.stop('total')
print("===")
p.show()
-- p.show()
-- print("generation "..(minetest.pos_to_string(minp)).." - "..(minetest.pos_to_string(maxp))..
-- " took ".. string.format("%.2fms", (os.clock() - tstart) * 1000))
end)
29 changes: 14 additions & 15 deletions nodes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ minetest.register_node("cratermg:stone_with_coal", {
description = "Coal Ore",
tiles = {"default_stone.png^[colorize:#F408^default_mineral_coal.png"},
groups = {cracky = 3},
drop = 'default:coal_lump',
drop = "default:coal_lump",
sounds = default.node_sound_stone_defaults(),
})

Expand All @@ -66,7 +66,7 @@ minetest.register_node("cratermg:stone_with_copper", {
description = "Copper Ore",
tiles = {"default_stone.png^[colorize:#F408^default_mineral_copper.png"},
groups = {cracky = 2},
drop = 'default:copper_lump',
drop = "default:copper_lump",
sounds = default.node_sound_stone_defaults(),
})

Expand Down Expand Up @@ -114,33 +114,32 @@ cratermg.materials.dust = minetest.get_content_id("cratermg:dust")
-- Ores registration
--------------------


cratermg.register_ore({
noise = {scale = 1, octaves = 4, persist = 0.7, offset = -1.3},
ore = 'cratermg:stone_with_mese', spawns_in = 'cratermg:stone'
noise = {scale = 1, octaves = 3, persist = 1, offset = -1.3},
ore = "cratermg:stone_with_mese", spawns_in = "cratermg:stone"
})

cratermg.register_ore({
noise = {scale = 1, octaves = 4, persist = 0.7, offset = -1.3},
ore = 'cratermg:stone_with_diamond', spawns_in = 'cratermg:stone'
noise = {scale = 1, octaves = 3, persist = 1, offset = -1.3},
ore = "cratermg:stone_with_diamond", spawns_in = "cratermg:stone"
})

cratermg.register_ore({
noise = {scale = 0.1, octaves = 2, persist = 0.7},
ore = 'cratermg:stone_with_iron', spawns_in = 'cratermg:stone'
noise = {scale = 1, octaves = 1, persist = 1 },
ore = "cratermg:stone_with_iron", spawns_in = "cratermg:stone"
})

cratermg.register_ore({
noise = {scale = 0.05, octaves = 2, persist = 0.7},
ore = 'cratermg:stone_with_copper', spawns_in = 'cratermg:stone'
noise = {scale = 1, octaves = 1, persist = 1, offset = -0.1},
ore = "cratermg:stone_with_copper", spawns_in = "cratermg:stone"
})

cratermg.register_ore({
noise = {scale = 0.05, octaves = 2, persist = 0.7},
ore = 'cratermg:stone_with_tin', spawns_in = 'cratermg:stone'
noise = {scale = 1, octaves = 2, persist = 1, offset = -1},
ore = "cratermg:stone_with_tin", spawns_in = "cratermg:stone"
})

cratermg.register_ore({
noise = {scale = 0.2, octaves = 1},
ore = 'cratermg:stone_with_coal', spawns_in = 'cratermg:stone'
noise = {scale = 2, octaves = 2, persist = 1, offset = -1.5},
ore = "cratermg:stone_with_coal", spawns_in = "cratermg:stone"
})
45 changes: 39 additions & 6 deletions oregen.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
--[[
Crater MG - Crater Map Generator for Minetest
(c) Pierre-Yves Rollo
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation, either version 2.1 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
--]]

local ores = {}

local nscale = 16
local nscale = 8

-- Simplification of math.fuctions call
local floor, random = math.floor, math.random
Expand Down Expand Up @@ -39,9 +57,25 @@ function cratermg.register_ore(def)
ores[#ores+1] = def
end

local nores, spawns_in, ore, nmap

local function pre_generate()
if nores then return end
nores = #ores
spawns_in = {}
ore = {}
nmap = {}
for index = 1, nores do
spawns_in[index] = ores[index].c_spawns_in
ore[index] = ores[index].c_ore
nmap[index] = ores[index].nmap
end
end

function cratermg.ore_generate(minp, maxp, mapdata, area, p)
pre_generate()

local p = cratermg.profile
local nores = #ores

local nlens3d = {
x=ncoord(maxp.x) - ncoord(minp.x) + 1,
Expand Down Expand Up @@ -70,10 +104,9 @@ function cratermg.ore_generate(minp, maxp, mapdata, area, p)
local nix = ncoord(x-minp.x) + nixy + 1
local cid = mapdata[vmi]
for index = 1, nores do
local ore = ores[index]
if ore.c_spawns_in == cid and
random() < ore.nmap[nix] then
mapdata[vmi] = ore.c_ore
if spawns_in[index] == cid and
random() < nmap[index][nix] then
mapdata[vmi] = ore[index]
break
end
end
Expand Down
98 changes: 98 additions & 0 deletions technic.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
--[[
Crater MG - Crater Map Generator for Minetest
(c) Pierre-Yves Rollo
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation, either version 2.1 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
--]]

-- Technic mod dependant code
-- ==========================

-- Ore nodes registration
-------------------------

minetest.register_node("cratermg:stone_with_uranium", {
description = "Uranium Ore",
tiles = {"default_stone.png^[colorize:#F408^technic_mineral_uranium.png"},
is_ground_content = true,
groups = {cracky=3, radioactive=1},
sounds = default.node_sound_stone_defaults(),
drop = "technic:uranium_lump",
})

minetest.register_node("cratermg:stone_with_chromium", {
description = "Chromium Ore",
tiles = {"default_stone.png^[colorize:#F408^technic_mineral_chromium.png"},
is_ground_content = true,
groups = {cracky=3},
sounds = default.node_sound_stone_defaults(),
drop = "technic:chromium_lump",
})

minetest.register_node("cratermg:stone_with_zinc", {
description = "Zinc Ore",
tiles = {"default_stone.png^[colorize:#F408^technic_mineral_zinc.png"},
is_ground_content = true,
groups = {cracky=3},
sounds = default.node_sound_stone_defaults(),
drop = "technic:zinc_lump",
})

minetest.register_node("cratermg:stone_with_lead", {
description = "Lead Ore",
tiles = {"default_stone.png^[colorize:#F408^technic_mineral_lead.png"},
is_ground_content = true,
groups = {cracky=3},
sounds = default.node_sound_stone_defaults(),
drop = "technic:lead_lump",
})

minetest.register_node("cratermg:stone_with_sulfur", {
description = "Sulfur Ore",
tiles = {"default_stone.png^[colorize:#F408^technic_mineral_sulfur.png"},
is_ground_content = true,
groups = {cracky=3},
sounds = default.node_sound_stone_defaults(),
drop = "technic:sulfur_lump",
})

-- Ores registration
--------------------

cratermg.register_ore({
noise = {scale = 1, octaves = 3, persist = 1, offset = -1,
spread = {x=1024, y=128, z=1024}},
ore = "cratermg:stone_with_uranium", spawns_in = "cratermg:stone"
})

cratermg.register_ore({
noise = {scale = 1, octaves = 2, persist = 1, offset = -1},
ore = "cratermg:stone_with_chromium", spawns_in = "cratermg:stone"
})

cratermg.register_ore({
noise = {scale = 1, octaves = 2, persist = 1, offset = -1},
ore = "cratermg:stone_with_lead", spawns_in = "cratermg:stone"
})

cratermg.register_ore({
noise = {scale = 1, octaves = 2, persist = 1, offset = -1},
ore = "cratermg:stone_with_zinc", spawns_in = "cratermg:stone"
})

cratermg.register_ore({
noise = {scale = 1, octaves = 2, persist = 1, offset = -1,
spread = {x=256, y=1024, z=256}},
ore = "cratermg:stone_with_sulfur", spawns_in = "cratermg:stone"
})

0 comments on commit 09278d1

Please sign in to comment.