small api change
This commit is contained in:
parent
2dd09f2b04
commit
b1340e953e
@ -99,10 +99,16 @@ local function register_florbfluid(data)
|
|||||||
local fluid = fluidity.fluid_name(source_node.description)
|
local fluid = fluidity.fluid_name(source_node.description)
|
||||||
local internal = fluidity.fluid_short(fluid)
|
local internal = fluidity.fluid_short(fluid)
|
||||||
|
|
||||||
|
local itemname = data.mod_name..":"..data.florb_name.."_"..internal
|
||||||
|
|
||||||
|
if minetest.registered_items[itemname] then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
local stationary_name = source_node.tiles[1].name:gsub("_source_animated", "")
|
local stationary_name = source_node.tiles[1].name:gsub("_source_animated", "")
|
||||||
|
|
||||||
-- Register base item
|
-- Register base item
|
||||||
minetest.register_craftitem(data.mod_name..":"..data.florb_name.."_"..internal, {
|
minetest.register_craftitem(itemname, {
|
||||||
description = data.florb_description.." ("..fluid..")",
|
description = data.florb_description.." ("..fluid..")",
|
||||||
inventory_image = stationary_name.."^[noalpha^"..data.textures[1].."^"..data.textures[2].."^[makealpha:255,0,0,",
|
inventory_image = stationary_name.."^[noalpha^"..data.textures[1].."^"..data.textures[2].."^[makealpha:255,0,0,",
|
||||||
_florb_capacity = data.capacity,
|
_florb_capacity = data.capacity,
|
||||||
@ -119,9 +125,11 @@ function fluidity.florbs.register_florb(data)
|
|||||||
local florb_desc = data.florb_description or 'Florb'
|
local florb_desc = data.florb_description or 'Florb'
|
||||||
local textures = data.textures or {"fluidity_florb.png", "fluidity_florb_mask.png"}
|
local textures = data.textures or {"fluidity_florb.png", "fluidity_florb_mask.png"}
|
||||||
local capacity = data.capacity or 1000
|
local capacity = data.capacity or 1000
|
||||||
|
local item_name = mod_name..":"..florb_name
|
||||||
|
|
||||||
|
if not minetest.registered_items[item_name] then
|
||||||
-- Register base item
|
-- Register base item
|
||||||
minetest.register_craftitem(mod_name..":"..florb_name, {
|
minetest.register_craftitem(item_name, {
|
||||||
description = florb_desc.." (Empty)\nThis item holds millibuckets of fluid.",
|
description = florb_desc.." (Empty)\nThis item holds millibuckets of fluid.",
|
||||||
inventory_image = textures[1].."^[noalpha^"..textures[2].."^[makealpha:255,0,0,",
|
inventory_image = textures[1].."^[noalpha^"..textures[2].."^[makealpha:255,0,0,",
|
||||||
_florb_capacity = capacity,
|
_florb_capacity = capacity,
|
||||||
@ -129,6 +137,7 @@ function fluidity.florbs.register_florb(data)
|
|||||||
stack_max = 1,
|
stack_max = 1,
|
||||||
groups = {florb = 1, florb_blank = 1}
|
groups = {florb = 1, florb_blank = 1}
|
||||||
})
|
})
|
||||||
|
end
|
||||||
|
|
||||||
-- Register for all fluids
|
-- Register for all fluids
|
||||||
if data.fluids then
|
if data.fluids then
|
||||||
|
@ -232,7 +232,13 @@ local function register_tankfluid(data)
|
|||||||
local fluid = fluidity.fluid_name(source_node.description)
|
local fluid = fluidity.fluid_name(source_node.description)
|
||||||
local internal = fluidity.fluid_short(fluid)
|
local internal = fluidity.fluid_short(fluid)
|
||||||
|
|
||||||
minetest.register_node(data.mod_name..":"..data.tank_name.."_"..internal, {
|
local nodename = data.mod_name..":"..data.tank_name.."_"..internal
|
||||||
|
|
||||||
|
if minetest.registered_nodes[nodename] then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.register_node(nodename, {
|
||||||
description = data.tank_description.." ("..fluid..")",
|
description = data.tank_description.." ("..fluid..")",
|
||||||
drawtype = "glasslike_framed_optional",
|
drawtype = "glasslike_framed_optional",
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
@ -260,8 +266,10 @@ function fluidity.tanks.register_fluid_tank(data)
|
|||||||
local tankdesc = data.tank_description or 'Fluid Tank'
|
local tankdesc = data.tank_description or 'Fluid Tank'
|
||||||
local tiles = data.tiles or {"default_glass.png", "default_glass_detail.png"}
|
local tiles = data.tiles or {"default_glass.png", "default_glass_detail.png"}
|
||||||
local capacity = data.capacity or 64000
|
local capacity = data.capacity or 64000
|
||||||
|
local tanknode = modname..":"..tankname
|
||||||
|
|
||||||
minetest.register_node(modname..":"..tankname, {
|
if not tanknode then
|
||||||
|
minetest.register_node(tanknode, {
|
||||||
description = tankdesc,
|
description = tankdesc,
|
||||||
drawtype = "glasslike_framed_optional",
|
drawtype = "glasslike_framed_optional",
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
@ -281,6 +289,7 @@ function fluidity.tanks.register_fluid_tank(data)
|
|||||||
groups = {cracky = 1, oddly_breakable_by_hand = 3, fluidity_tank = 1, fluid_tank_empty = 1},
|
groups = {cracky = 1, oddly_breakable_by_hand = 3, fluidity_tank = 1, fluid_tank_empty = 1},
|
||||||
tiles = tiles
|
tiles = tiles
|
||||||
})
|
})
|
||||||
|
end
|
||||||
|
|
||||||
if data.fluids then
|
if data.fluids then
|
||||||
-- This tank only uses certain fluids
|
-- This tank only uses certain fluids
|
||||||
|
@ -6,10 +6,8 @@ local num_tools = 0
|
|||||||
|
|
||||||
-- Create base tools
|
-- Create base tools
|
||||||
for m, s in pairs(tinkering.materials) do
|
for m, s in pairs(tinkering.materials) do
|
||||||
for t,_ in pairs(tinkering.tools) do
|
tinkering.register_material_tool(m)
|
||||||
tinkering.create_tool(t, {main=m,binding="wood",rod="wood"}, false, nil)
|
|
||||||
num_tools = num_tools + 1
|
num_tools = num_tools + 1
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Register tool components
|
-- Register tool components
|
||||||
|
@ -71,7 +71,7 @@ tinkering.components = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
-- Create component for material
|
-- Create component for material
|
||||||
local function create_material_component(data)
|
function tinkering.create_material_component(data)
|
||||||
local desc = data.description
|
local desc = data.description
|
||||||
local name = data.name
|
local name = data.name
|
||||||
local mod = data.mod_name
|
local mod = data.mod_name
|
||||||
@ -87,51 +87,6 @@ local function create_material_component(data)
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Register a new tool component
|
|
||||||
function tinkering.register_component(name, data)
|
|
||||||
local mod = data.mod_name or minetest.get_current_modname()
|
|
||||||
|
|
||||||
if not tinkering.components[name] then
|
|
||||||
tinkering.components[name] = data
|
|
||||||
end
|
|
||||||
|
|
||||||
local comp_desc = data.description:sub(4)
|
|
||||||
|
|
||||||
-- Register cast
|
|
||||||
metal_melter.set_spec(name, metal_caster.spec.cast)
|
|
||||||
metal_caster.register_cast(name, {
|
|
||||||
description = comp_desc,
|
|
||||||
mod_name = mod,
|
|
||||||
result = name,
|
|
||||||
cost = data.material_cost,
|
|
||||||
typenames = {name}
|
|
||||||
})
|
|
||||||
|
|
||||||
-- Register pattern
|
|
||||||
tinkering.register_pattern(name, {
|
|
||||||
description = comp_desc,
|
|
||||||
cost = data.material_cost,
|
|
||||||
mod_name = mod
|
|
||||||
})
|
|
||||||
|
|
||||||
-- Register components for all materials
|
|
||||||
for m, s in pairs(tinkering.materials) do
|
|
||||||
local component = m.."_"..name
|
|
||||||
|
|
||||||
create_material_component({
|
|
||||||
name = component,
|
|
||||||
component = name,
|
|
||||||
metal = m,
|
|
||||||
mod_name = mod,
|
|
||||||
description = data.description:format(s.name),
|
|
||||||
image = tinkering.color_filter(data.image, s.color)
|
|
||||||
})
|
|
||||||
|
|
||||||
-- Make all components meltable
|
|
||||||
metal_melter.register_melt(mod..":"..component, m, name)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Register a tool type
|
-- Register a tool type
|
||||||
--
|
--
|
||||||
--data = {
|
--data = {
|
||||||
@ -363,7 +318,7 @@ function tinkering.create_tool(tool_type, materials, want_tool, custom_name, ove
|
|||||||
local internal_name = mod_name..":"..materials.main.."_"..tool_type
|
local internal_name = mod_name..":"..materials.main.."_"..tool_type
|
||||||
|
|
||||||
-- Register base tool if it doesnt exist already
|
-- Register base tool if it doesnt exist already
|
||||||
if not minetest.registered_items[internal_name] then
|
if not minetest.registered_items[internal_name] and minetest.get_current_modname() then
|
||||||
minetest.register_tool(internal_name, tool_def)
|
minetest.register_tool(internal_name, tool_def)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -414,3 +369,55 @@ function tinkering.create_tool(tool_type, materials, want_tool, custom_name, ove
|
|||||||
|
|
||||||
return tool
|
return tool
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Register new tool material
|
||||||
|
function tinkering.register_material_tool(material)
|
||||||
|
for t,_ in pairs(tinkering.tools) do
|
||||||
|
tinkering.create_tool(t, {main=material,binding="wood",rod="wood"}, false, nil)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Register a new tool component
|
||||||
|
function tinkering.register_component(name, data)
|
||||||
|
local mod = data.mod_name or minetest.get_current_modname()
|
||||||
|
|
||||||
|
if not tinkering.components[name] then
|
||||||
|
tinkering.components[name] = data
|
||||||
|
end
|
||||||
|
|
||||||
|
local comp_desc = data.description:sub(4)
|
||||||
|
|
||||||
|
-- Register cast
|
||||||
|
metal_melter.set_spec(name, metal_caster.spec.cast)
|
||||||
|
metal_caster.register_cast(name, {
|
||||||
|
description = comp_desc,
|
||||||
|
mod_name = mod,
|
||||||
|
result = name,
|
||||||
|
cost = data.material_cost,
|
||||||
|
typenames = {name}
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Register pattern
|
||||||
|
tinkering.register_pattern(name, {
|
||||||
|
description = comp_desc,
|
||||||
|
cost = data.material_cost,
|
||||||
|
mod_name = mod
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Register components for all materials
|
||||||
|
for m, s in pairs(tinkering.materials) do
|
||||||
|
local component = m.."_"..name
|
||||||
|
|
||||||
|
tinkering.create_material_component({
|
||||||
|
name = component,
|
||||||
|
component = name,
|
||||||
|
metal = m,
|
||||||
|
mod_name = mod,
|
||||||
|
description = data.description:format(s.name),
|
||||||
|
image = tinkering.color_filter(data.image, s.color)
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Make all components meltable
|
||||||
|
metal_melter.register_melt(mod..":"..component, m, name)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user