Automatically add craft for walls
This commit is contained in:
parent
beb8e50eb6
commit
e866c610cb
|
@ -2,18 +2,25 @@
|
||||||
|
|
||||||
This API allows you to add more walls (like the cobblestone wall) to MineClone 2.
|
This API allows you to add more walls (like the cobblestone wall) to MineClone 2.
|
||||||
|
|
||||||
## `mcl_walls.register_wall(nodename, description, tiles, invtex, groups, sounds)`
|
## `mcl_walls.register_wall(nodename, description, craft_material, tiles, invtex, groups, sounds)`
|
||||||
|
|
||||||
Adds a new wall type. This is optimized for stone-based walls, but other materials are theoretically possible, too.
|
Adds a new wall type. This is optimized for stone-based walls, but other materials are theoretically possible, too.
|
||||||
|
|
||||||
The current implementation registers a couple of nodes for the different nodeboxes.
|
The current implementation registers a couple of nodes for the different nodeboxes.
|
||||||
All walls connect to solid nodes and all other wall nodes.
|
All walls connect to solid nodes and all other wall nodes.
|
||||||
|
|
||||||
The crafting recipe is NOT registered, you have to add your own.
|
If `craft_material` is not `nil` it also adds a crafting recipe of the following form:
|
||||||
|
|
||||||
|
CCC
|
||||||
|
CCC
|
||||||
|
|
||||||
|
Yields 6 walls
|
||||||
|
C = craft_material (can be group)
|
||||||
|
|
||||||
### Parameters
|
### Parameters
|
||||||
* `nodename`: Full itemstring of the new wall node (base node only). ***Must not have an underscore!***
|
* `nodename`: Full itemstring of the new wall node (base node only). ***Must not have an underscore!***
|
||||||
* `description`: Item description of item (tooltip), visible to user
|
* `description`: Item description of item (tooltip), visible to user
|
||||||
|
* `craft_material`: Item to be used in the crafting recipe. If `nil`, no crafting recipe will be added
|
||||||
* `tiles`: Wall textures table, same syntax as for `minetest.register_node`
|
* `tiles`: Wall textures table, same syntax as for `minetest.register_node`
|
||||||
* `inventory_image`: Inventory image (optional, default is an ugly 3D image)
|
* `inventory_image`: Inventory image (optional, default is an ugly 3D image)
|
||||||
* `groups`: Base group memberships (optional, default is `{cracky=3}`)
|
* `groups`: Base group memberships (optional, default is `{cracky=3}`)
|
||||||
|
|
|
@ -84,12 +84,13 @@ local full_blocks = {
|
||||||
--[[ Adds a new wall type.
|
--[[ Adds a new wall type.
|
||||||
* nodename: Itemstring of base node to add. Must not contain an underscore
|
* nodename: Itemstring of base node to add. Must not contain an underscore
|
||||||
* description: Item description (tooltip), visible to user
|
* description: Item description (tooltip), visible to user
|
||||||
|
* craft_material: Material for the default crafting recipe (optional)
|
||||||
* tiles: Wall textures table
|
* tiles: Wall textures table
|
||||||
* inventory_image: Inventory image (optional)
|
* inventory_image: Inventory image (optional)
|
||||||
* groups: Base group memberships (optional, default is {cracky=3})
|
* groups: Base group memberships (optional, default is {cracky=3})
|
||||||
* sounds: Sound table (optional, default is stone)
|
* sounds: Sound table (optional, default is stone)
|
||||||
]]
|
]]
|
||||||
function mcl_walls.register_wall(nodename, description, tiles, inventory_image, groups, sounds)
|
function mcl_walls.register_wall(nodename, description, craft_material, tiles, inventory_image, groups, sounds)
|
||||||
|
|
||||||
local base_groups = groups
|
local base_groups = groups
|
||||||
if not base_groups then
|
if not base_groups then
|
||||||
|
@ -211,29 +212,23 @@ function mcl_walls.register_wall(nodename, description, tiles, inventory_image,
|
||||||
on_construct = update_wall,
|
on_construct = update_wall,
|
||||||
sounds = sounds,
|
sounds = sounds,
|
||||||
})
|
})
|
||||||
|
if craft_material then
|
||||||
|
minetest.register_craft({
|
||||||
|
output = nodename .. " 6",
|
||||||
|
recipe = {
|
||||||
|
{craft_material, craft_material, craft_material},
|
||||||
|
{craft_material, craft_material, craft_material},
|
||||||
|
}
|
||||||
|
})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Cobblestone wall
|
-- Cobblestone wall
|
||||||
|
mcl_walls.register_wall("mcl_walls:cobble", "Cobblestone Wall", "mcl_core:cobble", {"default_cobble.png"}, "mcl_walls_cobble.png")
|
||||||
mcl_walls.register_wall("mcl_walls:cobble", "Cobblestone Wall", {"default_cobble.png"}, "mcl_walls_cobble.png")
|
|
||||||
minetest.register_craft({
|
|
||||||
output = 'mcl_walls:cobble 6',
|
|
||||||
recipe = {
|
|
||||||
{'mcl_core:cobble', 'mcl_core:cobble', 'mcl_core:cobble'},
|
|
||||||
{'mcl_core:cobble', 'mcl_core:cobble', 'mcl_core:cobble'}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
-- Mossy wall
|
-- Mossy wall
|
||||||
|
|
||||||
mcl_walls.register_wall("mcl_walls:mossycobble", "Mossy Cobblestone Wall", {"default_mossycobble.png"}, "mcl_walls_mossycobble.png")
|
mcl_walls.register_wall("mcl_walls:mossycobble", "Mossy Cobblestone Wall", "mcl_core:mossycobble", {"default_mossycobble.png"}, "mcl_walls_mossycobble.png")
|
||||||
minetest.register_craft({
|
|
||||||
output = 'mcl_walls:mossycobble 6',
|
|
||||||
recipe = {
|
|
||||||
{'mcl_core:mossycobble', 'mcl_core:mossycobble', 'mcl_core:mossycobble'},
|
|
||||||
{'mcl_core:mossycobble', 'mcl_core:mossycobble', 'mcl_core:mossycobble'}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_on_placenode(update_wall_global)
|
minetest.register_on_placenode(update_wall_global)
|
||||||
minetest.register_on_dignode(update_wall_global)
|
minetest.register_on_dignode(update_wall_global)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user