Add gears
This commit is contained in:
parent
2c54a8be3b
commit
d1b81c55d2
@ -93,6 +93,17 @@ minetest.register_craft({
|
||||
-- Items --
|
||||
-----------
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "elepower_dynamics:particle_board",
|
||||
recipe = {
|
||||
"elepower_dynamics:wood_dust",
|
||||
"elepower_dynamics:wood_dust",
|
||||
"elepower_dynamics:wood_dust",
|
||||
"elepower_dynamics:wood_dust",
|
||||
}
|
||||
})
|
||||
|
||||
--------------
|
||||
-- Smelting --
|
||||
--------------
|
||||
@ -108,3 +119,34 @@ minetest.register_craft({
|
||||
output = "elepower_dynamics:lead_lump",
|
||||
recipe = "elepower_dynamics:lead_ingot"
|
||||
})
|
||||
|
||||
-----------
|
||||
-- Gears --
|
||||
-----------
|
||||
|
||||
local keywords = { "_ingot", "" }
|
||||
for mat, data in pairs(elepd.registered_gears) do
|
||||
for _,keyword in ipairs(keywords) do
|
||||
local found = ele.helpers.scan_item_list(mat .. keyword)
|
||||
local immebreak = false
|
||||
|
||||
if mat == "wood" then
|
||||
found = "group:stick"
|
||||
immebreak = true
|
||||
end
|
||||
|
||||
if found then
|
||||
-- Gear recipe for material
|
||||
minetest.register_craft({
|
||||
recipe = {
|
||||
{ "", found, "" },
|
||||
{ found, "", found},
|
||||
{ "", found, "" }
|
||||
},
|
||||
output = data.item
|
||||
})
|
||||
|
||||
if immebreak then break end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -12,10 +12,19 @@ function elepd.register_dust(mat, data)
|
||||
data.item = itemname
|
||||
elepd.registered_dusts[mat] = data
|
||||
|
||||
-- Make descriptions overridable
|
||||
local description = "Pulverized " .. data.description
|
||||
if data.force_description then
|
||||
description = data.description
|
||||
end
|
||||
|
||||
minetest.register_craftitem(itemname, {
|
||||
description = "Pulverized " .. data.description,
|
||||
description = description,
|
||||
inventory_image = "elepower_dust.png^[multiply:" .. data.color,
|
||||
groups = {["dust_" .. mat] = 1, dust = 1}
|
||||
groups = {
|
||||
["dust_" .. mat] = 1,
|
||||
dust = 1
|
||||
}
|
||||
})
|
||||
end
|
||||
|
||||
@ -80,3 +89,9 @@ elepd.register_dust("energium", {
|
||||
description = "Energium",
|
||||
color = "#ff1111"
|
||||
})
|
||||
|
||||
elepd.register_dust("wood", {
|
||||
description = "Wood Shavings",
|
||||
force_description = true,
|
||||
color = "#847454"
|
||||
})
|
||||
|
87
elepower_dynamics/gears.lua
Normal file
87
elepower_dynamics/gears.lua
Normal file
@ -0,0 +1,87 @@
|
||||
|
||||
----------------------
|
||||
-- Ground materials --
|
||||
----------------------
|
||||
|
||||
elepd.registered_gears = {}
|
||||
|
||||
function elepd.register_gear(mat, data)
|
||||
local mod = minetest.get_current_modname()
|
||||
local itemname = mod..":"..mat.."_gear"
|
||||
|
||||
data.item = itemname
|
||||
elepd.registered_gears[mat] = data
|
||||
|
||||
local description = data.description .. " Gear"
|
||||
|
||||
minetest.register_craftitem(itemname, {
|
||||
description = description,
|
||||
inventory_image = "elepower_gear.png^[multiply:" .. data.color,
|
||||
groups = {
|
||||
["gear_" .. mat] = 1,
|
||||
dust = 1
|
||||
}
|
||||
})
|
||||
end
|
||||
|
||||
-- Default dust list
|
||||
|
||||
elepd.register_gear("bronze", {
|
||||
description = "Bronze",
|
||||
color = "#fa7b26"
|
||||
})
|
||||
|
||||
elepd.register_gear("copper", {
|
||||
description = "Copper",
|
||||
color = "#fcb15f"
|
||||
})
|
||||
|
||||
elepd.register_gear("gold", {
|
||||
description = "Gold",
|
||||
color = "#ffff47"
|
||||
})
|
||||
|
||||
elepd.register_gear("steel", {
|
||||
description = "Steel",
|
||||
color = "#ffffff"
|
||||
})
|
||||
|
||||
elepd.register_gear("tin", {
|
||||
description = "Tin",
|
||||
color = "#c1c1c1"
|
||||
})
|
||||
|
||||
elepd.register_gear("mithril", {
|
||||
description = "Mithril",
|
||||
color = "#8686df"
|
||||
})
|
||||
|
||||
elepd.register_gear("silver", {
|
||||
description = "Silver",
|
||||
color = "#d7e2e8"
|
||||
})
|
||||
|
||||
elepd.register_gear("lead", {
|
||||
description = "Lead",
|
||||
color = "#aeaedc"
|
||||
})
|
||||
|
||||
elepd.register_gear("iron", {
|
||||
description = "Iron",
|
||||
color = "#dddddd"
|
||||
})
|
||||
|
||||
elepd.register_gear("diamond", {
|
||||
description = "Diamond",
|
||||
color = "#02c1e8"
|
||||
})
|
||||
|
||||
elepd.register_gear("energium", {
|
||||
description = "Energium",
|
||||
color = "#ff1111"
|
||||
})
|
||||
|
||||
elepd.register_gear("wood", {
|
||||
description = "Wood",
|
||||
color = "#847454"
|
||||
})
|
@ -11,5 +11,6 @@ dofile(modpath.."/craftitems.lua")
|
||||
dofile(modpath.."/tools.lua")
|
||||
dofile(modpath.."/nodes.lua")
|
||||
dofile(modpath.."/dusts.lua")
|
||||
dofile(modpath.."/gears.lua")
|
||||
dofile(modpath.."/worldgen.lua")
|
||||
dofile(modpath.."/crafting.lua")
|
||||
|
@ -14,3 +14,11 @@ minetest.register_node("elepower_dynamics:stone_with_lead", {
|
||||
drop = 'elepower_dynamics:lead_lump',
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_node("elepower_dynamics:particle_board", {
|
||||
description = "Particle Board",
|
||||
tiles = {"elepower_particle_board.png"},
|
||||
groups = {choppy = 2, wood = 1},
|
||||
drop = 'elepower_dynamics:wood_dust 4',
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
})
|
||||
|
BIN
elepower_dynamics/textures/elepower_gear.png
Normal file
BIN
elepower_dynamics/textures/elepower_gear.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 348 B |
BIN
elepower_dynamics/textures/elepower_particle_board.png
Normal file
BIN
elepower_dynamics/textures/elepower_particle_board.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 411 B |
@ -17,6 +17,11 @@ function elepm.register_craft(craftdef)
|
||||
return nil
|
||||
end
|
||||
|
||||
if craftdef.type == "cooking" then
|
||||
minetest.register_craft(craftdef)
|
||||
return
|
||||
end
|
||||
|
||||
local inputs = craftdef.recipe
|
||||
local outputs = craftdef.output
|
||||
local ctype = craftdef.type
|
||||
@ -32,10 +37,10 @@ function elepm.register_craft(craftdef)
|
||||
|
||||
local craftresult = {}
|
||||
if type(outputs) == "table" then
|
||||
for _,output in ipairs(output) do
|
||||
for _,output in ipairs(outputs) do
|
||||
local stack = ItemStack(output)
|
||||
if stack and not stack:is_empty() then
|
||||
craftresult[stack:get_name()] = stack:get_count()
|
||||
craftresult[#craftresult + 1] = stack:to_string()
|
||||
end
|
||||
end
|
||||
else
|
||||
|
@ -41,26 +41,11 @@ elepm.register_craft_type("grind", {
|
||||
inputs = 1,
|
||||
})
|
||||
|
||||
-- Look for item name regardless of mod
|
||||
local function scan_item_list(item_name)
|
||||
local found = nil
|
||||
|
||||
for name in pairs(minetest.registered_items) do
|
||||
local nomod = name:gsub("(%w+):", "")
|
||||
if nomod == item_name then
|
||||
found = name
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
return found
|
||||
end
|
||||
|
||||
local keywords = { _ingot = 1, _lump = 2, _block = 9, block = 9 }
|
||||
for mat, data in pairs(elepd.registered_dusts) do
|
||||
local kwfound = nil
|
||||
for keyword,count in pairs(keywords) do
|
||||
local found = scan_item_list(mat .. keyword)
|
||||
local found = ele.helpers.scan_item_list(mat .. keyword)
|
||||
if found then
|
||||
if keyword == "_ingot" and not kwfound then
|
||||
kwfound = found
|
||||
@ -161,7 +146,7 @@ minetest.after(0.2, function ()
|
||||
elepm.register_craft({
|
||||
type = "saw",
|
||||
recipe = { tree },
|
||||
output = wood .. " 6",
|
||||
output = {wood .. " 6", "elepower_dynamics:wood_dust"},
|
||||
time = 8,
|
||||
})
|
||||
end
|
||||
|
@ -72,3 +72,18 @@ function ele.helpers.get_node_property(meta, pos, prop)
|
||||
|
||||
return value
|
||||
end
|
||||
|
||||
-- Look for item name regardless of mod
|
||||
function ele.helpers.scan_item_list(item_name)
|
||||
local found = nil
|
||||
|
||||
for name in pairs(minetest.registered_items) do
|
||||
local nomod = name:gsub("([%w_]+):", "")
|
||||
if nomod == item_name then
|
||||
found = name
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
return found
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user