Initial Commit
15
.luacheckrc
Normal file
@ -0,0 +1,15 @@
|
||||
unused_args = false
|
||||
allow_defined_top = true
|
||||
|
||||
read_globals = {
|
||||
"DIR_DELIM",
|
||||
"minetest", "core",
|
||||
"dump",
|
||||
"vector", "nodeupdate",
|
||||
"VoxelManip", "VoxelArea",
|
||||
"PseudoRandom", "ItemStack",
|
||||
"intllib",
|
||||
"default",
|
||||
table = { fields = { "copy", "getn" } }
|
||||
}
|
||||
|
1
depends.txt
Normal file
@ -0,0 +1 @@
|
||||
default
|
1
description.txt
Normal file
@ -0,0 +1 @@
|
||||
Bring color into the mgv7 mapgen world.
|
185
init.lua
Normal file
@ -0,0 +1,185 @@
|
||||
|
||||
--[[
|
||||
|
||||
grass - biome colored grass
|
||||
|
||||
(C) LGPL-2.1+ Auke Kok <sofar@foo-projects.org>
|
||||
|
||||
Textures are licensed according to their respective origin
|
||||
from github.com/minetest/minetest_game, generally CC-BY-SA-4.0
|
||||
or similar.
|
||||
|
||||
]]--
|
||||
|
||||
local wp = minetest.get_worldpath() .. "/luscious"
|
||||
|
||||
local mgp = minetest.get_mapgen_params()
|
||||
local chunksize = 16 * mgp.chunksize
|
||||
|
||||
local function after_place_node(pos, placer, itemstack, pointed_thing)
|
||||
-- get chunk from pos
|
||||
local v = vector.apply(pos, function(a) return math.floor((a - 48) / chunksize) end)
|
||||
local o = vector.subtract(pos, vector.apply(v, function(a) return (a * chunksize) + 48 end))
|
||||
local l = o.z * (chunksize) + o.x
|
||||
local p = minetest.hash_node_position(v)
|
||||
|
||||
local f = assert(io.open(wp .. "/" .. string.format("%d", p), "r"),
|
||||
"unable to find map for " .. string.format("%d", p))
|
||||
local z = f:read("*a")
|
||||
f:close()
|
||||
local map = minetest.decompress(z)
|
||||
|
||||
local node = minetest.get_node(pos)
|
||||
node.param2 = string.byte(map, l + 1)
|
||||
minetest.swap_node(pos, node)
|
||||
end
|
||||
|
||||
minetest.override_item("default:dirt_with_grass", {
|
||||
paramtype2 = "color",
|
||||
drawtype = "color",
|
||||
palette_index = 136,
|
||||
palette = "default_luscious_palette.png",
|
||||
tiles = {"default_grass.png", {name = "default_dirt.png", color = "white"}, "default_grass.png"},
|
||||
overlay_tiles = {"", "", {name = "default_dirt_overlay.png", color = "white"}},
|
||||
place_param2 = 136,
|
||||
after_place_node = after_place_node,
|
||||
})
|
||||
|
||||
for _, v in pairs({
|
||||
"default:leaves",
|
||||
"default:aspen_leaves",
|
||||
"default:jungleleaves",
|
||||
"default:pine_needles",
|
||||
"default:acacia_leaves",
|
||||
"default:bush_leaves",
|
||||
"default:acacia_bush_leaves",
|
||||
}) do
|
||||
minetest.override_item(v, {
|
||||
paramtype2 = "color",
|
||||
palette_index = 136,
|
||||
palette = "default_luscious_palette.png",
|
||||
place_param2 = 136,
|
||||
after_place_node = after_place_node,
|
||||
})
|
||||
end
|
||||
|
||||
minetest.register_alias_force("default:dirt_with_dry_grass", "default:dirt_with_grass")
|
||||
minetest.register_alias_force("default:dirt_with_rainforest_litter", "default:dirt_with_grass")
|
||||
minetest.register_alias_force("default:dirt_with_snow", "default:dirt_with_grass")
|
||||
|
||||
for _, v in pairs({
|
||||
"default:grass_1",
|
||||
"default:grass_2",
|
||||
"default:grass_3",
|
||||
"default:grass_4",
|
||||
"default:grass_5",
|
||||
"default:junglegrass",
|
||||
}) do
|
||||
minetest.override_item(v, {
|
||||
paramtype2 = "color",
|
||||
palette_index = 136,
|
||||
palette = "default_luscious_palette.png",
|
||||
place_param2 = 136,
|
||||
after_place_node = after_place_node,
|
||||
})
|
||||
end
|
||||
for i = 1, 5 do
|
||||
minetest.register_alias_force("default:dry_grass_" .. i, "default:grass_" .. i)
|
||||
end
|
||||
|
||||
-- content ids
|
||||
local cn = {
|
||||
["default:dirt_with_grass"] = 1,
|
||||
["default:grass_1"] = 1,
|
||||
["default:grass_2"] = 1,
|
||||
["default:grass_3"] = 1,
|
||||
["default:grass_4"] = 1,
|
||||
["default:grass_5"] = 1,
|
||||
["default:junglegrass"] = 1,
|
||||
["default:leaves"] = 1,
|
||||
["default:aspen_leaves"] = 1,
|
||||
["default:jungleleaves"] = 1,
|
||||
["default:pine_needles"] = 1,
|
||||
["default:acacia_leaves"] = 1,
|
||||
["default:bush_leaves"] = 1,
|
||||
["default:acacia_bush_leaves"] = 1,
|
||||
}
|
||||
local cs = {}
|
||||
for k, _ in pairs(cn) do
|
||||
cs[minetest.get_content_id(k)] = 1
|
||||
end
|
||||
|
||||
minetest.register_on_generated(function(minp, maxp, blockseed)
|
||||
local v = vector.apply(minp, function(a) return (a - 48) / chunksize end)
|
||||
local heatmap = minetest.get_mapgen_object("heatmap")
|
||||
local humiditymap = minetest.get_mapgen_object("humiditymap")
|
||||
local map = ""
|
||||
for i = 1, #heatmap do
|
||||
local h1 = heatmap[i]
|
||||
local h2 = humiditymap[i]
|
||||
h1 = math.floor(math.min(math.max(math.floor(h1), 0), 100) / 6.6)
|
||||
h2 = math.floor(math.min(math.max(math.floor(h2), 0), 100) / 6.6)
|
||||
map = map .. string.char(h1 + (h2 * 16))
|
||||
end
|
||||
local p = string.format("%d", minetest.hash_node_position(v))
|
||||
|
||||
local f = assert(io.open(wp .. "/" .. p, "w"), wp .. "/" .. p)
|
||||
f:write(minetest.compress(map))
|
||||
f:close()
|
||||
|
||||
local vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
|
||||
local area = VoxelArea:new{MinEdge = emin, MaxEdge = emax}
|
||||
local data = vm:get_data()
|
||||
local p2data = vm:get_param2_data()
|
||||
for z = minp.z, maxp.z do
|
||||
for y = minp.y, maxp.y do
|
||||
local vi = area:index(minp.x, y, z)
|
||||
for x = minp.x, maxp.x do
|
||||
local vv = (x - minp.x) + ((z - minp.z) * chunksize)
|
||||
if cs[data[vi]] then
|
||||
local mv = string.byte(map, vv + 1)
|
||||
p2data[vi] = mv
|
||||
end
|
||||
vi = vi + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
vm:set_param2_data(p2data)
|
||||
vm:write_to_map()
|
||||
end)
|
||||
|
||||
local function update_p2(pos, size)
|
||||
local minp = {x = pos.x - size[1], y = pos.y, z = pos.z - size[1]}
|
||||
local maxp = {x = pos.x + size[1], y = pos.y + size[2], z = pos.z + size[1]}
|
||||
for x = minp.x, maxp.x do
|
||||
for y = minp.y, maxp.y do
|
||||
for z = minp.z, maxp.z do
|
||||
local p = vector.new(x, y, z)
|
||||
local node = minetest.get_node(p)
|
||||
if cn[node.name] then
|
||||
after_place_node(p)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local saplings = {
|
||||
["default:sapling"] = {2, 8},
|
||||
["default:junglesapling"] = {2, 17},
|
||||
["default:pine_sapling"] = {2, 14},
|
||||
["default:acacia_sapling"] = {4, 8},
|
||||
["default:aspen_sapling"] = {2, 12},
|
||||
["default:bush_sapling"] = {1, 3},
|
||||
["default:acacia_bush_sapling"] = {1, 3},
|
||||
}
|
||||
|
||||
for k, v in pairs(saplings) do
|
||||
minetest.override_item(k, {
|
||||
on_timer = function(pos)
|
||||
default.grow_sapling(pos)
|
||||
update_p2(pos, v)
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
33
readme.md
Normal file
@ -0,0 +1,33 @@
|
||||
|
||||
## luscious
|
||||
|
||||
Makes your map luscious.
|
||||
|
||||
This mod heavily modifies your base landscape and modifies various
|
||||
nodes like dirt and leaves so that they become colored using node
|
||||
coloring.
|
||||
|
||||
The color selection of each node is decided based on the biome data,
|
||||
using heat and humidity. These are mapped on a 16x16 palette where
|
||||
the heat is mapped along the x axis from 0-15 and the humidity along
|
||||
the y axis with the same range. This gives us a total of 256 possible
|
||||
colorizations of each node.
|
||||
|
||||
Manual placing of the nodes, and sapling placement is also modified to
|
||||
make trees growing or manual placing of nodes also result in colorized
|
||||
nodes in the landscape.
|
||||
|
||||
## features
|
||||
|
||||
- jungle dirt is replaced by dirt with grass
|
||||
- dirt with dry grass is replaced by dirt with grass
|
||||
- dirt with snow is replaced by dirt with grass
|
||||
- dry grass is replaced with grass
|
||||
|
||||
## bugs
|
||||
|
||||
- leaf decay is broken due to p2 usage
|
||||
- grass spread is broken or will place wrongly colored grass nodes
|
||||
- inventory items lack proper coloring
|
||||
- snowy pine trees are missing
|
||||
|
BIN
textures/default_acacia_leaves.png
Normal file
After Width: | Height: | Size: 399 B |
BIN
textures/default_aspen_leaves.png
Normal file
After Width: | Height: | Size: 780 B |
BIN
textures/default_dirt_overlay.png
Normal file
After Width: | Height: | Size: 492 B |
BIN
textures/default_grass.png
Normal file
After Width: | Height: | Size: 645 B |
BIN
textures/default_grass_1.png
Normal file
After Width: | Height: | Size: 159 B |
BIN
textures/default_grass_2.png
Normal file
After Width: | Height: | Size: 179 B |
BIN
textures/default_grass_3.png
Normal file
After Width: | Height: | Size: 246 B |
BIN
textures/default_grass_4.png
Normal file
After Width: | Height: | Size: 354 B |
BIN
textures/default_grass_5.png
Normal file
After Width: | Height: | Size: 445 B |
BIN
textures/default_grass_side.png
Normal file
After Width: | Height: | Size: 793 B |
BIN
textures/default_jungleleaves.png
Normal file
After Width: | Height: | Size: 375 B |
BIN
textures/default_leaves.png
Normal file
After Width: | Height: | Size: 729 B |
BIN
textures/default_luscious_palette.png
Normal file
After Width: | Height: | Size: 674 B |
BIN
textures/default_pine_needles.png
Normal file
After Width: | Height: | Size: 403 B |