2012-09-20 15:39:45 +09:30

96 lines
2.7 KiB
Lua

--To add a new smooth node you have to define the node also
--the node that will be checked for corresponding BOTTOM_NODE
local NODE = {
"default:dirt",
"default:dirt_with_grass",
"default:cobble",
"default:wood",
"default:tree",
}
-- the node below the checked NODE
local BOTTOM_NODE = {
"default:stone",
"default:stone",
"default:stone",
"default:dirt",
"default:dirt"
}
-- the node to which it will change
local NEW = {
"smooth:dirt_stone",
"smooth:dirt_stone",
"smooth:cobble_stone",
"smooth:wood_grass",
"smooth:tree_grass",
}
-- if we should change the top or bottom node
local TOP = {
"false",
"false",
"false",
"true",
"true",
}
--register abm for node changes
for i, node in ipairs(NODE) do
minetest.register_abm({
nodenames = {NODE[i]},
interval = 30,
chance = 3,
action = function(pos)
local bottom = {x=pos.x, y=pos.y-1, z=pos.z}
local node = minetest.env:get_node(bottom)
if (node.name==BOTTOM_NODE[i]) then
if TOP[i] == "false" then
minetest.env:remove_node(bottom)
minetest.env:add_node(bottom, {name=NEW[i]})
else
minetest.env:remove_node(pos)
minetest.env:add_node(pos, {name=NEW[i]})
end
end
end
})
end
--define the nodes
minetest.register_node("smooth:dirt_stone", {
description = "Dirt Stone",
tile_images = {"smooth_dirt_stone_top.png", "default_stone.png", "default_stone.png^smooth_dirt_stone.png"},
is_ground_content = true,
groups = {cracky=3},
drop = 'default:cobble',
sounds = default.node_sound_stone_defaults(),
})
minetest.register_node("smooth:cobble_stone", {
description = "Cobble Stone",
tile_images = {"smooth_cobble_stone_top.png", "default_stone.png", "default_stone.png^smooth_cobble_stone.png"},
is_ground_content = true,
groups = {cracky=3},
drop = 'default:cobble',
sounds = default.node_sound_stone_defaults(),
})
minetest.register_node("smooth:wood_grass", {
description = "Wood Grass",
tile_images = {"default_wood.png", "default_wood.png", "default_wood.png^smooth_grass.png"},
is_ground_content = true,
drop = 'default:wood',
groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=3},
sounds = default.node_sound_wood_defaults(),
})
minetest.register_node("smooth:tree_grass", {
description = "Tree Grass",
tile_images = {"default_tree_top.png", "default_tree_top.png", "default_tree.png^smooth_grass.png"},
is_ground_content = true,
groups = {tree=1,snappy=1,choppy=2,oddly_breakable_by_hand=1,flammable=2},
sounds = default.node_sound_wood_defaults(),
drop = 'default:tree',
})
minetest.log("action", "[MOD]"..minetest.get_current_modname().." -- loaded from "..minetest.get_modpath(minetest.get_current_modname()))