forked from MineClone5/MineClone5
Add group support to mcl_walls API
This commit is contained in:
parent
d36beaf64f
commit
d0bcf7897e
|
@ -82,11 +82,26 @@ local full_blocks = {
|
||||||
}
|
}
|
||||||
|
|
||||||
--[[ Adds a new wall type.
|
--[[ Adds a new wall type.
|
||||||
* nodename: Itemstring of base node. Must not contain an underscore
|
* nodename: Itemstring of base node to add. Must not contain an underscore
|
||||||
* name: Item name, visible to user
|
* description: Item description (tooltip), visible to user
|
||||||
* tiles: Wall textures table
|
* tiles: Wall textures table
|
||||||
* invtex: Inventory image (optional) ]]
|
* invtex: Inventory image (optional)
|
||||||
function mcl_walls.register_wall(nodename, name, tiles, invtex)
|
* groups: Base group memberships (optional, default is {cracky=3})
|
||||||
|
]]
|
||||||
|
function mcl_walls.register_wall(nodename, description, tiles, invtex, groups)
|
||||||
|
|
||||||
|
local base_groups = groups
|
||||||
|
if not base_groups then
|
||||||
|
base_groups = {cracky=3}
|
||||||
|
end
|
||||||
|
base_groups.wall = 1
|
||||||
|
|
||||||
|
internal_groups = table.copy(base_groups)
|
||||||
|
internal_groups.not_in_creative_inventory = 1
|
||||||
|
|
||||||
|
main_node_groups = table.copy(base_groups)
|
||||||
|
main_node_groups.deco_block = 1
|
||||||
|
|
||||||
for i = 0, 15 do
|
for i = 0, 15 do
|
||||||
local need = {}
|
local need = {}
|
||||||
local need_pillar = false
|
local need_pillar = false
|
||||||
|
@ -123,7 +138,7 @@ function mcl_walls.register_wall(nodename, name, tiles, invtex)
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
tiles = tiles,
|
tiles = tiles,
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
groups = {snappy=2,cracky=3,oddly_breakable_by_hand=3,wall=1,not_in_creative_inventory=1},
|
groups = internal_groups,
|
||||||
drop = nodename,
|
drop = nodename,
|
||||||
node_box = {
|
node_box = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
|
@ -142,7 +157,7 @@ function mcl_walls.register_wall(nodename, name, tiles, invtex)
|
||||||
tiles = tiles,
|
tiles = tiles,
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
groups = {snappy=2,cracky=3,oddly_breakable_by_hand=3,wall=1,not_in_creative_inventory=1},
|
groups = internal_groups,
|
||||||
drop = nodename,
|
drop = nodename,
|
||||||
node_box = {
|
node_box = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
|
@ -160,7 +175,7 @@ function mcl_walls.register_wall(nodename, name, tiles, invtex)
|
||||||
tiles = tiles,
|
tiles = tiles,
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
groups = {snappy=2,cracky=3,oddly_breakable_by_hand=3,wall=1,not_in_creative_inventory=1},
|
groups = internal_groups,
|
||||||
drop = nodename,
|
drop = nodename,
|
||||||
node_box = {
|
node_box = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
|
@ -171,10 +186,10 @@ function mcl_walls.register_wall(nodename, name, tiles, invtex)
|
||||||
|
|
||||||
-- Inventory item
|
-- Inventory item
|
||||||
minetest.register_node(nodename, {
|
minetest.register_node(nodename, {
|
||||||
description = name,
|
description = description,
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
groups = {snappy=2,cracky=3,oddly_breakable_by_hand=3,wall=1,deco_block=1},
|
groups = main_node_groups,
|
||||||
tiles = tiles,
|
tiles = tiles,
|
||||||
inventory_image = invtex,
|
inventory_image = invtex,
|
||||||
stack_max = 64,
|
stack_max = 64,
|
||||||
|
|
Loading…
Reference in New Issue