Skip to content

Commit

Permalink
Centralize craft item names
Browse files Browse the repository at this point in the history
  • Loading branch information
random-geek committed Sep 18, 2020
1 parent 544e93f commit ca10fb0
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 96 deletions.
36 changes: 29 additions & 7 deletions morelights/init.lua
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
morelights = {}

if minetest.get_modpath("xpanes") then
morelights.glass = "xpanes:pane_flat"
else
morelights.glass = "default:glass"
end

function morelights.register_variants(variants, fixedDef)
for _, variant in ipairs(variants) do
local name = variant.name
Expand Down Expand Up @@ -50,6 +44,34 @@ function morelights.rotate_and_place(itemstack, placer, pointed_thing, lookup)
return itemstack
end


morelights.craft_items = {
glass = "default:glass",
glass_pane = "default:glass",
steel = "default:steel_ingot",
copper = "default:copper_ingot",
mese_fragment = "default:mese_crystal_fragment",
dye_dark = "dye:dark_grey",
dye_light = "dye:white",
wool_dark = "wool:dark_grey",
wool_light = "wool:white",
wood_dark = "default:junglewood",
cotton = "farming:cotton",
dirt = "default:dirt",
stone_block = "default:stone_block",
sandstone_block = "default:sandstone_block",
grass = "default:grass_1",
}

if minetest.get_modpath("xpanes") then
morelights.craft_items.glass_pane = "xpanes:pane_flat"
end

-- Use basic_materials brass if available, otherwise register our own.
if minetest.get_modpath("basic_materials") then
morelights.craft_items.brass = "basic_materials:brass_ingot"
end

local path = minetest.get_modpath("morelights")

dofile(path .. "/nodes.lua")
dofile(path .. DIR_DELIM .. "nodes.lua")
28 changes: 15 additions & 13 deletions morelights/nodes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -132,47 +132,49 @@ morelights.register_variants({
-- Craft recipes
--

local a = morelights.craft_items

minetest.register_craft({
output = "morelights:bulb",
recipe = {
{"", "default:glass", ""},
{"", "default:copper_ingot", ""},
{"", "default:steel_ingot", ""}
{"", a.glass, ""},
{"", a.copper, ""},
{"", a.steel, ""}
}
})

minetest.register_craft({
output = "morelights:pole_d 2",
recipe = {
{"dye:dark_grey", "default:steel_ingot", ""},
{"", "default:steel_ingot", ""},
{"", "default:steel_ingot", ""}
{a.dye_dark, a.steel, ""},
{"", a.steel, ""},
{"", a.steel, ""}
}
})

minetest.register_craft({
output = "morelights:pole_l 2",
recipe = {
{"dye:white", "default:steel_ingot", ""},
{"", "default:steel_ingot", ""},
{"", "default:steel_ingot", ""}
{a.dye_light, a.steel, ""},
{"", a.steel, ""},
{"", a.steel, ""}
}
})

minetest.register_craft({
output = "morelights:chain_d",
recipe = {
{"dye:dark_grey", "default:steel_ingot", ""},
{a.dye_dark, a.steel, ""},
{"", "", ""},
{"", "default:steel_ingot", ""}
{"", a.steel, ""}
}
})

minetest.register_craft({
output = "morelights:chain_l",
recipe = {
{"dye:white", "default:steel_ingot", ""},
{a.dye_light, a.steel, ""},
{"", "", ""},
{"", "default:steel_ingot", ""}
{"", a.steel, ""}
}
})
22 changes: 12 additions & 10 deletions morelights_extras/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -80,45 +80,47 @@ minetest.register_node("morelights_extras:stairlight", {
-- Craft recipes
--

local a = morelights.craft_items

minetest.register_craft({
output = "morelights_extras:f_block",
recipe = {
{"default:mese_crystal_fragment", "default:steel_ingot", "default:mese_crystal_fragment"},
{morelights.glass, "morelights:bulb", morelights.glass},
{"default:mese_crystal_fragment", "default:steel_ingot", "default:mese_crystal_fragment"}
{a.mese_fragment, a.steel, a.mese_fragment},
{a.glass_pane, "morelights:bulb", a.glass_pane},
{a.mese_fragment, a.steel, a.mese_fragment}
}
})

minetest.register_craft({
output = "morelights_extras:dirt_with_grass",
recipe = {
{"", morelights.glass, ""},
{"", a.glass_pane, ""},
{"", "morelights:bulb", ""},
{"default:grass_1", "default:dirt", ""}
{a.grass, a.dirt, ""}
}
})

minetest.register_craft({
output = "morelights_extras:stone_block",
recipe = {
{"", morelights.glass, ""},
{"", a.glass_pane, ""},
{"", "morelights:bulb", ""},
{"", "default:stone_block", ""}
{"", a.stone_block, ""}
}
})

minetest.register_craft({
output = "morelights_extras:sandstone_block",
recipe = {
{"", morelights.glass, ""},
{"", a.glass_pane, ""},
{"", "morelights:bulb", ""},
{"", "default:sandstone_block", ""}
{"", a.sandstone_block, ""}
}
})

minetest.register_craft({
output = "morelights_extras:stairlight",
recipe = {
{"default:steel_ingot", "morelights:bulb", "default:steel_ingot"}
{a.steel, "morelights:bulb", a.steel}
}
})
78 changes: 40 additions & 38 deletions morelights_modern/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -237,64 +237,66 @@ morelights.register_variants({
-- Craft recipes
--

local a = morelights.craft_items

minetest.register_craft({
output = "morelights_modern:block",
recipe = {
{"", "default:steel_ingot", ""},
{morelights.glass, "morelights:bulb", morelights.glass},
{"", "default:steel_ingot", ""}
{"", a.steel, ""},
{a.glass_pane, "morelights:bulb", a.glass_pane},
{"", a.steel, ""}
}
})

minetest.register_craft({
output = "morelights_modern:smallblock",
recipe = {
{"", morelights.glass, ""},
{"default:steel_ingot", "morelights:bulb", "default:steel_ingot"}
{"", a.glass_pane, ""},
{a.steel, "morelights:bulb", a.steel}
}
})

minetest.register_craft({
output = "morelights_modern:post_d",
recipe = {
{"dye:dark_grey", "default:steel_ingot", ""},
{a.dye_dark, a.steel, ""},
{"", "morelights:bulb", ""},
{"", "default:steel_ingot", ""}
{"", a.steel, ""}
}
})

minetest.register_craft({
output = "morelights_modern:post_l",
recipe = {
{"dye:white", "default:steel_ingot", ""},
{a.dye_light, a.steel, ""},
{"", "morelights:bulb", ""},
{"", "default:steel_ingot", ""}
{"", a.steel, ""}
}
})

minetest.register_craft({
output = "morelights_modern:streetpost_d 2",
recipe = {
{"dye:dark_grey", "default:steel_ingot", "default:steel_ingot"},
{"", "default:steel_ingot", ""},
{"", "default:steel_ingot", ""}
{a.dye_dark, a.steel, a.steel},
{"", a.steel, ""},
{"", a.steel, ""}
}
})

minetest.register_craft({
output = "morelights_modern:streetpost_l 2",
recipe = {
{"dye:white", "default:steel_ingot", "default:steel_ingot"},
{"", "default:steel_ingot", ""},
{"", "default:steel_ingot", ""}
{a.dye_light, a.steel, a.steel},
{"", a.steel, ""},
{"", a.steel, ""}
}
})

minetest.register_craft({
output = "morelights_modern:barlight_c 4",
recipe = {
{"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"},
{"default:copper_ingot", "default:glass", "default:copper_ingot"}
{a.steel, a.steel, a.steel},
{a.copper, a.glass, a.copper}
}
})

Expand All @@ -313,68 +315,68 @@ minetest.register_craft({
minetest.register_craft({
output = "morelights_modern:ceilinglight",
recipe = {
{"default:steel_ingot", "morelights:bulb", "default:steel_ingot"},
{"", morelights.glass, ""},
{a.steel, "morelights:bulb", a.steel},
{"", a.glass_pane, ""},
}
})

minetest.register_craft({
output = "morelights_modern:canlight_d",
recipe = {
{"dye:dark_grey", "default:steel_ingot", ""},
{"default:steel_ingot", "morelights:bulb", "default:steel_ingot"},
{a.dye_dark, a.steel, ""},
{a.steel, "morelights:bulb", a.steel},
}
})

minetest.register_craft({
output = "morelights_modern:canlight_l",
recipe = {
{"dye:white", "default:steel_ingot", ""},
{"default:steel_ingot", "morelights:bulb", "default:steel_ingot"},
{a.dye_light, a.steel, ""},
{a.steel, "morelights:bulb", a.steel},
}
})

minetest.register_craft({
output = "morelights_modern:walllamp",
recipe = {
{"dye:white", morelights.glass, ""},
{morelights.glass, "morelights:bulb", "default:steel_ingot"},
{"", "dye:dark_grey", "default:steel_ingot"}
{a.dye_light, a.glass_pane, ""},
{a.glass_pane, "morelights:bulb", a.steel},
{"", a.dye_dark, a.steel}
}
})

minetest.register_craft({
output = "morelights_modern:tablelamp_d",
recipe = {
{"wool:dark_grey", "morelights:bulb", "wool:dark_grey"},
{"", "default:steel_ingot", ""},
{"", "default:steel_ingot", ""}
{a.wool_dark, "morelights:bulb", a.wool_dark},
{"", a.steel, ""},
{"", a.steel, ""}
}
})

minetest.register_craft({
output = "morelights_modern:tablelamp_l",
recipe = {
{"wool:white", "morelights:bulb", "wool:white"},
{"", "default:steel_ingot", ""},
{"", "default:steel_ingot", ""}
{a.wool_light, "morelights:bulb", a.wool_light},
{"", a.steel, ""},
{"", a.steel, ""}
}
})

minetest.register_craft({
output = "morelights_modern:pathlight_d",
recipe = {
{"dye:dark_grey", "morelights:bulb", ""},
{"", "default:steel_ingot", ""},
{"", "default:steel_ingot", ""}
{a.dye_dark, "morelights:bulb", ""},
{"", a.steel, ""},
{"", a.steel, ""}
}
})

minetest.register_craft({
output = "morelights_modern:pathlight_l",
recipe = {
{"dye:white", "morelights:bulb", ""},
{"", "default:steel_ingot", ""},
{"", "default:steel_ingot", ""}
{a.dye_light, "morelights:bulb", ""},
{"", a.steel, ""},
{"", a.steel, ""}
}
})
Loading

0 comments on commit ca10fb0

Please sign in to comment.