cleanup node registration.
separate tree and leaves registrations into own files.
This commit is contained in:
parent
aae1beea64
commit
00829dbce9
3 changed files with 103 additions and 100 deletions
|
@ -1,105 +1,7 @@
|
|||
local modname = minetest.get_current_modname()
|
||||
|
||||
local function reg_log (name, def)
|
||||
def = def or {}
|
||||
|
||||
def.description = def.description or "Log"
|
||||
|
||||
local texture = def.texture or name
|
||||
def.tiles = blockgame.underride(def.tiles, {
|
||||
modname .. "_" .. texture .. "_top.png",
|
||||
modname .. "_" .. texture .. "_top.png",
|
||||
modname .. "_" .. texture .. ".png",
|
||||
})
|
||||
|
||||
def.groups = blockgame.underride(def.groups, {
|
||||
woody = 1,
|
||||
supports_leaves = 1,
|
||||
})
|
||||
|
||||
blockgame.register_node(modname .. ":" .. name, def)
|
||||
end
|
||||
|
||||
reg_log("log")
|
||||
reg_log("log_alive", {
|
||||
groups = {
|
||||
planty = 1,
|
||||
},
|
||||
texture = "log",
|
||||
drop = modname .. ":log",
|
||||
})
|
||||
reg_log("sapling", {
|
||||
groups = {
|
||||
planty = 1,
|
||||
},
|
||||
drop = modname .. ":log",
|
||||
})
|
||||
|
||||
|
||||
|
||||
local function leaves_fall_check (pos, node)
|
||||
return blockgame.every(blockgame.vector.get_neighbors(pos), function (pos)
|
||||
return minetest.get_item_group(minetest.get_node(pos).name, "supports_leaves") == 0
|
||||
end)
|
||||
end
|
||||
|
||||
local function reg_leaves (name, def)
|
||||
def.description = def.description or name
|
||||
def.texture = def.texture or name
|
||||
def.tiles = {modname .. "_" .. def.texture .. ".png"}
|
||||
|
||||
def.drawtype = "glasslike"
|
||||
def.paramtype = "light"
|
||||
def.sunlight_propagates = true
|
||||
|
||||
def.groups = blockgame.underride(def.groups, {
|
||||
planty = 1,
|
||||
supports_leaves = 1,
|
||||
air_flowable = 1,
|
||||
can_fall = 1,
|
||||
})
|
||||
|
||||
blockgame.register_node(modname .. ":" .. name, def)
|
||||
end
|
||||
|
||||
local nutty_drops = {
|
||||
max_items = 3,
|
||||
items = {
|
||||
{
|
||||
rarity = 8,
|
||||
items = {modname .. ":nut"},
|
||||
},
|
||||
{
|
||||
rarity = 12,
|
||||
items = {modname .. ":nut 2"},
|
||||
},
|
||||
{
|
||||
rarity = 1,
|
||||
items = {modname .. ":leaves"},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
reg_leaves("leaves", {
|
||||
description = "Leaves",
|
||||
})
|
||||
reg_leaves("leaves_growing", {
|
||||
description = "Growing Leaves",
|
||||
texture = "leaves_alive",
|
||||
drop = nutty_drops,
|
||||
fall_check = leaves_fall_check,
|
||||
})
|
||||
reg_leaves("leaves_alive", {
|
||||
description = "Leaves",
|
||||
drop = nutty_drops,
|
||||
fall_check = leaves_fall_check,
|
||||
})
|
||||
reg_leaves("leaves_decomposing", {
|
||||
description = "Decomposing Leaves",
|
||||
groups = {
|
||||
supports_leaves = 0,
|
||||
},
|
||||
})
|
||||
load_file("node_log")
|
||||
load_file("node_leaves")
|
||||
|
||||
blockgame.reg_simple_node("nut", "Nut", {
|
||||
woody = 1,
|
||||
|
|
65
mods/bg_tree/node_leaves.lua
Normal file
65
mods/bg_tree/node_leaves.lua
Normal file
|
@ -0,0 +1,65 @@
|
|||
local modname = minetest.get_current_modname()
|
||||
|
||||
local function leaves_fall_check (pos, node)
|
||||
return blockgame.every(blockgame.vector.get_neighbors(pos), function (pos)
|
||||
return minetest.get_item_group(minetest.get_node(pos).name, "supports_leaves") == 0
|
||||
end)
|
||||
end
|
||||
|
||||
local function reg_leaves (name, def)
|
||||
def.description = def.description or name
|
||||
def.texture = def.texture or name
|
||||
def.tiles = {modname .. "_" .. def.texture .. ".png"}
|
||||
|
||||
def.drawtype = "glasslike"
|
||||
def.paramtype = "light"
|
||||
def.sunlight_propagates = true
|
||||
|
||||
def.groups = blockgame.underride(def.groups, {
|
||||
planty = 1,
|
||||
supports_leaves = 1,
|
||||
air_flowable = 1,
|
||||
can_fall = 1,
|
||||
})
|
||||
|
||||
blockgame.register_node(modname .. ":" .. name, def)
|
||||
end
|
||||
|
||||
local nutty_drops = {
|
||||
max_items = 3,
|
||||
items = {
|
||||
{
|
||||
rarity = 8,
|
||||
items = {modname .. ":nut"},
|
||||
},
|
||||
{
|
||||
rarity = 12,
|
||||
items = {modname .. ":nut 2"},
|
||||
},
|
||||
{
|
||||
rarity = 1,
|
||||
items = {modname .. ":leaves"},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
reg_leaves("leaves", {
|
||||
description = "Leaves",
|
||||
})
|
||||
reg_leaves("leaves_growing", {
|
||||
description = "Growing Leaves",
|
||||
texture = "leaves_alive",
|
||||
drop = nutty_drops,
|
||||
fall_check = leaves_fall_check,
|
||||
})
|
||||
reg_leaves("leaves_alive", {
|
||||
description = "Leaves",
|
||||
drop = nutty_drops,
|
||||
fall_check = leaves_fall_check,
|
||||
})
|
||||
reg_leaves("leaves_decomposing", {
|
||||
description = "Decomposing Leaves",
|
||||
groups = {
|
||||
supports_leaves = 0,
|
||||
},
|
||||
})
|
36
mods/bg_tree/node_log.lua
Normal file
36
mods/bg_tree/node_log.lua
Normal file
|
@ -0,0 +1,36 @@
|
|||
local modname = minetest.get_current_modname()
|
||||
|
||||
local function reg_log (name, def)
|
||||
def = def or {}
|
||||
|
||||
def.description = def.description or "Log"
|
||||
|
||||
local texture = def.texture or name
|
||||
def.tiles = blockgame.underride(def.tiles, {
|
||||
modname .. "_" .. texture .. "_top.png",
|
||||
modname .. "_" .. texture .. "_top.png",
|
||||
modname .. "_" .. texture .. ".png",
|
||||
})
|
||||
|
||||
def.groups = blockgame.underride(def.groups, {
|
||||
woody = 1,
|
||||
supports_leaves = 1,
|
||||
})
|
||||
|
||||
blockgame.register_node(modname .. ":" .. name, def)
|
||||
end
|
||||
|
||||
reg_log("log")
|
||||
reg_log("log_alive", {
|
||||
groups = {
|
||||
planty = 1,
|
||||
},
|
||||
texture = "log",
|
||||
drop = modname .. ":log",
|
||||
})
|
||||
reg_log("sapling", {
|
||||
groups = {
|
||||
planty = 1,
|
||||
},
|
||||
drop = modname .. ":log",
|
||||
})
|
Loading…
Reference in a new issue