mirror of
https://gitlab.icynet.eu/evert/melterns.git
synced 2024-11-24 07:53:47 +01:00
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 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", "")
|
||||
|
||||
-- Register base item
|
||||
minetest.register_craftitem(data.mod_name..":"..data.florb_name.."_"..internal, {
|
||||
minetest.register_craftitem(itemname, {
|
||||
description = data.florb_description.." ("..fluid..")",
|
||||
inventory_image = stationary_name.."^[noalpha^"..data.textures[1].."^"..data.textures[2].."^[makealpha:255,0,0,",
|
||||
_florb_capacity = data.capacity,
|
||||
@ -114,21 +120,24 @@ local function register_florbfluid(data)
|
||||
end
|
||||
|
||||
function fluidity.florbs.register_florb(data)
|
||||
local mod_name = data.mod_name or minetest.get_current_modname()
|
||||
local mod_name = data.mod_name or minetest.get_current_modname()
|
||||
local florb_name = data.florb_name or 'florb'
|
||||
local florb_desc = data.florb_description or 'Florb'
|
||||
local textures = data.textures or {"fluidity_florb.png", "fluidity_florb_mask.png"}
|
||||
local capacity = data.capacity or 1000
|
||||
local item_name = mod_name..":"..florb_name
|
||||
|
||||
-- Register base item
|
||||
minetest.register_craftitem(mod_name..":"..florb_name, {
|
||||
description = florb_desc.." (Empty)\nThis item holds millibuckets of fluid.",
|
||||
inventory_image = textures[1].."^[noalpha^"..textures[2].."^[makealpha:255,0,0,",
|
||||
_florb_capacity = capacity,
|
||||
_florb_source = nil,
|
||||
stack_max = 1,
|
||||
groups = {florb = 1, florb_blank = 1}
|
||||
})
|
||||
if not minetest.registered_items[item_name] then
|
||||
-- Register base item
|
||||
minetest.register_craftitem(item_name, {
|
||||
description = florb_desc.." (Empty)\nThis item holds millibuckets of fluid.",
|
||||
inventory_image = textures[1].."^[noalpha^"..textures[2].."^[makealpha:255,0,0,",
|
||||
_florb_capacity = capacity,
|
||||
_florb_source = nil,
|
||||
stack_max = 1,
|
||||
groups = {florb = 1, florb_blank = 1}
|
||||
})
|
||||
end
|
||||
|
||||
-- Register for all fluids
|
||||
if data.fluids then
|
||||
|
@ -232,7 +232,13 @@ local function register_tankfluid(data)
|
||||
local fluid = fluidity.fluid_name(source_node.description)
|
||||
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..")",
|
||||
drawtype = "glasslike_framed_optional",
|
||||
paramtype = "light",
|
||||
@ -260,27 +266,30 @@ function fluidity.tanks.register_fluid_tank(data)
|
||||
local tankdesc = data.tank_description or 'Fluid Tank'
|
||||
local tiles = data.tiles or {"default_glass.png", "default_glass_detail.png"}
|
||||
local capacity = data.capacity or 64000
|
||||
local tanknode = modname..":"..tankname
|
||||
|
||||
minetest.register_node(modname..":"..tankname, {
|
||||
description = tankdesc,
|
||||
drawtype = "glasslike_framed_optional",
|
||||
paramtype = "light",
|
||||
paramtype2 = "glasslikeliquidlevel",
|
||||
is_ground_content = false,
|
||||
sunlight_propagates = true,
|
||||
fluidity_fluid = nil,
|
||||
on_construct = function ( pos )
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_int("fluid", 0)
|
||||
meta:set_string("infotext", "Empty "..tankdesc)
|
||||
end,
|
||||
on_rightclick = bucket_fill,
|
||||
_mod = modname,
|
||||
_dataname = tankname,
|
||||
_capacity = capacity,
|
||||
groups = {cracky = 1, oddly_breakable_by_hand = 3, fluidity_tank = 1, fluid_tank_empty = 1},
|
||||
tiles = tiles
|
||||
})
|
||||
if not tanknode then
|
||||
minetest.register_node(tanknode, {
|
||||
description = tankdesc,
|
||||
drawtype = "glasslike_framed_optional",
|
||||
paramtype = "light",
|
||||
paramtype2 = "glasslikeliquidlevel",
|
||||
is_ground_content = false,
|
||||
sunlight_propagates = true,
|
||||
fluidity_fluid = nil,
|
||||
on_construct = function ( pos )
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_int("fluid", 0)
|
||||
meta:set_string("infotext", "Empty "..tankdesc)
|
||||
end,
|
||||
on_rightclick = bucket_fill,
|
||||
_mod = modname,
|
||||
_dataname = tankname,
|
||||
_capacity = capacity,
|
||||
groups = {cracky = 1, oddly_breakable_by_hand = 3, fluidity_tank = 1, fluid_tank_empty = 1},
|
||||
tiles = tiles
|
||||
})
|
||||
end
|
||||
|
||||
if data.fluids then
|
||||
-- This tank only uses certain fluids
|
||||
|
@ -6,10 +6,8 @@ local num_tools = 0
|
||||
|
||||
-- Create base tools
|
||||
for m, s in pairs(tinkering.materials) do
|
||||
for t,_ in pairs(tinkering.tools) do
|
||||
tinkering.create_tool(t, {main=m,binding="wood",rod="wood"}, false, nil)
|
||||
num_tools = num_tools + 1
|
||||
end
|
||||
tinkering.register_material_tool(m)
|
||||
num_tools = num_tools + 1
|
||||
end
|
||||
|
||||
-- Register tool components
|
||||
|
@ -71,7 +71,7 @@ tinkering.components = {
|
||||
}
|
||||
|
||||
-- Create component for material
|
||||
local function create_material_component(data)
|
||||
function tinkering.create_material_component(data)
|
||||
local desc = data.description
|
||||
local name = data.name
|
||||
local mod = data.mod_name
|
||||
@ -87,51 +87,6 @@ local function create_material_component(data)
|
||||
})
|
||||
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
|
||||
--
|
||||
--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
|
||||
|
||||
-- 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)
|
||||
end
|
||||
|
||||
@ -414,3 +369,55 @@ function tinkering.create_tool(tool_type, materials, want_tool, custom_name, ove
|
||||
|
||||
return tool
|
||||
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