Collect plate, dust and gear registration into single file
This commit is contained in:
parent
04a58a6a14
commit
d19178d8d4
141
elepower_dynamics/components.lua
Normal file
141
elepower_dynamics/components.lua
Normal file
@ -0,0 +1,141 @@
|
|||||||
|
|
||||||
|
local list_def = {
|
||||||
|
{material = "bronze", description = "Bronze", color = "#fa7b26", dust = true, plate = true, gear = true},
|
||||||
|
{material = "copper", description = "Copper", color = "#fcb15f", dust = true, plate = true, gear = true},
|
||||||
|
{material = "gold", description = "Gold", color = "#ffff47", dust = true, plate = true, gear = true},
|
||||||
|
{material = "steel", description = "Steel", color = "#ffffff", dust = true, plate = true, gear = true},
|
||||||
|
{material = "tin", description = "Tin", color = "#c1c1c1", dust = true, plate = true, gear = true},
|
||||||
|
{material = "mithril", description = "Mithril", color = "#8686df", dust = true, plate = true, gear = true},
|
||||||
|
{material = "silver", description = "Silver", color = "#d7e2e8", dust = true, plate = true, gear = true},
|
||||||
|
{material = "lead", description = "Lead", color = "#aeaedc", dust = true, plate = true, gear = true},
|
||||||
|
{material = "iron", description = "Iron", color = "#dddddd", dust = true, plate = true, gear = true},
|
||||||
|
{material = "diamond", description = "Diamond", color = "#02c1e8", dust = true, plate = true, gear = true},
|
||||||
|
{material = "nickel", description = "Nickel", color = "#d6d5ab", dust = true, plate = true, gear = true},
|
||||||
|
{material = "invar", description = "Invar", color = "#9fa5b2", dust = true, plate = true, gear = true},
|
||||||
|
{material = "electrum", description = "Electrum", color = "#ebeb90", dust = true, plate = true, gear = true},
|
||||||
|
{material = "viridisium", description = "Viridisium", color = "#5b9751", dust = true, plate = true, gear = true},
|
||||||
|
{material = "zinc", description = "Zinc", color = "#598a9e", dust = true, plate = true},
|
||||||
|
{material = "wood", description = "Wood", color = "#847454", dust = "Sawdust", gear = true}
|
||||||
|
}
|
||||||
|
|
||||||
|
elepd.registered_gears = {}
|
||||||
|
elepd.registered_dusts = {}
|
||||||
|
elepd.registered_plates = {}
|
||||||
|
|
||||||
|
function elepd.register_plate(mat, data)
|
||||||
|
local mod = minetest.get_current_modname()
|
||||||
|
local itemname = mod..":"..mat.."_plate"
|
||||||
|
|
||||||
|
data.item = itemname
|
||||||
|
elepd.registered_plates[mat] = data
|
||||||
|
|
||||||
|
-- Make descriptions overridable
|
||||||
|
local description = data.description .. " Plate"
|
||||||
|
if data.force_description then
|
||||||
|
description = data.description
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.register_craftitem(itemname, {
|
||||||
|
description = description,
|
||||||
|
inventory_image = "elepower_plate.png^[multiply:" .. data.color,
|
||||||
|
groups = {
|
||||||
|
["plate_" .. mat] = 1,
|
||||||
|
plate = 1
|
||||||
|
}
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
function elepd.register_dust(mat, data)
|
||||||
|
local mod = minetest.get_current_modname()
|
||||||
|
local itemname = mod..":"..mat.."_dust"
|
||||||
|
|
||||||
|
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 = description,
|
||||||
|
inventory_image = "elepower_dust.png^[multiply:" .. data.color,
|
||||||
|
groups = {
|
||||||
|
["dust_" .. mat] = 1,
|
||||||
|
dust = 1
|
||||||
|
}
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
-- Make descriptions overridable
|
||||||
|
local description = data.description .. " Gear"
|
||||||
|
if data.force_description then
|
||||||
|
description = data.description
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.register_craftitem(itemname, {
|
||||||
|
description = description,
|
||||||
|
inventory_image = "elepower_gear.png^[multiply:" .. data.color,
|
||||||
|
groups = {
|
||||||
|
["gear_" .. mat] = 1,
|
||||||
|
gear = 1
|
||||||
|
}
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
------------------
|
||||||
|
-- Register all --
|
||||||
|
------------------
|
||||||
|
|
||||||
|
for _,spec in pairs(list_def) do
|
||||||
|
local desc = spec.description
|
||||||
|
local name = spec.material
|
||||||
|
local color = spec.color
|
||||||
|
|
||||||
|
if spec.dust ~= nil and spec.dust ~= false then
|
||||||
|
local fdesc = nil
|
||||||
|
if spec.dust ~= true then
|
||||||
|
fdesc = spec.dust
|
||||||
|
end
|
||||||
|
|
||||||
|
elepd.register_dust(name, {
|
||||||
|
description = fdesc or desc,
|
||||||
|
color = color,
|
||||||
|
force_description = fdesc ~= nil,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
if spec.gear ~= nil and spec.gear ~= false then
|
||||||
|
local fdesc = nil
|
||||||
|
if spec.gear ~= true then
|
||||||
|
fdesc = spec.gear
|
||||||
|
end
|
||||||
|
|
||||||
|
elepd.register_gear(name, {
|
||||||
|
description = fdesc or desc,
|
||||||
|
color = color,
|
||||||
|
force_description = fdesc ~= nil,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
if spec.plate ~= nil and spec.plate ~= false then
|
||||||
|
local fdesc = nil
|
||||||
|
if spec.plate ~= true then
|
||||||
|
fdesc = spec.plate
|
||||||
|
end
|
||||||
|
|
||||||
|
elepd.register_plate(name, {
|
||||||
|
description = fdesc or desc,
|
||||||
|
color = color,
|
||||||
|
force_description = fdesc ~= nil,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
@ -1,58 +0,0 @@
|
|||||||
|
|
||||||
----------------------
|
|
||||||
-- Ground materials --
|
|
||||||
----------------------
|
|
||||||
|
|
||||||
elepd.registered_dusts = {}
|
|
||||||
|
|
||||||
function elepd.register_dust(mat, data)
|
|
||||||
local mod = minetest.get_current_modname()
|
|
||||||
local itemname = mod..":"..mat.."_dust"
|
|
||||||
|
|
||||||
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 = description,
|
|
||||||
inventory_image = "elepower_dust.png^[multiply:" .. data.color,
|
|
||||||
groups = {
|
|
||||||
["dust_" .. mat] = 1,
|
|
||||||
dust = 1
|
|
||||||
}
|
|
||||||
})
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Default dust list
|
|
||||||
local dusts = {
|
|
||||||
{"bronze", "Bronze", "#fa7b26"},
|
|
||||||
{"copper", "Copper", "#fcb15f"},
|
|
||||||
{"gold", "Gold", "#ffff47"},
|
|
||||||
{"steel", "Steel", "#ffffff"},
|
|
||||||
{"tin", "Tin", "#c1c1c1"},
|
|
||||||
{"mithril", "Mithril", "#8686df"},
|
|
||||||
{"silver", "Silver", "#d7e2e8"},
|
|
||||||
{"lead", "Lead", "#aeaedc"},
|
|
||||||
{"iron", "Iron", "#dddddd"},
|
|
||||||
{"coal", "Coal", "#222222"},
|
|
||||||
{"diamond", "Diamond", "#02c1e8"},
|
|
||||||
{"nickel", "Nickel", "#d6d5ab"},
|
|
||||||
{"invar", "Invar", "#9fa5b2"},
|
|
||||||
{"electrum", "Electrum", "#ebeb90"},
|
|
||||||
{"viridisium", "Viridisium", "#5b9751"},
|
|
||||||
{"zinc", "Zinc", "#598a9e"},
|
|
||||||
{"wood", "Sawdust", "#847454", true}
|
|
||||||
}
|
|
||||||
|
|
||||||
for _,dust in ipairs(dusts) do
|
|
||||||
elepd.register_dust(dust[1], {
|
|
||||||
description = dust[2],
|
|
||||||
color = dust[3],
|
|
||||||
force_description = dust[4],
|
|
||||||
})
|
|
||||||
end
|
|
@ -1,51 +0,0 @@
|
|||||||
|
|
||||||
-----------
|
|
||||||
-- Gears --
|
|
||||||
-----------
|
|
||||||
|
|
||||||
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,
|
|
||||||
gear = 1
|
|
||||||
}
|
|
||||||
})
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Default gear list
|
|
||||||
local gears = {
|
|
||||||
{"bronze", "Bronze", "#fa7b26"},
|
|
||||||
{"copper", "Copper", "#fcb15f"},
|
|
||||||
{"gold", "Gold", "#ffff47"},
|
|
||||||
{"steel", "Steel", "#ffffff"},
|
|
||||||
{"tin", "Tin", "#c1c1c1"},
|
|
||||||
{"mithril", "Mithril", "#8686df"},
|
|
||||||
{"silver", "Silver", "#d7e2e8"},
|
|
||||||
{"lead", "Lead", "#aeaedc"},
|
|
||||||
{"iron", "Iron", "#dddddd"},
|
|
||||||
{"coal", "Coal", "#222222"},
|
|
||||||
{"diamond", "Diamond", "#02c1e8"},
|
|
||||||
{"nickel", "Nickel", "#d6d5ab"},
|
|
||||||
{"invar", "Invar", "#9fa5b2"},
|
|
||||||
{"electrum", "Electrum", "#ebeb90"},
|
|
||||||
{"viridisium", "Viridisium", "#5b9751"},
|
|
||||||
}
|
|
||||||
|
|
||||||
for _,gear in ipairs(gears) do
|
|
||||||
elepd.register_gear(gear[1], {
|
|
||||||
description = gear[2],
|
|
||||||
color = gear[3]
|
|
||||||
})
|
|
||||||
end
|
|
@ -13,8 +13,6 @@ dofile(modpath.."/tools.lua")
|
|||||||
dofile(modpath.."/nodes.lua")
|
dofile(modpath.."/nodes.lua")
|
||||||
dofile(modpath.."/liquids.lua")
|
dofile(modpath.."/liquids.lua")
|
||||||
dofile(modpath.."/tanks.lua")
|
dofile(modpath.."/tanks.lua")
|
||||||
dofile(modpath.."/dusts.lua")
|
dofile(modpath.."/components.lua")
|
||||||
dofile(modpath.."/plates.lua")
|
|
||||||
dofile(modpath.."/gears.lua")
|
|
||||||
dofile(modpath.."/worldgen.lua")
|
dofile(modpath.."/worldgen.lua")
|
||||||
dofile(modpath.."/crafting.lua")
|
dofile(modpath.."/crafting.lua")
|
||||||
|
@ -1,56 +0,0 @@
|
|||||||
|
|
||||||
------------
|
|
||||||
-- Plates --
|
|
||||||
------------
|
|
||||||
|
|
||||||
elepd.registered_plates = {}
|
|
||||||
|
|
||||||
function elepd.register_plate(mat, data)
|
|
||||||
local mod = minetest.get_current_modname()
|
|
||||||
local itemname = mod..":"..mat.."_plate"
|
|
||||||
|
|
||||||
data.item = itemname
|
|
||||||
elepd.registered_plates[mat] = data
|
|
||||||
|
|
||||||
-- Make descriptions overridable
|
|
||||||
local description = data.description .. " Plate"
|
|
||||||
if data.force_description then
|
|
||||||
description = data.description
|
|
||||||
end
|
|
||||||
|
|
||||||
minetest.register_craftitem(itemname, {
|
|
||||||
description = description,
|
|
||||||
inventory_image = "elepower_plate.png^[multiply:" .. data.color,
|
|
||||||
groups = {
|
|
||||||
["plate_" .. mat] = 1,
|
|
||||||
plate = 1
|
|
||||||
}
|
|
||||||
})
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Default plate list
|
|
||||||
local plates = {
|
|
||||||
{"bronze", "Bronze", "#fa7b26"},
|
|
||||||
{"copper", "Copper", "#fcb15f"},
|
|
||||||
{"gold", "Gold", "#ffff47"},
|
|
||||||
{"steel", "Steel", "#ffffff"},
|
|
||||||
{"tin", "Tin", "#c1c1c1"},
|
|
||||||
{"mithril", "Mithril", "#8686df"},
|
|
||||||
{"silver", "Silver", "#d7e2e8"},
|
|
||||||
{"lead", "Lead", "#aeaedc"},
|
|
||||||
{"iron", "Iron", "#dddddd"},
|
|
||||||
{"diamond", "Diamond", "#02c1e8"},
|
|
||||||
{"nickel", "Nickel", "#d6d5ab"},
|
|
||||||
{"invar", "Invar", "#9fa5b2"},
|
|
||||||
{"electrum", "Electrum", "#ebeb90"},
|
|
||||||
{"viridisium", "Viridisium", "#5b9751"},
|
|
||||||
{"zinc", "Zinc", "#598a9e"},
|
|
||||||
}
|
|
||||||
|
|
||||||
for _,plate in ipairs(plates) do
|
|
||||||
elepd.register_plate(plate[1], {
|
|
||||||
description = plate[2],
|
|
||||||
color = plate[3],
|
|
||||||
force_description = plate[4],
|
|
||||||
})
|
|
||||||
end
|
|
Loading…
Reference in New Issue
Block a user