red_glazed_terracotta/mods/rgt_world/init.lua

475 lines
13 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

rgt_world = {}
local ns = rgt_world
local function rep(tx, size)
local out = "[combine:"..(size *16).."x"..(size *16)
for x = 0, size -1 do
for y = 0, size -1 do
out = out..":"..(x *16)..","..(y *16).."="..tx
end
end
return out
end
include "variants.lua"
rgt.register_node("stone", {
tiles = {{name = "rgt_stone.png", align_style = "world"}},
_variants = "all",
groups = {stone = 1}
})
rgt.register_node("stone_brick", {
tiles = {{name = "rgt_stone_brick.png", align_style = "world"}},
_variants = "all",
groups = {stone = 1}
})
rgt.register_node("stone_brick_large", {
tiles = {{name = "rgt_stone_brick_large.png", align_style = "world"}},
_variants = "all",
groups = {stone = 1}
})
rgt.register_node("stone_tile", {
tiles = {{name = "rgt_stone_tile.png", align_style = "world"}},
_variants = "all",
groups = {stone = 1}
})
rgt.register_node("cobble", {
tiles = {"rgt_cobble.png"},
_variants = "all",
groups = {stone = 1}
})
rgt.register_node("dirt", {
tiles = {"rgt_dirt.png"},
groups = {dig_immediate = 3}
})
rgt.register_node("dirt_mossy", {
tiles = {{name = rep("rgt_dirt.png", 4).."^rgt_path_grass.png", scale = 4, align_style = "world"}, "rgt_dirt.png"},
groups = {dig_immediate = 3}
})
rgt.register_node("dirt_grass", {
paramtype2 = "color",
tiles = {"rgt_grass_top.png", {name = "rgt_dirt.png", color = "#fff"}, {name = "rgt_dirt.png^rgt_grass_side_shadow.png", color = "#fff"}},
overlay_tiles = {"", "", "rgt_grass_side.png"},
palette = "rgt_palette_grass.png",
on_construct = function(pos)
end,
-- tiles = {"[fill:16x16:0,0:#3e7e7b^[fill:14x14:1,1:#326764"},
groups = {dig_immediate = 3}
})
-- Grass
for i = 1, 3 do
rgt.register_node("grass_"..i, {
drawtype = "plantlike",
paramtype = "light",
paramtype2 = "meshoptions",
place_param2 = 2,
sunlight_propagates = false,
tiles = {"rgt_grass_"..i..".png"},
groups = {attached_node = 3, dig_immediate = 3},
walkable = false,
selection_box = {
type = "fixed",
fixed = {
-6/16, -0.5, -6/16,
6/16, 6/16, 6/16
}
}
})
end
-- Tall grass
rgt.register_node("grass_tall_bottom", {
drawtype = "plantlike",
paramtype = "light",
paramtype2 = "meshoptions",
place_param2 = 2,
sunlight_propagates = false,
tiles = {"rgt_grass_tall.png^[verticalframe:2:1"},
groups = {attached_node = 3, dig_immediate = 3},
walkable = false,
selection_box = {
type = "fixed",
fixed = {
-6/16, -0.5, -6/16,
6/16, 0.5, 6/16
}
},
node_placement_prediction = "",
after_destruct = function(pos)
local above = pos:offset(0, 1, 0)
local na = minetest.get_node(above)
if na.name:find "grass_tall_top" then
minetest.remove_node(above)
end
end,
on_place = function(s, p, pt)
if pt.type ~= "node" then return end
local target = pt.above
if not minetest.get_node(target:offset(0, -1, 0)).name:find "dirt_grass" then
return
end
local above = target:offset(0, 1, 0)
if minetest.get_node(above).name == "air" then
minetest.set_node(target, {name = "grass_tall_bottom", param2 = 2})
minetest.set_node(above, {name = "grass_tall_top", param2 = 2})
s:take_item()
return s
end
end
})
rgt.register_node("grass_tall_top", {
drawtype = "plantlike",
paramtype = "light",
paramtype2 = "meshoptions",
place_param2 = 2,
sunlight_propagates = false,
tiles = {"rgt_grass_tall.png^[verticalframe:2:0"},
groups = {dig_immediate = 3},
walkable = false,
selection_box = {
type = "fixed",
fixed = {
-6/16, -0.5, -6/16,
6/16, 6/16, 6/16
}
},
drop = "grass_tall_bottom",
after_destruct = function(pos)
local below = pos:offset(0, -1, 0)
local nb = minetest.get_node(below)
if nb.name:find "grass_tall_bottom" then
minetest.remove_node(below)
end
end,
})
-- TODO: Tall grass
--rgt.register_node("tall_grass", {
-- drawtype = "mesh",
-- mesh = "rgt_plantlike_1x1x2.obj",
-- use_texture_alpha = "clip",
-- paramtype = "light",
-- sunlight_propagates = false,
-- tiles = {"rgt_grass_tall.png"},
-- groups = {dig_immediate = 3},
-- walkable = false
--})
rgt.register_node("path_grass", {
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {
-0.5, -0.5, -0.5,
0.5, 7/16, 0.5
}
},
tiles = {"rgt_path_grass_top.png", "rgt_dirt.png", "rgt_dirt.png^rgt_path_grass_side.png"},
-- tiles = {"[fill:16x16:0,0:#3e7e7b^[fill:14x14:1,1:#326764"},
paramtype = "light",
sunlight_propagates = false,
groups = {dig_immediate = 3}
})
rgt.register_node("sand", {
tiles = {"rgt_sand.png"},
groups = {dig_immediate = 3}
})
rgt.register_node("oak_log", {
tiles = {"rgt_oak_log_top.png", "rgt_oak_log_top.png", "rgt_oak_log_side.png"},
groups = {dig_immediate = 3},
paramtype2 = "facedir"
})
rgt.register_node("oak_leaves", {
drawtype = "allfaces",
tiles = {"rgt_oak_leaves.png"},
use_texture_alpha = "clip",
groups = {dig_immediate = 3},
})
rgt.register_node("oak_planks", {
tiles = {{name = "rgt_oak_planks.png", align_style = "world"}},
_variants = "all",
groups = {dig_immediate = 3},
})
rgt.register_node("dark_planks", {
tiles = {{name = "rgt_dark_planks.png", align_style = "world"}},
_variants = "all",
groups = {dig_immediate = 3},
})
rgt.register_node("spruce_planks", {
tiles = {{name = "rgt_spruce_planks.png", align_style = "world"}},
_variants = "all",
groups = {dig_immediate = 3},
})
rgt.register_node("acacia_planks", {
tiles = {{name = "rgt_acacia_planks.png", align_style = "world"}},
_variants = "all",
groups = {dig_immediate = 3},
})
rgt.register_node("redwood_planks", {
tiles = {{name = "rgt_redwood_planks.png", align_style = "world"}},
_variants = "all",
groups = {dig_immediate = 3},
})
rgt.register_node("birch_planks", {
tiles = {{name = "rgt_birch_planks.png", align_style = "world"}},
_variants = "all",
groups = {dig_immediate = 3},
})
rgt.register_node("glass", {
drawtype = "glasslike",
paramtype = "light",
tiles = {{name = "rgt_glass.png", align_style = "world"}},
use_texture_alpha = "clip",
_variants = "all",
groups = {dig_immediate = 3}
})
--minetest.register_decoration {
-- deco_type = "simple",
-- place_on = "dirt_grass",
-- fill_ratio = 0.5,
-- decoration = {"red_glazed_terracotta:oak_planks", "red_glazed_terracotta:spruce_planks", "red_glazed_terracotta:dark_planks", "red_glazed_terracotta:redwood_planks", "red_glazed_terracotta:acacia_planks", "red_glazed_terracotta:birch_planks"}
--}
rgt.register_node("basalt", {
tiles = {{name = "rgt_basalt.png", align_style = "world"}},
_variants = "all",
groups = {dig_immediate = 3},
})
rgt.register_node("water", {
tiles = {"[fill:16x16:0,0:#2d5a7c77^[fill:14x14:1,1:#2d5a7c33"},
groups = {dig_immediate = 3},
drawtype = "liquid",
use_texture_alpha = "blend",
paramtype = "light",
walkable = false,
climbable = true,
post_effect_color = "#2d5a7c55",
is_ground_content = false,
liquidtype = "source",
-- Minetest pro tip: Do not try to use aliases for these.
liquid_alternative_source = "red_glazed_terracotta:water",
liquid_alternative_flowing = "red_glazed_terracotta:water_flowing",
liquid_viscosity = 1,
liquid_range = 5,
})
rgt.register_node("water_flowing", {
tiles = {{name = "[fill:16x16:0,0:#2d5a7c77^[fill:14x14:1,1:#2d5a7c33", backface_culling = true}},
special_tiles = {{name = "[fill:16x16:0,0:#2d5a7c77^[fill:14x14:1,1:#2d5a7c33", backface_culling = true}, {name = "[fill:16x16:0,0:#2d5a7c77^[fill:14x14:1,1:#2d5a7c33", backface_culling = true}},
groups = {dig_immediate = 3},
drawtype = "flowingliquid",
use_texture_alpha = "blend",
paramtype = "light",
paramtype2 = "flowingliquid",
walkable = false,
climbable = true,
post_effect_color = "#2d5a7c55",
is_ground_content = false,
liquidtype = "flowing",
liquid_alternative_source = "red_glazed_terracotta:water",
liquid_alternative_flowing = "red_glazed_terracotta:water_flowing",
liquid_viscosity = 1,
liquid_range = 5,
})
rgt.register_node("river_water", {
tiles = {"[fill:16x16:0,0:#2d5a7c77^[fill:14x14:1,1:#2d5a7c33"},
groups = {dig_immediate = 3},
drawtype = "liquid",
use_texture_alpha = "blend",
paramtype = "light",
walkable = false,
climbable = true,
post_effect_color = "#2d5a7c55",
liquidtype = "source",
-- Minetest pro tip: Do not try to use aliases for these.
liquid_alternative_source = "red_glazed_terracotta:river_water",
liquid_alternative_flowing = "red_glazed_terracotta:river_water_flowing",
liquid_viscosity = 1,
liquid_range = 2,
liquid_renewable = false
})
rgt.register_node("river_water_flowing", {
tiles = {{name = "[fill:16x16:0,0:#2d5a7c77^[fill:14x14:1,1:#2d5a7c33", backface_culling = true}},
special_tiles = {{name = "[fill:16x16:0,0:#2d5a7c77^[fill:14x14:1,1:#2d5a7c33", backface_culling = true}, {name = "[fill:16x16:0,0:#2d5a7c77^[fill:14x14:1,1:#2d5a7c33", backface_culling = true}},
groups = {dig_immediate = 3},
drawtype = "flowingliquid",
use_texture_alpha = "blend",
paramtype = "light",
paramtype2 = "flowingliquid",
walkable = false,
climbable = true,
post_effect_color = "#2d5a7c55",
liquidtype = "flowing",
liquid_alternative_source = "red_glazed_terracotta:river_water",
liquid_alternative_flowing = "red_glazed_terracotta:river_water_flowing",
liquid_viscosity = 1,
liquid_range = 2,
liquid_renewable = false
})
minetest.register_alias("mapgen_stone", "red_glazed_terracotta:stone")
minetest.register_alias("mapgen_water_source", "red_glazed_terracotta:water")
minetest.register_alias("mapgen_river_water_source", "red_glazed_terracotta:river_water")
--[[
Biomes to add:
[Temperate]
Steppe
Moor
Plains
Light Deciduous Forest
Dark Deciduous Forest
[Cold]
Alpine
Glacier
Taiga
Tundra
Coniferous Forest
[Warm]
Desert
Badlands
Jungle
Swamp
Marsh
--]]
include "biomes.lua"
rgt.register_node("light", {
tiles = {"[fill:1x1:0,0:#fed"},
light_source = 14,
paramtype = "light",
description = "Test"
})
minetest.register_ore {
ore_type = "scatter",
ore = "light",
wherein = "stone",
clust_scarcity = 3 * 3 * 3,
clust_num_ores = 5,
clust_size = 1
}
minetest.register_decoration {
deco_type = "schematic",
place_on = "dirt_grass",
biomes = {"forest"},
y_min = 1,
y_max = 8000,
fill_ratio = 0.01,
schematic = minetest.get_modpath(minetest.get_current_modname()).."/schems/tree.mts",
flags = "place_center_x, place_center_z",
place_offset_y = 1,
}
minetest.register_decoration {
deco_type = "schematic",
place_on = "dirt_grass",
biomes = {"plains"},
y_min = 1,
noise_params = {
offset = 0,
scale = 0.25,
spread = {x = 8, y = 8, z = 8},
seed = 3456789,
octaves = 4,
persist = 0.6,
lacunarity = 3,
},
-- fill_ratio = 0.1,
schematic = {
size = {x = 1, y = 2, z = 1}, -- 1×2×1
data = {
{name = "grass_tall_bottom", prob = 255, param2 = 2},
{name = "grass_tall_top", prob = 255, param2 = 2},
},
},
place_offset_y = 1,
}
minetest.register_decoration {
deco_type = "simple",
place_on = "dirt_grass",
biomes = {"forest", "plains"},
decoration = {"grass_1", "grass_2", "grass_3"},
param2 = 2,
y_min = 1,
fill_ratio = 0.2,
}
minetest.override_item("", {
on_place = function(s, p, pt)
if minetest.get_node(pt.under).name:find "dirt_grass" then
minetest.set_node(pt.under, {name = "path_grass"})
end
-- minetest.spawn_tree(pt.above, {
-- axiom = "TF[FFA]",
-- rules_a = "F",
-- trunk = "oak_log",
-- leaves = "oak_leaves",
-- angle = 30,
-- iterations = 2,
-- random_level = 0,
-- trunk_type = "single",
---- thin_branches = true,
-- fruit_chance = 0,
-- fruit = "stone_brick"
-- })
end
})
minetest.register_chatcommand("biome", {
func = function(name)
tell(name, minetest.get_biome_name(minetest.get_biome_data(minetest.get_player_by_name(name):get_pos()).biome))
end
})
include "config.lua"
--minetest.register_mapgen_script(minetest.get_modpath(minetest.get_current_modname()).."/mapgen.lua")