Merge pull request #1 from pithydon/master

add API
This commit is contained in:
Don 2016-10-04 11:13:45 -07:00 committed by GitHub
commit 83718005b4
3 changed files with 197 additions and 200 deletions

View File

@ -32,3 +32,15 @@ local material = {--{Name for description}, {image without .png}, {item name}, {
-- { "Dirt", "default_dirt","dirt","default"},
}
Newish API example:
```lua
mymillwork.register_all(
"default_stone",
"Stone",
"default_stone.png",
{cracky = 3,not_in_creative_inventory=1},
"default:stone"
)
```

View File

@ -266,27 +266,9 @@ then
local ingotstack = inv:get_stack("ingot", 1)
local resstack = inv:get_stack("res", 1)
--Register Items
local items = {
{"default:stone", "default_stone"},
{"default:stonebrick", "default_stone_brick"},
{"default:cobble", "default_cobble"},
{"default:desert_stone", "default_desert_stone"},
{"default:sandstone", "default_sandstone"},
{"default:clay", "default_clay"},
{"default:wood", "default_wood"},
{"default:junglewood", "default_junglewood"},
{"default:pine_wood", "default_pine_wood"},
{"default:pine_acacia", "default_acacia_wood"},
{"default:aspen_wood", "default_aspen_wood"},
{"default:coalblock", "default_coal_block"},
{"default:obsidian", "default_obsidian"}
}
for i in ipairs(items) do
local itm = items[i][1]
local mat = items[i][2]
for i in ipairs(mymillwork.registered) do
local itm = mymillwork.registered[i][1]
local mat = mymillwork.registered[i][2]
if ingotstack:get_name()== itm then
material = mat
make_ok = "1"

View File

@ -1,7 +1,8 @@
mymillwork.registered = {}
function mymillwork.register_all(mat, desc, image, group, itm)
minetest.register_node("mymillwork:crownmould_"..mat, {
minetest.register_node(":mymillwork:crownmould_"..mat, {
description = desc.." Crown Mould",
drawtype = "nodebox",
tiles = {image},
@ -35,7 +36,7 @@ minetest.register_node("mymillwork:crownmould_"..mat, {
on_place = minetest.rotate_node,
})
minetest.register_node("mymillwork:crownmould_ic_"..mat, {
minetest.register_node(":mymillwork:crownmould_ic_"..mat, {
description = desc.." Crown Mould IC",
drawtype = "nodebox",
tiles = {image},
@ -79,7 +80,7 @@ minetest.register_node("mymillwork:crownmould_ic_"..mat, {
on_place = minetest.rotate_node,
})
minetest.register_node("mymillwork:crownmould_oc_"..mat, {
minetest.register_node(":mymillwork:crownmould_oc_"..mat, {
description = desc.." Crown Mould OC",
drawtype = "nodebox",
tiles = {image},
@ -114,7 +115,7 @@ minetest.register_node("mymillwork:crownmould_oc_"..mat, {
on_place = minetest.rotate_node,
})
minetest.register_node("mymillwork:crownmould_beam_"..mat, {
minetest.register_node(":mymillwork:crownmould_beam_"..mat, {
description = desc.." Crown Mould with Beam",
drawtype = "nodebox",
tiles = {image},
@ -151,7 +152,7 @@ minetest.register_node("mymillwork:crownmould_beam_"..mat, {
on_place = minetest.rotate_node,
})
minetest.register_node("mymillwork:column_" ..mat, {
minetest.register_node(":mymillwork:column_" ..mat, {
description = desc.." Column",
drawtype = "nodebox",
tiles = {image},
@ -180,7 +181,7 @@ minetest.register_node("mymillwork:column_" ..mat, {
on_place = minetest.rotate_node,
})
minetest.register_node("mymillwork:column_base_"..mat, {
minetest.register_node(":mymillwork:column_base_"..mat, {
description = desc.." Column Base",
drawtype = "nodebox",
tiles = {image},
@ -210,7 +211,7 @@ minetest.register_node("mymillwork:column_base_"..mat, {
on_place = minetest.rotate_node,
})
minetest.register_node("mymillwork:column_half_"..mat, {
minetest.register_node(":mymillwork:column_half_"..mat, {
description = desc.." Half Column",
drawtype = "nodebox",
tiles = {image},
@ -239,7 +240,7 @@ minetest.register_node("mymillwork:column_half_"..mat, {
on_place = minetest.rotate_node,
})
minetest.register_node("mymillwork:column_half_base_"..mat, {
minetest.register_node(":mymillwork:column_half_base_"..mat, {
description = desc.." Half Column Base",
drawtype = "nodebox",
tiles = {image},
@ -269,7 +270,7 @@ minetest.register_node("mymillwork:column_half_base_"..mat, {
on_place = minetest.rotate_node,
})
minetest.register_node("mymillwork:column_half_wbeam_"..mat, {
minetest.register_node(":mymillwork:column_half_wbeam_"..mat, {
description = desc.." Half Column Base With Beam",
drawtype = "nodebox",
tiles = {image},
@ -307,7 +308,7 @@ minetest.register_node("mymillwork:column_half_wbeam_"..mat, {
on_place = minetest.rotate_node,
})
minetest.register_node("mymillwork:column_quarter_"..mat, {
minetest.register_node(":mymillwork:column_quarter_"..mat, {
description = desc.." Quarter Column",
drawtype = "nodebox",
tiles = {image},
@ -336,7 +337,7 @@ minetest.register_node("mymillwork:column_quarter_"..mat, {
on_place = minetest.rotate_node,
})
minetest.register_node("mymillwork:column_quarter_base_"..mat, {
minetest.register_node(":mymillwork:column_quarter_base_"..mat, {
description = desc.." Quarter Column Base",
drawtype = "nodebox",
tiles = {image},
@ -366,7 +367,7 @@ minetest.register_node("mymillwork:column_quarter_base_"..mat, {
on_place = minetest.rotate_node,
})
minetest.register_node("mymillwork:column_quarter_wbase_"..mat, {
minetest.register_node(":mymillwork:column_quarter_wbase_"..mat, {
description = desc.." Quarter Column Base Baseboard",
drawtype = "nodebox",
tiles = {image},
@ -398,7 +399,7 @@ minetest.register_node("mymillwork:column_quarter_wbase_"..mat, {
on_place = minetest.rotate_node,
})
minetest.register_node("mymillwork:column_quarter_fancybase_"..mat, {
minetest.register_node(":mymillwork:column_quarter_fancybase_"..mat, {
description = desc.." Quarter Column Base Fancy Baseboard",
drawtype = "nodebox",
tiles = {image},
@ -435,7 +436,7 @@ minetest.register_node("mymillwork:column_quarter_fancybase_"..mat, {
on_place = minetest.rotate_node,
})
minetest.register_node("mymillwork:ceiling_" ..mat, {
minetest.register_node(":mymillwork:ceiling_" ..mat, {
description = desc.." Ceiling",
drawtype = "nodebox",
tiles = {image},
@ -460,7 +461,7 @@ minetest.register_node("mymillwork:ceiling_" ..mat, {
on_place = minetest.rotate_node,
})
minetest.register_node("mymillwork:ceiling_post_"..mat, {
minetest.register_node(":mymillwork:ceiling_post_"..mat, {
description = desc.." Ceiling with Post",
drawtype = "nodebox",
tiles = {image},
@ -489,7 +490,7 @@ minetest.register_node("mymillwork:ceiling_post_"..mat, {
on_place = minetest.rotate_node,
})
minetest.register_node("mymillwork:beam_ceiling_"..mat, {
minetest.register_node(":mymillwork:beam_ceiling_"..mat, {
description = desc.." Ceiling with Beam",
drawtype = "nodebox",
tiles = {image},
@ -517,7 +518,7 @@ minetest.register_node("mymillwork:beam_ceiling_"..mat, {
on_place = minetest.rotate_node,
})
minetest.register_node("mymillwork:beam_ceiling_t_"..mat, {
minetest.register_node(":mymillwork:beam_ceiling_t_"..mat, {
description = desc.." Ceiling with Beam T",
drawtype = "nodebox",
tiles = {image},
@ -549,7 +550,7 @@ minetest.register_node("mymillwork:beam_ceiling_t_"..mat, {
on_place = minetest.rotate_node,
})
minetest.register_node("mymillwork:beam_" ..mat, {
minetest.register_node(":mymillwork:beam_" ..mat, {
description = desc.." Beam",
drawtype = "nodebox",
tiles = {image},
@ -576,7 +577,7 @@ minetest.register_node("mymillwork:beam_" ..mat, {
on_place = minetest.rotate_node,
})
minetest.register_node("mymillwork:beam_t_"..mat, {
minetest.register_node(":mymillwork:beam_t_"..mat, {
description = desc.." Beam T",
drawtype = "nodebox",
tiles = {image},
@ -607,7 +608,7 @@ minetest.register_node("mymillwork:beam_t_"..mat, {
on_place = minetest.rotate_node,
})
minetest.register_node("mymillwork:base_" ..mat, {
minetest.register_node(":mymillwork:base_" ..mat, {
description = desc.." Baseboard",
drawtype = "nodebox",
tiles = {image},
@ -632,7 +633,7 @@ minetest.register_node("mymillwork:base_" ..mat, {
on_place = minetest.rotate_node,
})
minetest.register_node("mymillwork:base_ic_"..mat, {
minetest.register_node(":mymillwork:base_ic_"..mat, {
description = desc.." Baseboard IC",
drawtype = "nodebox",
tiles = {image},
@ -659,7 +660,7 @@ minetest.register_node("mymillwork:base_ic_"..mat, {
on_place = minetest.rotate_node,
})
minetest.register_node("mymillwork:base_oc_"..mat, {
minetest.register_node(":mymillwork:base_oc_"..mat, {
description = desc.." Baseboard OC",
drawtype = "nodebox",
tiles = {image},
@ -684,7 +685,7 @@ minetest.register_node("mymillwork:base_oc_"..mat, {
on_place = minetest.rotate_node,
})
minetest.register_node("mymillwork:base_fancy_"..mat, {
minetest.register_node(":mymillwork:base_fancy_"..mat, {
description = desc.." Fancy Baseboard",
drawtype = "nodebox",
tiles = {image},
@ -712,7 +713,7 @@ minetest.register_node("mymillwork:base_fancy_"..mat, {
on_place = minetest.rotate_node,
})
minetest.register_node("mymillwork:base_fancy_ic_"..mat, {
minetest.register_node(":mymillwork:base_fancy_ic_"..mat, {
description = desc.." Fancy Baseboard IC",
drawtype = "nodebox",
tiles = {image},
@ -745,7 +746,7 @@ minetest.register_node("mymillwork:base_fancy_ic_"..mat, {
on_place = minetest.rotate_node,
})
minetest.register_node("mymillwork:base_fancy_oc_"..mat, {
minetest.register_node(":mymillwork:base_fancy_oc_"..mat, {
description = desc.." Fancy Baseboard OC",
drawtype = "nodebox",
tiles = {image},
@ -773,4 +774,6 @@ minetest.register_node("mymillwork:base_fancy_oc_"..mat, {
on_place = minetest.rotate_node,
})
table.insert(mymillwork.registered, {itm, mat})
end