Cleanup 1

This commit is contained in:
Kotolegokot 2012-11-09 22:55:59 +06:00
parent 2581691177
commit fd20591b1d
4 changed files with 60 additions and 56 deletions

View File

@ -0,0 +1 @@
default

View File

@ -1,8 +1,10 @@
DISABLE_BLOCKS={ removing_blocks = {}
removing_blocks.blocks = {
"default:tree",
"default:leaves",
} }
for i, block in ipairs(removing_blocks.blocks) do
for i=1, #DISABLE_BLOCKS do minetest.register_node(":"..block, {
minetest.register_node(":"..DISABLE_BLOCKS[i], {
drawtype = "airlike", drawtype = "airlike",
paramtype = "light", paramtype = "light",
light_propagates = true, light_propagates = true,

View File

@ -1 +1,2 @@
default default
helper_functions

View File

@ -1,20 +1,13 @@
dofile(minetest.get_modpath("trees").."/treegen.lua") dofile(minetest.get_modpath("trees").."/treegen.lua")
GROUND_LIST={ trees = {}
'default:dirt',
'default:dirt_with_grass', trees.grounds = {
"default:dirt",
"default:dirt_with_grass",
} }
local table_containts = function(t, v) trees.list = {
for _, i in ipairs(t) do
if i==v then
return true
end
end
return false
end
TREES_LIST={
"ash", "ash",
"aspen", "aspen",
"birch", "birch",
@ -23,10 +16,19 @@ TREES_LIST={
"pine", "pine",
} }
for i=1,#TREES_LIST do trees.desc_list = {
minetest.register_node("trees:"..TREES_LIST[i].."_trunk", { "Ash",
description = "Log of "..TREES_LIST[i], "Aspen",
tiles = {"trees_"..TREES_LIST[i].."_trunk_top.png", "trees_"..TREES_LIST[i].."_trunk_top.png", "trees_"..TREES_LIST[i].."_trunk.png"}, "Birch",
"Chestnut",
"Mapple",
"Pine",
}
for i, tree in ipairs(trees.list) do
minetest.register_node("trees:"..tree.."_trunk", {
description = "Log of "..trees.desc_list[i],
tiles = {"trees_"..tree.."_trunk_top.png", "trees_"..tree.."_trunk_top.png", "trees_"..tree.."_trunk.png"},
is_ground_content = true, is_ground_content = true,
groups = {tree=1,snappy=1,choppy=2,flammable=2}, groups = {tree=1,snappy=1,choppy=2,flammable=2},
sounds = default.node_sound_wood_defaults(), sounds = default.node_sound_wood_defaults(),
@ -44,29 +46,28 @@ for i=1,#TREES_LIST do
{-0.4,-0.5,-0.4,0.4,0.5,0.4}, {-0.4,-0.5,-0.4,0.4,0.5,0.4},
}, },
}, },
climbable = true,
}) })
minetest.register_node("trees:"..TREES_LIST[i].."_leaves", { minetest.register_node("trees:"..tree.."_leaves", {
description = "Leaves of "..TREES_LIST[i], description = "Leaves of "..trees.desc_list[i],
drawtype = "allfaces_optional", drawtype = "allfaces_optional",
visual_scale = 1.3, visual_scale = 1.3,
tiles = {"trees_"..TREES_LIST[i].."_leaves.png"}, tiles = {"trees_"..tree.."_leaves.png"},
paramtype = "light", paramtype = "light",
groups = {snappy=3, leafdecay=3, flammable=2}, groups = {snappy=3, leafdecay=3, flammable=2},
drop = { drop = {
max_items = 1, max_items = 1,
items = { items = {
{ {
items = {'trees:'..TREES_LIST[i]..'_sapling'}, items = {'trees:'..tree..'_sapling'},
rarity = 15, rarity = 15,
}, },
{ {
items = {'trees:'..TREES_LIST[i]..'_stick'}, items = {'trees:'..tree..'_stick'},
rarity = 2, rarity = 2,
}, },
{ {
items = {"trees:"..TREES_LIST[i].."_leaves"}, items = {"trees:"..tree.."_leaves"},
} }
} }
}, },
@ -75,18 +76,17 @@ for i=1,#TREES_LIST do
climbable = true, climbable = true,
}) })
minetest.register_node("trees:"..TREES_LIST[i].."_wood", { minetest.register_node("trees:"..tree.."_wood", {
description = "Wooden Planks of "..TREES_LIST[i], description = "Wooden Planks of "..trees.desc_list[i],
tiles = {"trees_"..TREES_LIST[i].."_wood.png"}, tiles = {"trees_"..tree.."_wood.png"},
inventory_image = "",
is_ground_content = true, is_ground_content = true,
groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=3}, groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=3},
sounds = default.node_sound_wood_defaults(), sounds = default.node_sound_wood_defaults(),
}) })
minetest.register_craftitem("trees:"..TREES_LIST[i].."_stick", { minetest.register_craftitem("trees:"..tree.."_stick", {
description = "Stick of "..TREES_LIST[i], description = "Stick of "..trees.desc_list[i],
inventory_image = "trees_"..TREES_LIST[i].."_stick.png", inventory_image = "trees_"..tree.."_stick.png",
groups = {sticks=3}, groups = {sticks=3},
--[[on_use = function(itemstack, user, pointed_thing) --[[on_use = function(itemstack, user, pointed_thing)
if pointed_thing.type ~= "node" then if pointed_thing.type ~= "node" then
@ -97,13 +97,13 @@ for i=1,#TREES_LIST do
end,]] end,]]
}) })
minetest.register_node("trees:"..TREES_LIST[i].."_sapling", { minetest.register_node("trees:"..tree.."_sapling", {
description = "Sapling of "..TREES_LIST[i], description = "Sapling of "..trees.desc_list[i],
drawtype = "plantlike", drawtype = "plantlike",
visual_scale = 1.0, visual_scale = 1.0,
tiles = {"trees_"..TREES_LIST[i].."_sapling.png"}, tiles = {"trees_"..tree.."_sapling.png"},
inventory_image = "trees_"..TREES_LIST[i].."_sapling.png", inventory_image = "trees_"..tree.."_sapling.png",
wield_image = "trees_"..TREES_LIST[i].."_sapling.png", wield_image = "trees_"..tree.."_sapling.png",
paramtype = "light", paramtype = "light",
walkable = false, walkable = false,
groups = {snappy=2,dig_immediate=3,flammable=2}, groups = {snappy=2,dig_immediate=3,flammable=2},
@ -124,22 +124,22 @@ for i=1,#TREES_LIST do
})]] })]]
minetest.register_abm({ minetest.register_abm({
nodenames = {"trees:"..TREES_LIST[i].."_trunk"}, nodenames = {"trees:"..tree.."_trunk"},
interval = 1.0, interval = 1.0,
chance = 1.0, chance = 1.0,
action = function(pos, node, active_object_count, active_object_count_wider) action = function(pos, node, active_object_count, active_object_count_wider)
if table_containts(GROUND_LIST, minetest.env:get_node({x = pos.x, y = pos.y-1, z = pos.z}).name) then return end if table.contains(trees.grounds, minetest.env:get_node({x = pos.x, y = pos.y-1, z = pos.z}).name) then return end
for x = -1, 1 do for x = -1, 1 do
for z = -1, 1 do for z = -1, 1 do
local posn={x = pos.x+x, y = pos.y-1, z = pos.z+z} local posn={x = pos.x+x, y = pos.y-1, z = pos.z+z}
if minetest.env:get_node(posn).name == "trees:"..TREES_LIST[i].."_trunk" then if minetest.env:get_node(posn).name == "trees:"..tree.."_trunk" then
return return
end
end end
end end
end minetest.env:add_item(pos, "trees:"..tree.."_trunk")
minetest.env:add_item(pos, "trees:"..TREES_LIST[i].."_trunk") minetest.env:add_node(pos, {name="air"})
minetest.env:add_node(pos, {name="air"}) end,
end,
}) })
end end
@ -234,4 +234,4 @@ function(minp, maxp, seed)
end end
end) end)
end) end)