add support for mapgen v7

master
Martin Doege 2016-01-24 19:36:56 +01:00
parent 1f9798b925
commit 1cf9e1a20b
41 changed files with 1738 additions and 518 deletions

View File

@ -69,3 +69,12 @@ minetest.register_alias("snow", "default:snow")
-- Mese now comes in the form of blocks, ore, crystal and fragments
minetest.register_alias("default:mese", "default:mese_block")
-- Aliases for pine node names
minetest.register_alias("default:pine_tree", "default:pinetree")
minetest.register_alias("default:pine_wood", "default:pinewood")
minetest.register_alias("flowers:mushroom_red", "farming:mushroom_red")
minetest.register_alias("flowers:mushroom_brown", "farming:mushroom_brown")

View File

@ -21,6 +21,20 @@ minetest.register_craft({
}
})
minetest.register_craft({
output = 'default:acacia_wood 4',
recipe = {
{'default:acacia_tree'},
}
})
minetest.register_craft({
output = 'default:aspen_wood 4',
recipe = {
{'default:aspen_tree'},
}
})
minetest.register_craft({
output = 'default:stick 4',
recipe = {

View File

@ -309,7 +309,7 @@ minetest.register_abm({
})
minetest.register_abm({
nodenames = {"default:dirt_with_grass"},
nodenames = {"default:dirt_with_grass", "default:dirt_with_dry_grass"},
interval = 2,
chance = 20,
action = function(pos, node)

File diff suppressed because it is too large Load Diff

View File

@ -273,6 +273,19 @@ minetest.register_node("default:dirt_with_grass_footsteps", {
}),
})
minetest.register_node("default:dirt_with_dry_grass", {
description = "Dirt with Dry Grass",
tiles = {"default_dry_grass.png",
"default_dirt.png",
{name = "default_dirt.png^default_dry_grass_side.png",
tileable_vertical = false}},
groups = {crumbly = 3, soil = 1},
drop = 'default:dirt',
sounds = default.node_sound_dirt_defaults({
footstep = {name = "default_grass_footstep", gain = 0.4},
}),
})
minetest.register_node("default:dirt_with_snow", {
description = "Dirt with Snow",
tiles = {"default_snow.png", "default_dirt.png", "default_dirt.png^default_snow_side.png"},
@ -654,6 +667,126 @@ minetest.register_node("default:pine_sapling", {
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("default:acacia_tree", {
description = "Acacia Tree",
tiles = {"default_acacia_tree_top.png", "default_acacia_tree_top.png",
"default_acacia_tree.png"},
paramtype2 = "facedir",
is_ground_content = false,
groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2},
sounds = default.node_sound_wood_defaults(),
on_place = minetest.rotate_node
})
minetest.register_node("default:acacia_wood", {
description = "Acacia Wood Planks",
tiles = {"default_acacia_wood.png"},
is_ground_content = false,
groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 3, wood = 1},
sounds = default.node_sound_wood_defaults(),
})
minetest.register_node("default:acacia_leaves", {
description = "Acacia Leaves",
drawtype = "allfaces_optional",
visual_scale = 1.3,
tiles = {"default_acacia_leaves.png"},
waving = 1,
paramtype = "light",
is_ground_content = false,
groups = {snappy = 3, leafdecay = 3, flammable = 2, leaves = 1},
drop = {
max_items = 1,
items = {
{items = {"default:acacia_sapling"}, rarity = 20},
{items = {"default:acacia_leaves"}}
}
},
sounds = default.node_sound_leaves_defaults(),
after_place_node = default.after_place_leaves,
})
minetest.register_node("default:acacia_sapling", {
description = "Acacia Tree Sapling",
drawtype = "plantlike",
visual_scale = 1.0,
tiles = {"default_acacia_sapling.png"},
inventory_image = "default_acacia_sapling.png",
wield_image = "default_acacia_sapling.png",
paramtype = "light",
sunlight_propagates = true,
walkable = false,
selection_box = {
type = "fixed",
fixed = {-0.3, -0.5, -0.3, 0.3, 0.35, 0.3}
},
groups = {snappy = 2, dig_immediate = 3, flammable = 2,
attached_node = 1, sapling = 1},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("default:aspen_tree", {
description = "Aspen Tree",
tiles = {"default_aspen_tree_top.png", "default_aspen_tree_top.png",
"default_aspen_tree.png"},
paramtype2 = "facedir",
is_ground_content = false,
groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2},
sounds = default.node_sound_wood_defaults(),
on_place = minetest.rotate_node
})
minetest.register_node("default:aspen_wood", {
description = "Aspen Wood Planks",
tiles = {"default_aspen_wood.png"},
is_ground_content = false,
groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 3, wood = 1},
sounds = default.node_sound_wood_defaults(),
})
minetest.register_node("default:aspen_leaves", {
description = "Aspen Leaves",
drawtype = "allfaces_optional",
visual_scale = 1.3,
tiles = {"default_aspen_leaves.png"},
waving = 1,
paramtype = "light",
is_ground_content = false,
groups = {snappy = 3, leafdecay = 3, flammable = 2, leaves = 1},
drop = {
max_items = 1,
items = {
{items = {"default:aspen_sapling"}, rarity = 20},
{items = {"default:aspen_leaves"}}
}
},
sounds = default.node_sound_leaves_defaults(),
after_place_node = default.after_place_leaves,
})
minetest.register_node("default:aspen_sapling", {
description = "Aspen Tree Sapling",
drawtype = "plantlike",
visual_scale = 1.0,
tiles = {"default_aspen_sapling.png"},
inventory_image = "default_aspen_sapling.png",
wield_image = "default_aspen_sapling.png",
paramtype = "light",
sunlight_propagates = true,
walkable = false,
selection_box = {
type = "fixed",
fixed = {-0.3, -0.5, -0.3, 0.3, 0.35, 0.3}
},
groups = {snappy = 2, dig_immediate = 3, flammable = 2,
attached_node = 1, sapling = 1},
sounds = default.node_sound_leaves_defaults(),
})
--
-- Ores
--
@ -1024,6 +1157,57 @@ for i=2,5 do
})
end
minetest.register_node("default:dry_grass_1", {
description = "Dry Grass",
drawtype = "plantlike",
waving = 1,
tiles = {"default_dry_grass_1.png"},
inventory_image = "default_dry_grass_3.png",
wield_image = "default_dry_grass_3.png",
paramtype = "light",
sunlight_propagates = true,
walkable = false,
buildable_to = true,
groups = {snappy = 3, flammable = 3, flora = 1, attached_node = 1},
sounds = default.node_sound_leaves_defaults(),
selection_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},
},
on_place = function(itemstack, placer, pointed_thing)
-- place a random dry grass node
local stack = ItemStack("default:dry_grass_" .. math.random(1, 5))
local ret = minetest.item_place(stack, placer, pointed_thing)
return ItemStack("default:dry_grass_1 " ..
itemstack:get_count() - (1 - ret:get_count()))
end,
})
for i = 2, 5 do
minetest.register_node("default:dry_grass_" .. i, {
description = "Dry Grass",
drawtype = "plantlike",
waving = 1,
tiles = {"default_dry_grass_" .. i .. ".png"},
inventory_image = "default_dry_grass_" .. i .. ".png",
wield_image = "default_dry_grass_" .. i .. ".png",
paramtype = "light",
sunlight_propagates = true,
walkable = false,
buildable_to = true,
groups = {snappy = 3, flammable = 3, flora = 1,
attached_node = 1, not_in_creative_inventory=1},
drop = "default:dry_grass_1",
sounds = default.node_sound_leaves_defaults(),
selection_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},
},
})
end
--
-- Liquids
--
@ -1117,6 +1301,101 @@ minetest.register_node("default:water_flowing", {
})
minetest.register_node("default:river_water_source", {
description = "River Water Source",
inventory_image = minetest.inventorycube("default_river_water.png"),
drawtype = "liquid",
tiles = {
{
name = "default_river_water_source_animated.png",
animation = {
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
length = 2.0,
},
},
},
special_tiles = {
{
name = "default_river_water_source_animated.png",
animation = {
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
length = 2.0,
},
backface_culling = false,
},
},
alpha = 160,
paramtype = "light",
walkable = false,
pointable = false,
diggable = false,
buildable_to = true,
is_ground_content = false,
drop = "",
drowning = 1,
liquidtype = "source",
liquid_alternative_flowing = "default:river_water_flowing",
liquid_alternative_source = "default:river_water_source",
liquid_viscosity = 1,
liquid_renewable = false,
liquid_range = 2,
post_effect_color = {a = 103, r = 30, g = 76, b = 90},
groups = {water = 3, liquid = 3, puts_out_fire = 1},
})
minetest.register_node("default:river_water_flowing", {
description = "Flowing River Water",
inventory_image = minetest.inventorycube("default_river_water.png"),
drawtype = "flowingliquid",
tiles = {"default_river_water.png"},
special_tiles = {
{
name = "default_river_water_flowing_animated.png",
backface_culling = false,
animation = {
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
length = 0.8,
},
},
{
name = "default_river_water_flowing_animated.png",
backface_culling = true,
animation = {
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
length = 0.8,
},
},
},
alpha = 160,
paramtype = "light",
paramtype2 = "flowingliquid",
walkable = false,
pointable = false,
diggable = false,
buildable_to = true,
is_ground_content = false,
drop = "",
drowning = 1,
liquidtype = "flowing",
liquid_alternative_flowing = "default:river_water_flowing",
liquid_alternative_source = "default:river_water_source",
liquid_viscosity = 1,
liquid_renewable = false,
liquid_range = 2,
post_effect_color = {a = 103, r = 30, g = 76, b = 90},
groups = {water = 3, liquid = 3, puts_out_fire = 1,
not_in_creative_inventory = 1},
})
minetest.register_node("default:lava_source", {
description = "Lava Source",

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 561 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 462 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 219 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 265 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 295 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 316 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 339 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 285 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 462 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 716 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

View File

@ -1,10 +1,12 @@
--
-- Grow trees
-- Grow trees from saplings
--
-- 'Can grow' function
local random = math.random
local function can_grow(pos)
function default.can_grow(pos)
local node_under = minetest.get_node_or_nil({x = pos.x, y = pos.y - 1, z = pos.z})
if not node_under then
return false
@ -14,57 +16,70 @@ local function can_grow(pos)
if is_soil == 0 then
return false
end
local light_level = minetest.get_node_light(pos)
if not light_level or light_level < 13 then
return false
end
return true
end
-- Sapling ABMs
-- Sapling ABM
minetest.register_abm({
nodenames = {"default:sapling"},
nodenames = {"default:sapling", "default:junglesapling",
"default:pine_sapling", "default:acacia_sapling",
"default:aspen_sapling"},
interval = 10,
chance = 50,
action = function(pos, node)
if not can_grow(pos) then
if not default.can_grow(pos) then
return
end
minetest.log("action", "A sapling grows into a tree at "..
local mapgen = minetest.get_mapgen_params().mgname
if node.name == "default:sapling" then
minetest.log("action", "A sapling grows into a tree at "..
minetest.pos_to_string(pos))
default.grow_tree(pos, random(1, 4) == 1)
end
})
minetest.register_abm({
nodenames = {"default:junglesapling"},
interval = 11,
chance = 50,
action = function(pos, node)
if not can_grow(pos) then
return
if mapgen == "v6" then
default.grow_tree(pos, random(1, 4) == 1)
else
default.grow_new_apple_tree(pos)
end
elseif node.name == "default:junglesapling" then
minetest.log("action", "A jungle sapling grows into a tree at "..
minetest.pos_to_string(pos))
if mapgen == "v6" then
default.grow_jungle_tree(pos)
else
default.grow_new_jungle_tree(pos)
end
elseif node.name == "default:pine_sapling" then
minetest.log("action", "A pine sapling grows into a tree at "..
minetest.pos_to_string(pos))
if mapgen == "v6" then
default.grow_pine_tree(pos)
else
default.grow_new_pine_tree(pos)
end
elseif node.name == "default:acacia_sapling" then
minetest.log("action", "An acacia sapling grows into a tree at "..
minetest.pos_to_string(pos))
default.grow_new_acacia_tree(pos)
elseif node.name == "default:aspen_sapling" then
minetest.log("action", "An aspen sapling grows into a tree at "..
minetest.pos_to_string(pos))
default.grow_new_aspen_tree(pos)
end
minetest.log("action", "A jungle sapling grows into a tree at "..
minetest.pos_to_string(pos))
default.grow_jungle_tree(pos)
end
})
minetest.register_abm({
nodenames = {"default:pine_sapling"},
interval = 12,
chance = 50,
action = function(pos, node)
if not can_grow(pos) then
return
end
minetest.log("action", "A pine sapling grows into a tree at "..
minetest.pos_to_string(pos))
default.grow_pine_tree(pos)
end
})
--
-- Tree generation
--
-- Appletree, jungletree function
-- Apple tree and jungle tree trunk and leaves function
local function add_trunk_and_leaves(data, a, pos, tree_cid, leaves_cid,
height, size, iters, is_apple_tree)
@ -74,11 +89,11 @@ local function add_trunk_and_leaves(data, a, pos, tree_cid, leaves_cid,
local c_apple = minetest.get_content_id("default:apple")
-- Trunk
for y_dist = 0, height - 1 do
local vi = a:index(x, y + y_dist, z)
data[a:index(x, y, z)] = tree_cid -- Force-place lowest trunk node to replace sapling
for yy = y + 1, y + height - 1 do
local vi = a:index(x, yy, z)
local node_id = data[vi]
if y_dist == 0 or node_id == c_air or node_id == c_ignore
or node_id == leaves_cid then
if node_id == c_air or node_id == c_ignore or node_id == leaves_cid then
data[vi] = tree_cid
end
end
@ -123,7 +138,8 @@ local function add_trunk_and_leaves(data, a, pos, tree_cid, leaves_cid,
end
end
-- Appletree
-- Apple tree
function default.grow_tree(pos, is_apple_tree, bad)
--[[
@ -155,7 +171,8 @@ function default.grow_tree(pos, is_apple_tree, bad)
vm:update_map()
end
-- Jungletree
-- Jungle tree
function default.grow_jungle_tree(pos, bad)
--[[
@ -206,16 +223,19 @@ function default.grow_jungle_tree(pos, bad)
vm:update_map()
end
-- Pinetree from mg mapgen mod, design by sfan5, pointy top added by paramat
-- Pine tree from mg mapgen mod, design by sfan5, pointy top added by paramat
local function add_pine_needles(data, vi, c_air, c_ignore, c_snow, c_pine_needles)
if data[vi] == c_air or data[vi] == c_ignore or data[vi] == c_snow then
local node_id = data[vi]
if node_id == c_air or node_id == c_ignore or node_id == c_snow then
data[vi] = c_pine_needles
end
end
local function add_snow(data, vi, c_air, c_ignore, c_snow)
if data[vi] == c_air or data[vi] == c_ignore then
local node_id = data[vi]
if node_id == c_air or node_id == c_ignore then
data[vi] = c_snow
end
end
@ -226,7 +246,7 @@ function default.grow_pine_tree(pos)
local c_air = minetest.get_content_id("air")
local c_ignore = minetest.get_content_id("ignore")
local c_pinetree = minetest.get_content_id("default:pinetree")
local c_pine_tree = minetest.get_content_id("default:pine_tree")
local c_pine_needles = minetest.get_content_id("default:pine_needles")
local c_snow = minetest.get_content_id("default:snow")
local c_snowblock = minetest.get_content_id("default:snowblock")
@ -240,16 +260,14 @@ function default.grow_pine_tree(pos)
local a = VoxelArea:new({MinEdge = minp, MaxEdge = maxp})
local data = vm:get_data()
-- Scan for snow nodes near sapling
-- Scan for snow nodes near sapling to enable snow on branches
local snow = false
for yy = y - 1, y + 1 do
for zz = z - 1, z + 1 do
local vi = a:index(x - 1, yy, zz)
for xx = x - 1, x + 1 do
local nodid = data[vi]
if nodid == c_snow
or nodid == c_snowblock
or nodid == c_dirtsnow then
if nodid == c_snow or nodid == c_snowblock or nodid == c_dirtsnow then
snow = true
end
vi = vi + 1
@ -266,7 +284,7 @@ function default.grow_pine_tree(pos)
for xx = x - dev, x + dev do
if random() < 0.95 - dev * 0.05 then
add_pine_needles(data, vi, c_air, c_ignore, c_snow,
c_pine_needles)
c_pine_needles)
if snow then
add_snow(data, via, c_air, c_ignore, c_snow)
end
@ -280,9 +298,9 @@ function default.grow_pine_tree(pos)
-- Centre top nodes
add_pine_needles(data, a:index(x, maxy + 1, z), c_air, c_ignore, c_snow,
c_pine_needles)
c_pine_needles)
add_pine_needles(data, a:index(x, maxy + 2, z), c_air, c_ignore, c_snow,
c_pine_needles) -- Paramat added a pointy top node
c_pine_needles) -- Paramat added a pointy top node
if snow then
add_snow(data, a:index(x, maxy + 3, z), c_air, c_ignore, c_snow)
end
@ -301,7 +319,7 @@ function default.grow_pine_tree(pos)
local via = a:index(xi, yy + 1, zz)
for xx = xi, xi + 1 do
add_pine_needles(data, vi, c_air, c_ignore, c_snow,
c_pine_needles)
c_pine_needles)
if snow then
add_snow(data, via, c_air, c_ignore, c_snow)
end
@ -319,7 +337,7 @@ function default.grow_pine_tree(pos)
for xx = x - dev, x + dev do
if random() < 0.95 - dev * 0.05 then
add_pine_needles(data, vi, c_air, c_ignore, c_snow,
c_pine_needles)
c_pine_needles)
if snow then
add_snow(data, via, c_air, c_ignore, c_snow)
end
@ -332,9 +350,14 @@ function default.grow_pine_tree(pos)
end
-- Trunk
for yy = y, maxy do
data[a:index(x, y, z)] = c_pine_tree -- Force-place lowest trunk node to replace sapling
for yy = y + 1, maxy do
local vi = a:index(x, yy, z)
data[vi] = c_pinetree
local node_id = data[vi]
if node_id == c_air or node_id == c_ignore or
node_id == c_pine_needles or node_id == c_snow then
data[vi] = c_pine_tree
end
end
vm:set_data(data)
@ -342,3 +365,46 @@ function default.grow_pine_tree(pos)
vm:update_map()
end
-- New apple tree
function default.grow_new_apple_tree(pos)
local path = minetest.get_modpath("default") .. "/schematics/apple_tree_from_sapling.mts"
minetest.place_schematic({x = pos.x - 2, y = pos.y - 1, z = pos.z - 2},
path, 0, nil, false)
end
-- New jungle tree
function default.grow_new_jungle_tree(pos)
local path = minetest.get_modpath("default") .. "/schematics/jungle_tree_from_sapling.mts"
minetest.place_schematic({x = pos.x - 2, y = pos.y - 1, z = pos.z - 2},
path, 0, nil, false)
end
-- New pine tree
function default.grow_new_pine_tree(pos)
local path = minetest.get_modpath("default") .. "/schematics/pine_tree_from_sapling.mts"
minetest.place_schematic({x = pos.x - 2, y = pos.y - 1, z = pos.z - 2},
path, 0, nil, false)
end
-- New acacia tree
function default.grow_new_acacia_tree(pos)
local path = minetest.get_modpath("default") .. "/schematics/acacia_tree_from_sapling.mts"
minetest.place_schematic({x = pos.x - 4, y = pos.y - 1, z = pos.z - 4},
path, random, nil, false)
end
-- New aspen tree
function default.grow_new_aspen_tree(pos)
local path = minetest.get_modpath("default") .. "/schematics/aspen_tree_from_sapling.mts"
minetest.place_schematic({x = pos.x - 2, y = pos.y - 1, z = pos.z - 2},
path, 0, nil, false)
end

View File

@ -1,20 +1,45 @@
-- Minetest 0.4 mod: stairs
-- See README.txt for licensing and other information.
-- Global namespace for functions
stairs = {}
-- Register aliases for new pine node names
minetest.register_alias("stairs:stair_pinewood", "stairs:stair_pine_wood")
minetest.register_alias("stairs:slab_pinewood", "stairs:slab_pine_wood")
-- Get setting for replace ABM
local replace = minetest.setting_getbool("enable_stairs_replace_abm")
-- Register stairs.
-- Node will be called stairs:stair_<subname>
function stairs.register_stair(subname, recipeitem, groups, images, description, sounds)
minetest.register_node(":stairs:stair_" .. subname, {
description = description,
drawtype = "nodebox",
drawtype = "mesh",
mesh = "stairs_stair.obj",
tiles = images,
paramtype = "light",
paramtype2 = "facedir",
is_ground_content = true,
is_ground_content = false,
groups = groups,
sounds = sounds,
node_box = {
selection_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, 0, 0.5},
{-0.5, 0, 0, 0.5, 0.5, 0.5},
},
},
collision_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, 0, 0.5},
@ -40,7 +65,7 @@ function stairs.register_stair(subname, recipeitem, groups, images, description,
param2 = minetest.dir_to_facedir(dir)
end
if p0.y-1 == p1.y then
if p0.y - 1 == p1.y then
param2 = param2 + 20
if param2 == 21 then
param2 = 23
@ -54,10 +79,12 @@ function stairs.register_stair(subname, recipeitem, groups, images, description,
})
-- for replace ABM
minetest.register_node(":stairs:stair_" .. subname.."upside_down", {
replace_name = "stairs:stair_" .. subname,
groups = {slabs_replace=1},
})
if replace then
minetest.register_node(":stairs:stair_" .. subname .. "upside_down", {
replace_name = "stairs:stair_" .. subname,
groups = {slabs_replace = 1},
})
end
minetest.register_craft({
output = 'stairs:stair_' .. subname .. ' 6',
@ -79,7 +106,10 @@ function stairs.register_stair(subname, recipeitem, groups, images, description,
})
end
-- Register slabs.
-- Node will be called stairs:slab_<subname>
function stairs.register_slab(subname, recipeitem, groups, images, description, sounds)
minetest.register_node(":stairs:slab_" .. subname, {
description = description,
@ -87,7 +117,7 @@ function stairs.register_slab(subname, recipeitem, groups, images, description,
tiles = images,
paramtype = "light",
paramtype2 = "facedir",
is_ground_content = true,
is_ground_content = false,
groups = groups,
sounds = sounds,
node_box = {
@ -112,7 +142,8 @@ function stairs.register_slab(subname, recipeitem, groups, images, description,
local n0_is_upside_down = (n0.name == "stairs:slab_" .. subname and
n0.param2 >= 20)
if n0.name == "stairs:slab_" .. subname and not n0_is_upside_down and p0.y+1 == p1.y then
if n0.name == "stairs:slab_" .. subname and not n0_is_upside_down and
p0.y + 1 == p1.y then
slabpos = p0
slabnode = n0
elseif n1.name == "stairs:slab_" .. subname then
@ -128,7 +159,8 @@ function stairs.register_slab(subname, recipeitem, groups, images, description,
pointed_thing.above = slabpos
local success
fakestack, success = minetest.item_place(fakestack, placer, pointed_thing)
fakestack, success = minetest.item_place(fakestack, placer,
pointed_thing)
-- If the item was taken from the fake stack, decrement original
if success then
itemstack:set_count(fakestack:get_count())
@ -140,7 +172,7 @@ function stairs.register_slab(subname, recipeitem, groups, images, description,
end
-- Upside down slabs
if p0.y-1 == p1.y then
if p0.y - 1 == p1.y then
-- Turn into full block if pointing at a existing slab
if n0_is_upside_down then
-- Remove the slab at the position of the slab
@ -151,7 +183,8 @@ function stairs.register_slab(subname, recipeitem, groups, images, description,
pointed_thing.above = p0
local success
fakestack, success = minetest.item_place(fakestack, placer, pointed_thing)
fakestack, success = minetest.item_place(fakestack, placer,
pointed_thing)
-- If the item was taken from the fake stack, decrement original
if success then
itemstack:set_count(fakestack:get_count())
@ -167,7 +200,7 @@ function stairs.register_slab(subname, recipeitem, groups, images, description,
end
-- If pointing at the side of a upside down slab
if n0_is_upside_down and p0.y+1 ~= p1.y then
if n0_is_upside_down and p0.y + 1 ~= p1.y then
param2 = 20
end
@ -176,10 +209,12 @@ function stairs.register_slab(subname, recipeitem, groups, images, description,
})
-- for replace ABM
minetest.register_node(":stairs:slab_" .. subname.."upside_down", {
replace_name = "stairs:slab_"..subname,
groups = {slabs_replace=1},
})
if replace then
minetest.register_node(":stairs:slab_" .. subname .. "upside_down", {
replace_name = "stairs:slab_".. subname,
groups = {slabs_replace = 1},
})
end
minetest.register_craft({
output = 'stairs:slab_' .. subname .. ' 6',
@ -189,123 +224,184 @@ function stairs.register_slab(subname, recipeitem, groups, images, description,
})
end
-- Replace old "upside_down" nodes with new param2 versions
minetest.register_abm({
nodenames = {"group:slabs_replace"},
interval = 1,
chance = 1,
action = function(pos, node)
node.name = minetest.registered_nodes[node.name].replace_name
node.param2 = node.param2 + 20
if node.param2 == 21 then
node.param2 = 23
elseif node.param2 == 23 then
node.param2 = 21
end
minetest.set_node(pos, node)
end,
})
-- Optionally replace old "upside_down" nodes with new param2 versions.
-- Disabled by default.
if replace then
minetest.register_abm({
nodenames = {"group:slabs_replace"},
interval = 8,
chance = 1,
action = function(pos, node)
node.name = minetest.registered_nodes[node.name].replace_name
node.param2 = node.param2 + 20
if node.param2 == 21 then
node.param2 = 23
elseif node.param2 == 23 then
node.param2 = 21
end
minetest.set_node(pos, node)
end,
})
end
-- Stair/slab registration function.
-- Nodes will be called stairs:{stair,slab}_<subname>
function stairs.register_stair_and_slab(subname, recipeitem, groups, images, desc_stair, desc_slab, sounds)
function stairs.register_stair_and_slab(subname, recipeitem, groups, images,
desc_stair, desc_slab, sounds)
stairs.register_stair(subname, recipeitem, groups, images, desc_stair, sounds)
stairs.register_slab(subname, recipeitem, groups, images, desc_slab, sounds)
end
-- Register default stairs and slabs
stairs.register_stair_and_slab("wood", "default:wood",
{snappy=2,choppy=2,oddly_breakable_by_hand=2,flammable=3},
{snappy = 2, choppy = 2, oddly_breakable_by_hand = 2, flammable = 3},
{"default_wood.png"},
"Wooden Stair",
"Wooden Slab",
default.node_sound_wood_defaults())
stairs.register_stair_and_slab("junglewood", "default:junglewood",
{snappy = 2, choppy = 2, oddly_breakable_by_hand = 2, flammable = 3},
{"default_junglewood.png"},
"Junglewood Stair",
"Junglewood Slab",
default.node_sound_wood_defaults())
stairs.register_stair_and_slab("pine_wood", "default:pine_wood",
{snappy = 2, choppy = 2, oddly_breakable_by_hand = 2, flammable = 3},
{"default_pine_wood.png"},
"Pine Wood Stair",
"Pine Wood Slab",
default.node_sound_wood_defaults())
stairs.register_stair_and_slab("acacia_wood", "default:acacia_wood",
{snappy = 2, choppy = 2, oddly_breakable_by_hand = 2, flammable = 3},
{"default_acacia_wood.png"},
"Acacia Wood Stair",
"Acacia Wood Slab",
default.node_sound_wood_defaults())
stairs.register_stair_and_slab("aspen_wood", "default:aspen_wood",
{snappy = 2, choppy = 2, oddly_breakable_by_hand = 2, flammable = 3},
{"default_aspen_wood.png"},
"Aspen Wood Stair",
"Aspen Wood Slab",
default.node_sound_wood_defaults())
stairs.register_stair_and_slab("stone", "default:stone",
{cracky=3},
{cracky = 3},
{"default_stone.png"},
"Stone Stair",
"Stone Slab",
default.node_sound_stone_defaults())
stairs.register_stair_and_slab("cobble", "default:cobble",
{cracky=3},
{cracky = 3},
{"default_cobble.png"},
"Cobblestone Stair",
"Cobblestone Slab",
default.node_sound_stone_defaults())
stairs.register_stair_and_slab("stonebrick", "default:stonebrick",
{cracky = 3},
{"default_stone_brick.png"},
"Stone Brick Stair",
"Stone Brick Slab",
default.node_sound_stone_defaults())
stairs.register_stair_and_slab("desert_stone", "default:desert_stone",
{cracky=3},
{cracky = 3},
{"default_desert_stone.png"},
"Desertstone Stair",
"Desertstone Slab",
default.node_sound_stone_defaults())
stairs.register_stair_and_slab("desert_cobble", "default:desert_cobble",
{cracky=3},
{cracky = 3},
{"default_desert_cobble.png"},
"Desert Cobblestone Stair",
"Desert Cobblestone Slab",
default.node_sound_stone_defaults())
stairs.register_stair_and_slab("desert_stonebrick", "default:desert_stonebrick",
{cracky=3},
{cracky = 3},
{"default_desert_stone_brick.png"},
"Desert Stone Brick Stair",
"Desert Stone Brick Slab",
default.node_sound_stone_defaults())
stairs.register_stair_and_slab("brick", "default:brick",
{cracky=3},
{"default_brick.png"},
"Brick Stair",
"Brick Slab",
default.node_sound_stone_defaults())
stairs.register_stair_and_slab("sandstone", "default:sandstone",
{crumbly=2,cracky=2},
{crumbly = 2, cracky = 2},
{"default_sandstone.png"},
"Sandstone Stair",
"Sandstone Slab",
default.node_sound_stone_defaults())
stairs.register_stair_and_slab("sandstonebrick", "default:sandstonebrick",
{crumbly=2,cracky=2},
{crumbly = 2, cracky = 2},
{"default_sandstone_brick.png"},
"Sandstone Brick Stair",
"Sandstone Brick Slab",
default.node_sound_stone_defaults())
stairs.register_stair_and_slab("junglewood", "default:junglewood",
{snappy=2,choppy=2,oddly_breakable_by_hand=2,flammable=3},
{"default_junglewood.png"},
"Junglewood Stair",
"Junglewood Slab",
default.node_sound_wood_defaults())
stairs.register_stair_and_slab("stonebrick", "default:stonebrick",
{cracky=3},
{"default_stone_brick.png"},
"Stone Brick Stair",
"Stone Brick Slab",
default.node_sound_stone_defaults())
stairs.register_stair_and_slab("pinewood", "default:pinewood",
{snappy=2,choppy=2,oddly_breakable_by_hand=2,flammable=3},
{"default_pinewood.png"},
"Pinewood Stair",
"Pinewood Slab",
default.node_sound_wood_defaults())
stairs.register_stair_and_slab("obsidian", "default:obsidian",
{cracky=1,level=2},
{cracky = 1, level = 2},
{"default_obsidian.png"},
"Obsidian Stair",
"Obsidian Slab",
default.node_sound_stone_defaults())
stairs.register_stair_and_slab("obsidianbrick", "default:obsidianbrick",
{cracky=1,level=2},
{cracky = 1, level = 2},
{"default_obsidian_brick.png"},
"Obsidian Brick Stair",
"Obsidian Brick Slab",
default.node_sound_stone_defaults())
stairs.register_stair_and_slab("brick", "default:brick",
{cracky = 3},
{"default_brick.png"},
"Brick Stair",
"Brick Slab",
default.node_sound_stone_defaults())
stairs.register_stair_and_slab("straw", "farming:straw",
{snappy = 3, flammable = 4},
{"farming_straw.png"},
"Straw Stair",
"Straw Slab",
default.node_sound_leaves_defaults())
stairs.register_stair_and_slab("steelblock", "default:steelblock",
{cracky = 1, level = 2},
{"default_steel_block.png"},
"Steel Block Stair",
"Steel Block Slab",
default.node_sound_stone_defaults())
stairs.register_stair_and_slab("copperblock", "default:copperblock",
{cracky = 1, level = 2},
{"default_copper_block.png"},
"Copper Block Stair",
"Copper Block Slab",
default.node_sound_stone_defaults())
stairs.register_stair_and_slab("bronzeblock", "default:bronzeblock",
{cracky = 1, level = 2},
{"default_bronze_block.png"},
"Bronze Block Stair",
"Bronze Block Slab",
default.node_sound_stone_defaults())
stairs.register_stair_and_slab("goldblock", "default:goldblock",
{cracky = 1},
{"default_gold_block.png"},
"Gold Block Stair",
"Gold Block Slab",
default.node_sound_stone_defaults())

View File

@ -0,0 +1,113 @@
# Blender v2.72 (sub 0) OBJ File: ''
# www.blender.org
mtllib stairs.mtl
o stairs_top
v -0.500000 0.000000 -0.500000
v -0.500000 0.000000 0.000000
v 0.500000 0.000000 0.000000
v 0.500000 0.000000 -0.500000
v -0.500000 0.500000 0.000000
v 0.500000 0.500000 0.000000
v -0.500000 0.500000 0.500000
v 0.500000 0.500000 0.500000
vt 0.000000 0.000000
vt 1.000000 0.000000
vt 1.000000 0.500000
vt 0.000000 0.500000
vt 1.000000 1.000000
vt 0.000000 1.000000
vn 0.000000 1.000000 0.000000
g stairs_top
usemtl None
s off
f 4/1/1 1/2/1 2/3/1 3/4/1
f 7/5/1 8/6/1 6/4/1 5/3/1
o stairs_bottom
v -0.500000 -0.500000 -0.500000
v 0.500000 -0.500000 -0.500000
v -0.500000 -0.500000 0.500000
v 0.500000 -0.500000 0.500000
vt 1.000000 0.000000
vt 1.000000 1.000000
vt 0.000000 1.000000
vt 0.000000 0.000000
vn 0.000000 -1.000000 -0.000000
g stairs_bottom
usemtl None
s off
f 11/7/2 9/8/2 10/9/2 12/10/2
o stairs_right
v -0.500000 0.000000 -0.500000
v -0.500000 -0.500000 -0.500000
v -0.500000 0.000000 0.000000
v -0.500000 -0.500000 0.500000
v -0.500000 0.500000 0.000000
v -0.500000 0.500000 0.500000
vt 0.000000 0.500000
vt 0.000000 0.000000
vt 0.500000 0.500000
vt 1.000000 1.000000
vt 0.500000 1.000000
vt 1.000000 0.000000
vn -1.000000 0.000000 0.000000
g stairs_right
usemtl None
s off
f 13/11/3 14/12/3 15/13/3
f 15/13/3 18/14/3 17/15/3
f 14/12/3 16/16/3 18/14/3
o stairs_left
v 0.500000 0.000000 0.000000
v 0.500000 -0.500000 -0.500000
v 0.500000 0.000000 -0.500000
v 0.500000 -0.500000 0.500000
v 0.500000 0.500000 0.000000
v 0.500000 0.500000 0.500000
vt 0.500000 0.500000
vt 1.000000 0.000000
vt 1.000000 0.500000
vt 0.500000 1.000000
vt 0.000000 1.000000
vt 0.000000 0.000000
vn 1.000000 0.000000 0.000000
g stairs_left
usemtl None
s off
f 19/17/4 20/18/4 21/19/4
f 19/17/4 23/20/4 24/21/4
f 20/18/4 24/21/4 22/22/4
o stairs_back
v -0.500000 -0.500000 0.500000
v 0.500000 -0.500000 0.500000
v -0.500000 0.500000 0.500000
v 0.500000 0.500000 0.500000
vt 1.000000 0.000000
vt 1.000000 1.000000
vt 0.000000 1.000000
vt 0.000000 0.000000
vn 0.000000 -0.000000 1.000000
g stairs_back
usemtl None
s off
f 26/23/5 28/24/5 27/25/5 25/26/5
o stairs_front
v -0.500000 0.000000 -0.500000
v -0.500000 -0.500000 -0.500000
v -0.500000 0.000000 0.000000
v 0.500000 0.000000 0.000000
v 0.500000 -0.500000 -0.500000
v 0.500000 0.000000 -0.500000
v -0.500000 0.500000 0.000000
v 0.500000 0.500000 0.000000
vt 1.000000 0.000000
vt 1.000000 0.500000
vt 0.000000 0.500000
vt 0.000000 0.000000
vt 1.000000 1.000000
vt 0.000000 1.000000
vn 0.000000 0.000000 -1.000000
g stairs_front
usemtl None
s off
f 30/27/6 29/28/6 34/29/6 33/30/6
f 31/28/6 35/31/6 36/32/6 32/29/6