Initial commit (version 0.1-test)
This commit is contained in:
219
mods/terumet/interop/3d_armor.lua
Normal file
219
mods/terumet/interop/3d_armor.lua
Normal file
@@ -0,0 +1,219 @@
|
||||
-- add armor when 3darmor mod is also active
|
||||
local opts = terumet.options.armor
|
||||
|
||||
local function gen_armor_groups(type, data)
|
||||
local grps = {
|
||||
armor_use=data.uses,
|
||||
armor_heal=(data.heal or 0),
|
||||
armor_water=(data.breathing or 0),
|
||||
armor_fire=data.fire,
|
||||
physics_speed=(data.speed or 0),
|
||||
physics_gravity=(data.gravity or 0),
|
||||
physics_jump=(data.jump or 0),
|
||||
}
|
||||
grps[type]=1
|
||||
return grps
|
||||
end
|
||||
|
||||
local function reg_recipe_boots(id, mat)
|
||||
minetest.register_craft{output=id, recipe={
|
||||
{mat, '', mat},
|
||||
{mat, '', mat}
|
||||
}}
|
||||
end
|
||||
|
||||
local function reg_recipe_legs(id, mat)
|
||||
minetest.register_craft{output=id, recipe={
|
||||
{mat, mat, mat},
|
||||
{mat, '', mat},
|
||||
{mat, '', mat}
|
||||
}}
|
||||
end
|
||||
|
||||
local function reg_recipe_chest(id, mat)
|
||||
minetest.register_craft{output=id, recipe={
|
||||
{mat, '', mat},
|
||||
{mat, mat, mat},
|
||||
{mat, mat, mat}
|
||||
}}
|
||||
end
|
||||
|
||||
local function reg_recipe_helm(id, mat)
|
||||
minetest.register_craft{output=id, recipe={
|
||||
{mat, mat, mat},
|
||||
{mat, '', mat},
|
||||
}}
|
||||
end
|
||||
|
||||
local function reg_terumet_armor(data)
|
||||
if not data or not data.suffix or not data.mat then error('Missing data on registering Terumetal armor') end
|
||||
data.uses = data.uses or 500
|
||||
data.mrv = data.mrv or 10 -- material repair value of 1x mat
|
||||
data.dgroups = data.dgroups or {cracky=3, snappy=3, choppy=3, crumbly=3, level=1}
|
||||
data.name = data.name or data.suffix
|
||||
|
||||
local low_def = data.total_def / 6
|
||||
local hi_def = data.total_def / 3
|
||||
|
||||
data.heal = data.total_heal / 4
|
||||
data.speed = data.weight / -100
|
||||
data.gravity = data.weight / 50
|
||||
|
||||
local boots_id = terumet.id('armboots_'..data.suffix)
|
||||
armor:register_armor(boots_id, {
|
||||
description = terumet.item_desc(data.name..' Boots', data.xinfo),
|
||||
inventory_image = terumet.tex('invboots_'..data.suffix),
|
||||
texture = terumet.tex('armboots_'..data.suffix),
|
||||
preview = terumet.tex('prvboots_'..data.suffix),
|
||||
groups = gen_armor_groups('armor_feet', data),
|
||||
armor_groups = {fleshy=low_def},
|
||||
damage_groups = data.dgroups,
|
||||
})
|
||||
reg_recipe_boots(boots_id, data.mat)
|
||||
terumet.register_repairable_item(boots_id, data.mrv*4)
|
||||
|
||||
local helm_id = terumet.id('armhelm_'..data.suffix)
|
||||
armor:register_armor(helm_id, {
|
||||
description= terumet.item_desc(data.name..' Helmet', data.xinfo),
|
||||
inventory_image = terumet.tex('invhelm_'..data.suffix),
|
||||
texture = terumet.tex('armhelm_'..data.suffix),
|
||||
preview = terumet.tex('prvhelm_'..data.suffix),
|
||||
groups = gen_armor_groups('armor_head', data),
|
||||
armor_groups = {fleshy=low_def},
|
||||
damage_groups = data.dgroups,
|
||||
})
|
||||
reg_recipe_helm(helm_id, data.mat)
|
||||
terumet.register_repairable_item(helm_id, data.mrv*5)
|
||||
|
||||
local chest_id = terumet.id('armchest_'..data.suffix)
|
||||
armor:register_armor(chest_id, {
|
||||
description= terumet.item_desc(data.name..' Chestpiece', data.xinfo),
|
||||
inventory_image = terumet.tex('invchest_'..data.suffix),
|
||||
texture = terumet.tex('armchest_'..data.suffix),
|
||||
preview = terumet.tex('prvchest_'..data.suffix),
|
||||
groups = gen_armor_groups('armor_torso', data),
|
||||
armor_groups = {fleshy=hi_def},
|
||||
damage_groups = data.dgroups,
|
||||
})
|
||||
reg_recipe_chest(chest_id, data.mat)
|
||||
terumet.register_repairable_item(chest_id, data.mrv*8)
|
||||
|
||||
local legs_id = terumet.id('armlegs_'..data.suffix)
|
||||
armor:register_armor(legs_id, {
|
||||
description= terumet.item_desc(data.name..' Leggings', data.xinfo),
|
||||
inventory_image = terumet.tex('invlegs_'..data.suffix),
|
||||
texture = terumet.tex('armlegs_'..data.suffix),
|
||||
preview = terumet.tex('prvlegs_'..data.suffix),
|
||||
groups = gen_armor_groups('armor_legs', data),
|
||||
armor_groups = {fleshy=hi_def},
|
||||
damage_groups = data.dgroups,
|
||||
})
|
||||
reg_recipe_legs(legs_id, data.mat)
|
||||
terumet.register_repairable_item(legs_id, data.mrv*7)
|
||||
end
|
||||
|
||||
-- enable terumet bracers
|
||||
if opts.BRACERS then
|
||||
-- I would love to colorize every texture rather than require a seperate armor & preview texture for every bracer
|
||||
-- but it seems that 3d_armor textures do NOT support texture generation with ^ layering and ^[multiply :(
|
||||
local function bracer_inv_texture(color)
|
||||
if color then
|
||||
return string.format('(%s^(%s^[multiply:%s))', terumet.tex('invbrcr_base'), terumet.tex('invbrcr_color'), color)
|
||||
else
|
||||
return terumet.tex('invbrcr_base')
|
||||
end
|
||||
end
|
||||
|
||||
local function core_texture(color)
|
||||
return string.format('%s^[multiply:%s', terumet.tex('item_brcrcrys'), color)
|
||||
end
|
||||
|
||||
table.insert(armor.elements, "terumet_brcr")
|
||||
|
||||
local brcrcrys_id = terumet.id('item_brcrcrys')
|
||||
minetest.register_craftitem( brcrcrys_id, {
|
||||
description = 'Blank Bracer Core',
|
||||
inventory_image = terumet.tex(brcrcrys_id)
|
||||
})
|
||||
-- add vulcan crystallizer recipe for blank bracer core
|
||||
terumet.options.vulcan.recipes[opts.BRACER_CRYSTAL_ITEM] = {brcrcrys_id, 2}
|
||||
|
||||
local function reg_terumet_band(data)
|
||||
if not data or not data.suffix then error('Missing data on registering Terumetal bracer') end
|
||||
data.uses = data.uses or 500
|
||||
data.def = data.def or 0
|
||||
data.dgroups = data.dgroups or {cracky=3, snappy=3, choppy=3, crumbly=3, level=1}
|
||||
data.name = data.name or data.suffix
|
||||
-- generate groups now to update xinfo if necessary before registering it
|
||||
local groups = gen_armor_groups('armor_terumet_brcr', data)
|
||||
|
||||
local band_id = terumet.id('brcr_'..data.suffix)
|
||||
armor:register_armor(band_id, {
|
||||
description= terumet.item_desc(data.name..' Bracers', data.xinfo),
|
||||
inventory_image = bracer_inv_texture(data.color),
|
||||
texture = terumet.tex('armbrcr_'..data.suffix),
|
||||
preview = terumet.tex('prvbrcr_'..data.suffix),
|
||||
groups = groups,
|
||||
armor_groups = {fleshy=data.def},
|
||||
damage_groups = data.dgroups,
|
||||
on_equip = data.on_equip,
|
||||
on_unequip = data.on_unequip,
|
||||
on_damage = data.on_damage,
|
||||
on_punched = data.on_punched
|
||||
})
|
||||
|
||||
if data.mat then
|
||||
local ecryst_id = terumet.id('item_brcrcrys_'..data.suffix)
|
||||
minetest.register_craftitem( ecryst_id, {
|
||||
description = data.name..' Bracer Core',
|
||||
inventory_image = core_texture(data.color)
|
||||
})
|
||||
|
||||
terumet.register_alloy_recipe{result=ecryst_id, flux=4, time=10.0, input={brcrcrys_id, data.mat}}
|
||||
|
||||
terumet.register_alloy_recipe{result=band_id, flux=0, time=120.0, input={terumet.id('brcr_base'), ecryst_id .. ' 8'}}
|
||||
else
|
||||
local metal = terumet.id('item_cryst_raw')
|
||||
local coil = terumet.id('item_coil_tgol')
|
||||
minetest.register_craft{output=band_id, recipe={
|
||||
{coil, metal, coil},
|
||||
{metal, metal, metal},
|
||||
{coil, metal, coil}
|
||||
}}
|
||||
end
|
||||
|
||||
terumet.register_repairable_item(band_id, data.rep or 80)
|
||||
end
|
||||
|
||||
reg_terumet_band{suffix='base', name='Terumetal', xinfo='No effects', def=5, uses=500, rep=80}
|
||||
|
||||
for band_id, band_data in pairs(opts.BRACERS) do
|
||||
if (not band_data.fire) or armor.config.fire_protect then
|
||||
band_data.suffix = band_id
|
||||
reg_terumet_band(band_data)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if not armor.config.fire_protect then
|
||||
minetest.log('warning', 'terumet: fire protection on armor will not function - 3d_armor fire protection option not activated')
|
||||
end
|
||||
|
||||
-- 3d_armor fire protection notes: total fire protection must meet or exceed the following values to be immune
|
||||
-- torches = 1, fire = 3, lava = 5
|
||||
-- this seems to be the only effect it has
|
||||
|
||||
reg_terumet_armor{suffix='cgls', name='Coreglass', mat=terumet.id('ingot_cgls'),
|
||||
mrv=120, total_def=78, total_heal=36, weight=3, xinfo='Weight +3', uses=120, fire=0.75} -- 2 pcs = immune to torches, 4 pcs = immune to fire
|
||||
reg_terumet_armor{suffix='tcha', name='Teruchalcum', mat=terumet.id('ingot_tcha'),
|
||||
mrv=60, total_def=64, total_heal=8, weight=2, xinfo='Weight +2', uses=260}
|
||||
reg_terumet_armor{suffix='tste', name='Terusteel', mat=terumet.id('ingot_tste'),
|
||||
mrv=40, total_def=56, total_heal=12, weight=1, xinfo='Weight +1', uses=190}
|
||||
reg_terumet_armor{suffix='tcop', name='Terucopper', mat=terumet.id('ingot_tcop'),
|
||||
mrv=20, total_def=45, total_heal=4, weight=0, uses=280}
|
||||
reg_terumet_armor{suffix='tgol', name='Terugold', mat=terumet.id('ingot_tgol'),
|
||||
mrv=80, total_def=24, total_heal=65, weight=-1, xinfo='Weight -1', uses=720}
|
||||
reg_terumet_armor{suffix='ttin', name='Terutin', mat=terumet.id('ingot_ttin'),
|
||||
mrv=21, total_def=38, total_heal=24, weight=-2, xinfo='Weight -2', uses=410, fire=0.34, breathing=.1} -- 3 pcs = immune to torches
|
||||
reg_terumet_armor{suffix='rsuit', name='Vulcansuit', mat=terumet.id('item_rsuitmat'),
|
||||
mrv=180, total_def=78, total_heal=50, weight=-3, xinfo='Weight -3', uses=120, fire=1} -- 1 pc = immune to torches, 3 pcs = immune to fire
|
||||
47
mods/terumet/interop/crusher_misc.lua
Normal file
47
mods/terumet/interop/crusher_misc.lua
Normal file
@@ -0,0 +1,47 @@
|
||||
-- add crushing recipes for various mods if they are active
|
||||
|
||||
local function add_crush(item, result)
|
||||
terumet.options.crusher.recipes[item] = result
|
||||
end
|
||||
|
||||
|
||||
if minetest.get_modpath('bushes') then
|
||||
add_crush('bushes:BushLeaves1', 'terumet:item_dust_bio')
|
||||
add_crush('bushes:BushLeaves2', 'terumet:item_dust_bio')
|
||||
end
|
||||
|
||||
if minetest.get_modpath('dryplants') then
|
||||
add_crush('dryplants:grass', 'terumet:item_dust_bio')
|
||||
end
|
||||
|
||||
if minetest.get_modpath('vines') then
|
||||
add_crush('vines:vines', 'terumet:item_dust_bio')
|
||||
end
|
||||
|
||||
if minetest.get_modpath('farming') then
|
||||
-- small crops turn into 2 biomatter
|
||||
local small_crops = {
|
||||
'wheat', 'peas', 'barley', 'beans', 'pepper', 'beetroot', 'chili_pepper', 'blueberries',
|
||||
'cucumber', 'grapes', 'garlic', 'onion', 'pea_pod', 'pineapple_ring', 'pineapple_top', 'potato',
|
||||
'raspberries', 'tomato', 'corn', 'rhubarb'
|
||||
}
|
||||
|
||||
for _,crop in ipairs(small_crops) do
|
||||
local crop_id = 'farming:'..crop
|
||||
if minetest.registered_items[crop_id] then
|
||||
add_crush(crop_id, 'terumet:item_dust_bio 2')
|
||||
end
|
||||
end
|
||||
|
||||
-- big crops turn into 5 biomatter
|
||||
local big_crops = {
|
||||
'pumpkin', 'pineapple', 'melon_8'
|
||||
}
|
||||
|
||||
for _,crop in ipairs(big_crops) do
|
||||
local crop_id = 'farming'..crop
|
||||
if minetest.registered_items[crop_id] then
|
||||
add_crush(crop_id, 'terumet:item_dust_bio 5')
|
||||
end
|
||||
end
|
||||
end
|
||||
79
mods/terumet/interop/doors.lua
Normal file
79
mods/terumet/interop/doors.lua
Normal file
@@ -0,0 +1,79 @@
|
||||
-- order door type can be converted
|
||||
local type_order = {'full', 'mesh', 'slat', 'vert'}
|
||||
local type_names = {
|
||||
full='Solid %s Door',
|
||||
mesh='Meshed %s Door',
|
||||
slat='Slatted %s Door',
|
||||
vert='Fancy %s Door'
|
||||
}
|
||||
|
||||
local materials = {
|
||||
tcop={
|
||||
item=terumet.id('ingot_tcop'),
|
||||
name='Terucopper',
|
||||
level=1
|
||||
},
|
||||
ttin={
|
||||
item=terumet.id('ingot_ttin'),
|
||||
name='Terutin',
|
||||
level=1
|
||||
},
|
||||
tste={
|
||||
item=terumet.id('ingot_tste'),
|
||||
name='Terusteel',
|
||||
level=2
|
||||
},
|
||||
tcha={
|
||||
item=terumet.id('ingot_tcha'),
|
||||
name='Teruchalcum',
|
||||
level=2
|
||||
},
|
||||
tgol={
|
||||
item=terumet.id('ingot_tgol'),
|
||||
name='Terugold',
|
||||
level=3
|
||||
},
|
||||
cgls={
|
||||
item=terumet.id('ingot_cgls'),
|
||||
name='Coreglass',
|
||||
level=4
|
||||
}
|
||||
}
|
||||
|
||||
for mat_id, mat_data in pairs(materials) do
|
||||
local first_door_id = nil
|
||||
local prev_door_id = nil
|
||||
for _, type_id in pairs(type_order) do
|
||||
local type_name = type_names[type_id]
|
||||
local door_id = terumet.id(string.format('door%s_%s', type_id, mat_id))
|
||||
local door_tex = terumet.tex(string.format('door%s_%s', type_id, mat_id))
|
||||
local door_invtex = terumet.tex(string.format('dinv%s_%s', type_id, mat_id))
|
||||
local door_recipe = nil
|
||||
if not prev_door_id then
|
||||
door_recipe = {
|
||||
{mat_data.item, mat_data.item},
|
||||
{mat_data.item, mat_data.item},
|
||||
{mat_data.item, mat_data.item}
|
||||
}
|
||||
end
|
||||
doors.register(door_id, {
|
||||
tiles = {{name = door_tex, backface_culling = true}},
|
||||
description = string.format(type_name, mat_data.name),
|
||||
inventory_image = door_invtex,
|
||||
protected = true,
|
||||
groups = {cracky = 1, level = mat_data.level},
|
||||
sounds = default.node_sound_metal_defaults(),
|
||||
sound_open = 'doors_steel_door_open',
|
||||
sound_close = 'doors_steel_door_close',
|
||||
recipe = door_recipe
|
||||
})
|
||||
|
||||
if prev_door_id then
|
||||
minetest.register_craft{ type='shapeless', output=door_id, recipe={prev_door_id} }
|
||||
end
|
||||
|
||||
if not first_door_id then first_door_id = door_id end
|
||||
prev_door_id = door_id
|
||||
end
|
||||
minetest.register_craft{ type='shapeless', output=first_door_id, recipe={prev_door_id} }
|
||||
end
|
||||
44
mods/terumet/interop/dungeon_loot.lua
Normal file
44
mods/terumet/interop/dungeon_loot.lua
Normal file
@@ -0,0 +1,44 @@
|
||||
|
||||
local rloot = dungeon_loot.register
|
||||
local id = terumet.id
|
||||
|
||||
local BOTTOM = -32768
|
||||
local TOP = 32768
|
||||
|
||||
-- still a WIP on balance/items put into loot
|
||||
|
||||
rloot{name=id('item_col_raw'), chance=0.8, count={1,9}, y={-64, TOP}}
|
||||
rloot{name=id('item_col_tcop'), chance=0.8, count={1,9}, y={-512, 32}}
|
||||
rloot{name=id('item_col_tgol'), chance=0.8, count={1,9}, y={BOTTOM, 0}}
|
||||
|
||||
rloot{name=id('lump_raw'), chance=0.8, count={2,6}, y={0, TOP}}
|
||||
rloot{name=id('ingot_raw'), chance=0.7, count={1,4}, y={0, TOP}}
|
||||
rloot{name=id('lump_raw'), chance=0.85, count={1,12}}
|
||||
rloot{name=id('ingot_raw'), chance=0.75, count={1,9}}
|
||||
|
||||
rloot{name=id('item_glue'), chance=0.95, count={3,24}, y={-16, TOP}}
|
||||
rloot{name=id('item_coke'), chance=0.85, count={1,10}, y={-128, -32}}
|
||||
rloot{name=id('item_tarball'), chance=0.75, count={1,10}, y={BOTTOM, -96}}
|
||||
|
||||
rloot{name=id('block_pwood'), chance=0.85, count={8,24}, y={-16, TOP}}
|
||||
rloot{name=id('block_conmix'), chance=0.65, count={8,24}, y={-64, 128}}
|
||||
rloot{name=id('block_asphalt'), chance=0.75, count={8,24}, y={-128, -48}}
|
||||
|
||||
rloot{name=id('item_ceramic'), chance=0.65, count={2,10}, y={-8, TOP}}
|
||||
rloot{name=id('item_ceramic'), chance=0.85, count={6,24}, y={-256, -8}}
|
||||
rloot{name=id('block_ceramic'), chance=0.45, count={1,3}, y={BOTTOM, -128}}
|
||||
|
||||
rloot{name=id('item_batt_cop_full'), chance=0.10, y={-128, 0}}
|
||||
rloot{name=id('item_batt_therm_full'), chance=0.05, y={BOTTOM, -128}}
|
||||
|
||||
rloot{name=id('item_htglass'), chance=0.5, count={1,3}, y={-128, 0}}
|
||||
rloot{name=id('item_entropy'), chance=0.2, y={BOTTOM, -128}}
|
||||
|
||||
rloot{name=id('repmat_drop'), chance=0.5, count={1,24}, y={BOTTOM, -8}}
|
||||
|
||||
-- TODO: weight alloys by value
|
||||
for _,alloy_data in pairs(terumet.alloys) do
|
||||
rloot{name=alloy_data.ingot, chance=0.30, count={1,2}, y={-24, TOP}}
|
||||
rloot{name=alloy_data.ingot, chance=0.50, count={1,5}, y={-128, 0}}
|
||||
rloot{name=alloy_data.ingot, chance=0.70, count={3,9}, y={BOTTOM, -96}}
|
||||
end
|
||||
14
mods/terumet/interop/extra.lua
Normal file
14
mods/terumet/interop/extra.lua
Normal file
@@ -0,0 +1,14 @@
|
||||
local food_opts = terumet.options.vac_oven.VAC_FOOD
|
||||
|
||||
-- add farming foods to vac-food whitelist if it's active
|
||||
if food_opts and food_opts.ACTIVE then
|
||||
local foods = {
|
||||
'potato_crisps', 'french_fries', 'onion_rings', 'blooming_onion', 'fish_sticks', 'grilled_patty', 'hamburger', 'cheeseburger',
|
||||
'corn_dog', 'meatloaf', 'flour_tortilla', 'taco', 'super_taco', 'quesadilla', 'pepperoni', 'garlic_bread', 'spaghetti', 'lasagna', 'cheese_pizza',
|
||||
'salsa', 'pepperoni_pizza', 'deluxe_pizza', 'pineapple_pizza', 'cornbread'
|
||||
}
|
||||
|
||||
for _,id in ipairs(foods) do
|
||||
food_opts.WHITELIST[string.format('extra:%s', id)]=1
|
||||
end
|
||||
end
|
||||
13
mods/terumet/interop/farming.lua
Normal file
13
mods/terumet/interop/farming.lua
Normal file
@@ -0,0 +1,13 @@
|
||||
local food_opts = terumet.options.vac_oven.VAC_FOOD
|
||||
|
||||
-- add farming foods to vac-food whitelist if it's active
|
||||
if food_opts and food_opts.ACTIVE then
|
||||
local foods = {
|
||||
'baked_potato', 'potato_salad', 'pumpkin_bread', 'toast_sandwich', 'donut', 'donut_chocolate', 'donut_apple', 'porridge', 'turkish_delight',
|
||||
'chili_bowl', 'rhubarb_pie', 'garlic_bread', 'muffin_blueberry', 'chocolate_dark'
|
||||
}
|
||||
|
||||
for _,id in ipairs(foods) do
|
||||
food_opts.WHITELIST[string.format('farming:%s', id)]=1
|
||||
end
|
||||
end
|
||||
7
mods/terumet/interop/mesecons.lua
Normal file
7
mods/terumet/interop/mesecons.lua
Normal file
@@ -0,0 +1,7 @@
|
||||
-- interop bugfix with Mesecons/piston mod
|
||||
-- fix for https://github.com/Terumoc/terumet/issues/16
|
||||
|
||||
terumet.machine.register_on_new_machine_node(function (id, def)
|
||||
-- register every terumetal machine node as a "stopper" for pistons
|
||||
mesecon.register_mvps_stopper(id, true)
|
||||
end)
|
||||
22
mods/terumet/interop/moreores.lua
Normal file
22
mods/terumet/interop/moreores.lua
Normal file
@@ -0,0 +1,22 @@
|
||||
|
||||
local crys_mithril = terumet.register_crystal{
|
||||
suffix='mith',
|
||||
color='#6161d5',
|
||||
name='Crystallized Mithril',
|
||||
cooking_result='moreores:mithril_ingot'
|
||||
}
|
||||
terumet.register_vulcan_result('moreores:mithril_lump', crys_mithril)
|
||||
terumet.register_vulcan_result('moreores:mineral_mithril', crys_mithril, 1)
|
||||
|
||||
local crys_silver = terumet.register_crystal{
|
||||
suffix='silv',
|
||||
color='#d3fffb',
|
||||
name='Crystallized Silver',
|
||||
cooking_result='moreores:silver_ingot'
|
||||
}
|
||||
terumet.register_vulcan_result('moreores:silver_lump', crys_silver)
|
||||
terumet.register_vulcan_result('moreores:mineral_silver', crys_silver, 1)
|
||||
|
||||
|
||||
terumet.crystal_ids.mitril = crys_mithril
|
||||
terumet.crystal_ids.silver = crys_silver
|
||||
234
mods/terumet/interop/terumet_api.lua
Normal file
234
mods/terumet/interop/terumet_api.lua
Normal file
@@ -0,0 +1,234 @@
|
||||
-- API for other mods to interface with this mod
|
||||
|
||||
|
||||
-- register an external block for use in making heatline versions and/or reinforced versions
|
||||
-- if you wish to exclude one or the other, pass {heatline=true} or {reinforced=true} as 3rd argument
|
||||
|
||||
|
||||
-- register an item that provide Repair Material to Equipment Reformer
|
||||
-- value = repair material value provided by 1 item
|
||||
function terumet.register_repair_material(id, value)
|
||||
-- TODO error checking
|
||||
terumet.options.repm.repair_mats[id] = value
|
||||
end
|
||||
|
||||
-- register a tool that can be repaired in Equipment Reformer
|
||||
-- needed_mat = amount of repair material value to repair fully worn tool
|
||||
function terumet.register_repairable_item(id, needed_mat)
|
||||
-- TODO error checking
|
||||
terumet.options.repm.repairable[id] = needed_mat
|
||||
end
|
||||
|
||||
-- register a new alloy smelter recipe
|
||||
-- required data keys and descriptions:
|
||||
local ALLOY_REQUIRED = {
|
||||
result='[itemstack string] what will be output',
|
||||
input='[table, 1-4 stacks] table of itemstacks consumed as input',
|
||||
time='[float] time in seconds to process',
|
||||
flux='[integer] amount of terumetal flux consumed from tank',
|
||||
}
|
||||
function terumet.register_alloy_recipe(data)
|
||||
if not data then
|
||||
error('terumet.register_alloy_recipe: no recipe data provided')
|
||||
end
|
||||
for req_key, desc in pairs(ALLOY_REQUIRED) do
|
||||
if not data[req_key] then
|
||||
error(string.format('terumet.register_alloy_recipe: recipe data is missing required key %s: %s', req_key, desc))
|
||||
end
|
||||
end
|
||||
if type(data.input) ~= 'table' or #data.input < 1 or #data.input > 4 then
|
||||
error('terumet.register_alloy_recipe: invalid input; must be a table of 1-4 itemstack strings (inclusive)')
|
||||
end
|
||||
table.insert(terumet.options.smelter.recipes, 1, data)
|
||||
end
|
||||
|
||||
-- TODO error checking
|
||||
function terumet.register_vacoven_recipe(data)
|
||||
table.insert(terumet.options.vac_oven.recipes, data)
|
||||
end
|
||||
|
||||
-- register a new crystallized material with the provided data
|
||||
-- ID of created item will be 'terumet:item_cryst_<SUFFIX>'
|
||||
-- IMPORTANT NOTE: a single source item can only be defined as a single crystal
|
||||
-- for example, trying to add a new crystal for 'default:copper_lump' will override the default one
|
||||
--
|
||||
-- required data keys and descriptions:
|
||||
local CRYSTAL_REQUIRED = {
|
||||
suffix='[string] ID suffix for crystallized item',
|
||||
color='[colorspec] minetest colorspec for crystallized item color',
|
||||
name='[string] name of crystallized item',
|
||||
cooking_result='[itemstack string] result of cooking crystallized item',
|
||||
}
|
||||
|
||||
|
||||
function terumet.register_crystal(data)
|
||||
local this_func = 'terumet.register_crystal'
|
||||
if not data then
|
||||
error(this_func..': no data provided')
|
||||
end
|
||||
for req_key, desc in pairs(CRYSTAL_REQUIRED) do
|
||||
if not data[req_key] then
|
||||
error(string.format('%s: data missing required key %s: %s', this_func, req_key, desc))
|
||||
end
|
||||
end
|
||||
local crys_id = terumet.id('item_cryst_'..data.suffix)
|
||||
minetest.register_craftitem( crys_id, {
|
||||
description = data.name,
|
||||
inventory_image = terumet.crystal_tex(data.color),
|
||||
})
|
||||
minetest.register_craft{ type = 'cooking',
|
||||
output = data.cooking_result,
|
||||
recipe = crys_id,
|
||||
cooktime = 5
|
||||
}
|
||||
return crys_id -- returns crystal item ID
|
||||
end
|
||||
|
||||
-- register an item that can be put into crystal vulcanizer
|
||||
-- requires source item and result, optionally include integer modifier
|
||||
-- by default creates 2 result items, but count_modifier is added to that value
|
||||
-- +1 more result item if vulcanizer has upgrade
|
||||
function terumet.register_vulcan_result(source, result, count_modifier, specialized)
|
||||
count_modifier = count_modifier or 0
|
||||
local this_func = 'terumet.register_vulcan_result'
|
||||
if not source then error(this_func..': no source item provided') end
|
||||
if not result then error(this_func..': no result item provided') end
|
||||
local count = 2 + count_modifier
|
||||
if( count < 1 ) then count = 1 end
|
||||
terumet.options.vulcan.recipes[source] = {result, count, specialized}
|
||||
end
|
||||
|
||||
-- register that a node can generate heat when extracted by the Environmental Entropy Extraction Heater (EEE Heater)
|
||||
local ENTROPIC_REQUIRED = {
|
||||
node='[string] id of node that can be extracted',
|
||||
hu_per_s='[integer] number of heat units extracted per second',
|
||||
extract_time='[float] total amount of time to extract this node',
|
||||
}
|
||||
-- optional keys:
|
||||
-- change_to: [string] what node this node will change into after extraction - if nil, the node will not change and thus can be extracted over and over (like air by default)
|
||||
function terumet.register_entropic_node(data)
|
||||
if not data then
|
||||
error('terumet.register_entropic_node: no data provided')
|
||||
end
|
||||
for req_key, desc in pairs(ENTROPIC_REQUIRED) do
|
||||
if not data[req_key] then
|
||||
error(string.format('terumet.register_entropic_node: data is missing required key %s: %s', req_key, desc))
|
||||
end
|
||||
end
|
||||
terumet.options.heater.entropy.EFFECTS[data.node] = {hu_per_s=data.hu_per_s, extract_time=data.extract_time, change_to=data.change_to}
|
||||
end
|
||||
|
||||
|
||||
local STANDARD_INV_LISTS = {'in', 'out', 'fuel', 'upgrade'}
|
||||
local EXTERNAL_MACHINES = {}
|
||||
local MACHINE_REQUIRED = {
|
||||
name='[string] Name of machine',
|
||||
node_tiles='[minetest tiles definition] Tiles for machine node',
|
||||
heat_max='[integer] Base maximum heat units that can be stored by machine',
|
||||
input_slots='[integer, 0-4 expected] Size of input inventory',
|
||||
output_slots='[integer, 0-4 expected] Size of output inventory',
|
||||
has_fuel_slot='[boolean] Whether machine has direct fuel slot',
|
||||
upgrade_slots='[integer, 0-6 expected] Size of upgrade inventory',
|
||||
tick_time='[float] Time in seconds between machine ticks',
|
||||
tick_function='[fn(machine_state, dt) -> boolean] Function called when machine ticks. Return true to tick again in tick_time seconds.'
|
||||
}
|
||||
-- optional keys:
|
||||
-- heat_provider: [boolean] true if machine generates/provides heat to adjacent machines
|
||||
-- heat_transfer: [integer] Maximum amount of heat machine can send in 1 tick
|
||||
-- node_name: [string] name to give machine's node. if not provided, uses same as 'name'
|
||||
-- node_param2: [string] param2 to give machine's node (same as minetest's nodedef param2 setting: facedir/none/etc. )
|
||||
-- custom_init: [fn(pos, meta, inv) -> nil] custom initialization for setting inventories or other metadata of a new machine
|
||||
-- custom_write: [fn(machine_state)] function to call when saving machine state to metadata
|
||||
-- custom_read: [fn(machine_state)] function to call when reading machine state from metadata
|
||||
-- -- machine formspec options --
|
||||
-- <basic>
|
||||
-- machinefs_theme: [string] definition of background/listcolors for machine's formspec
|
||||
-- machinefs_func: [fn(machine_state) -> string] custom function that returns formspec definition for main area above inventory in interface
|
||||
-- -- <OR advanced> --
|
||||
-- custom_fsdef: [fsdef table] entire customized formspec definition table for machine to use, see terumet/machine/machine.lua:build_fs for more information
|
||||
-- [IMPORTANT] => using custom_fsdef completely overrides use of machinefs_* funcs and default formspec so everything must be defined
|
||||
|
||||
function terumet.register_heat_machine( id, data )
|
||||
if not data then
|
||||
error('terumet.register_heat_machine: no data provided')
|
||||
end
|
||||
for req_key, desc in pairs(MACHINE_REQUIRED) do
|
||||
if not data[req_key] then
|
||||
error(string.format('terumet.register_heat_machine: data is missing required key %s: %s', req_key, desc))
|
||||
end
|
||||
end
|
||||
|
||||
local machine_tm_class = {
|
||||
name = data.name,
|
||||
timer = data.tick_time,
|
||||
fsdef = data.custom_fsdef or {
|
||||
control_buttons = {
|
||||
terumet.machine.buttondefs.HEAT_XFER_TOGGLE,
|
||||
},
|
||||
machine = data.machinefs_func or terumet.NO_FUNCTION,
|
||||
input = {data.input_slots > 0},
|
||||
output = {data.output_slots > 0},
|
||||
fuel_slot = {data.fuel_slot},
|
||||
theme = data.machinefs_theme,
|
||||
},
|
||||
default_heat_xfer = (data.heat_provider and terumet.machine.HEAT_XFER_MODE.PROVIDE_ONLY) or terumet.machine.HEAT_XFER_MODE.ACCEPT,
|
||||
get_drop_contents = function(machine)
|
||||
local drops = {}
|
||||
for _,std_list in ipairs(STANDARD_INV_LISTS) do
|
||||
default.get_inventory_drops(machine.pos, std_list, drops)
|
||||
end
|
||||
return drops
|
||||
end
|
||||
}
|
||||
|
||||
local node_def = terumet.machine.nodedef{
|
||||
description = data.node_name or data.name,
|
||||
tiles = data.node_tiles,
|
||||
param2 = data.node_param2,
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
if data.upgrade_slots > 0 then inv:set_size('upgrade', data.upgrade_slots) end
|
||||
if data.input_slots > 0 then inv:set_size('in', data.input_slots) end
|
||||
if data.output_slots > 0 then inv:set_size('out', data.output_slots) end
|
||||
if data.has_fuel_slot then inv:set_size('fuel', 1) end
|
||||
if data.custom_init then data.custom_init(pos, meta, inv) end
|
||||
local init = {
|
||||
class = machine_tm_class,
|
||||
state = 0,
|
||||
state_time = 0,
|
||||
heat_level = 0,
|
||||
max_heat = data.heat_max,
|
||||
status_text = 'New',
|
||||
inv = inv,
|
||||
meta = meta,
|
||||
pos = pos,
|
||||
}
|
||||
terumet.machine.write_state(pos, init)
|
||||
terumet.machine.set_timer(init)
|
||||
end,
|
||||
on_timer = function(pos, dt)
|
||||
local machine = terumet.machine.tick_read_state(pos)
|
||||
local re_tick = false
|
||||
if not terumet.machine.check_overheat(machine, data.heat_max) then
|
||||
re_tick = data.tick_function(machine, dt)
|
||||
if machine.heat_xfer_mode == terumet.machine.HEAT_XFER_MODE.PROVIDE_ONLY then
|
||||
terumet.machine.push_heat_adjacent(machine, data.heat_transfer or 50)
|
||||
end
|
||||
|
||||
if data.has_fuel_slot then
|
||||
terumet.machine.process_fuel(machine)
|
||||
re_tick = not machine.need_heat
|
||||
end
|
||||
end
|
||||
-- write status back to meta
|
||||
terumet.machine.write_state(pos, machine)
|
||||
return re_tick
|
||||
end,
|
||||
_terumach_class = machine_tm_class
|
||||
}
|
||||
|
||||
minetest.register_node( id, node_def )
|
||||
|
||||
EXTERNAL_MACHINES[id] = data
|
||||
end
|
||||
52
mods/terumet/interop/tubelib.lua
Normal file
52
mods/terumet/interop/tubelib.lua
Normal file
@@ -0,0 +1,52 @@
|
||||
local tube = 'tubelib:tubeS'
|
||||
if tubelib.version < 2.0 then
|
||||
tube = 'tubelib:tube1'
|
||||
end
|
||||
|
||||
terumet.register_machine_upgrade('tubelib', 'Tube Support Upgrade', {terumet.id('item_upg_base'), tube}, nil, 'simple', 'Allows machine to interface with tubelib tubes')
|
||||
|
||||
local machine_check = function(machine, player_name)
|
||||
return machine and terumet.machine.has_upgrade(machine, 'tubelib')
|
||||
---terumet.machine.has_auth(machine, player_name)
|
||||
end
|
||||
|
||||
local PUSH_FUNC = function(pos, side, item, player_name)
|
||||
local machine = terumet.machine.readonly_state(pos)
|
||||
if machine_check(machine) then
|
||||
local result = tubelib.put_item(machine.meta, 'in', item)
|
||||
if result then machine.class.on_inventory_change(machine) end
|
||||
return result
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local TUBELIB_MACHINE_DEF = {
|
||||
on_pull_item = function(pos, side, player_name)
|
||||
local machine = terumet.machine.readonly_state(pos)
|
||||
if machine_check(machine) then
|
||||
return tubelib.get_item(machine.meta, 'out')
|
||||
end
|
||||
return nil
|
||||
end,
|
||||
on_push_item = PUSH_FUNC,
|
||||
on_unpull_item = PUSH_FUNC
|
||||
}
|
||||
|
||||
terumet.machine.register_on_place(function (pos, machine, placer)
|
||||
tubelib.add_node(pos, machine.class.name)
|
||||
end)
|
||||
|
||||
terumet.machine.register_on_remove(function (pos, machine)
|
||||
tubelib.remove_node(pos)
|
||||
end)
|
||||
|
||||
tubelib.register_node(terumet.id('mach_asmelt'), {terumet.id('mach_asmelt_lit')}, TUBELIB_MACHINE_DEF)
|
||||
tubelib.register_node(terumet.id('mach_htfurn'), {terumet.id('mach_htfurn_lit')}, TUBELIB_MACHINE_DEF)
|
||||
tubelib.register_node(terumet.id('mach_lavam'), {terumet.id('mach_lavam_lit')}, TUBELIB_MACHINE_DEF)
|
||||
tubelib.register_node(terumet.id('mach_htr_furnace'), {terumet.id('mach_htr_furnace_lit')}, TUBELIB_MACHINE_DEF)
|
||||
tubelib.register_node(terumet.id('mach_crusher'), {terumet.id('mach_crusher_lit')}, TUBELIB_MACHINE_DEF)
|
||||
--oops: mese garden has no upgrade slots... consider adding it if support for other upgrades is added in future
|
||||
--tubelib.register_node(terumet.id('mach_meseg'), terumet.EMPTY, TUBELIB_MACHINE_DEF)
|
||||
tubelib.register_node(terumet.id('mach_repm'), terumet.EMPTY, TUBELIB_MACHINE_DEF)
|
||||
tubelib.register_node(terumet.id('mach_vulcan'), terumet.EMPTY, TUBELIB_MACHINE_DEF)
|
||||
|
||||
163
mods/terumet/interop/unified_inventory.lua
Normal file
163
mods/terumet/interop/unified_inventory.lua
Normal file
@@ -0,0 +1,163 @@
|
||||
local function add_terumet_recipes()
|
||||
-- add each defined alloy recipe to UnInv
|
||||
for _, recipe in pairs(terumet.options.smelter.recipes) do
|
||||
local listed = {}
|
||||
for i=1,#recipe.input do listed[#listed+1] = recipe.input[i] end
|
||||
if recipe.flux > 0 then
|
||||
listed[#listed+1] = terumet.id('uninv_flux_req', recipe.flux)
|
||||
end
|
||||
listed[#listed+1] = terumet.id('uninv_time_req', math.ceil(recipe.time))
|
||||
unified_inventory.register_craft{
|
||||
type = 'terumet_alloy',
|
||||
output = recipe.result,
|
||||
items = listed
|
||||
}
|
||||
end
|
||||
|
||||
-- add each defined vacuum oven recipe (1 entry for each output)
|
||||
for _, recipe in ipairs(terumet.options.vac_oven.recipes) do
|
||||
local time = terumet.id('uninv_time_req', math.ceil(recipe.time))
|
||||
for _, output in ipairs(recipe.results) do
|
||||
unified_inventory.register_craft{
|
||||
type = 'terumet_vacoven',
|
||||
output = output,
|
||||
items = {recipe.input, time}
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
-- add each defined flux source to UnInv
|
||||
for source, details in pairs(terumet.options.smelter.FLUX_ITEMS) do
|
||||
unified_inventory.register_craft{
|
||||
type = 'terumet_alloy',
|
||||
output = terumet.id('uninv_flux_req'),
|
||||
items = {source, terumet.id('uninv_time_req', math.ceil(details.time))}
|
||||
}
|
||||
end
|
||||
|
||||
-- add each crusher recipe to UnInv
|
||||
for source, result in pairs(terumet.options.crusher.recipes) do
|
||||
unified_inventory.register_craft{
|
||||
type = 'terumet_crush',
|
||||
output = result,
|
||||
items = {source}
|
||||
}
|
||||
end
|
||||
|
||||
-- add each repair material to UnInv
|
||||
for id, repmatval in pairs(terumet.options.repm.repair_mats) do
|
||||
unified_inventory.register_craft{
|
||||
type = 'terumet_repmat',
|
||||
output = terumet.id('uninv_repmat', repmatval),
|
||||
items = {id}
|
||||
}
|
||||
end
|
||||
|
||||
-- add each repairable tool to UnInv
|
||||
for id, rmreq in pairs(terumet.options.repm.repairable) do
|
||||
unified_inventory.register_craft{
|
||||
type = 'terumet_repair',
|
||||
output = id,
|
||||
items = {id, terumet.id('uninv_repmat', rmreq)}
|
||||
}
|
||||
end
|
||||
|
||||
-- add each crystal vulcanizer recipe to UnInv
|
||||
for source, result in pairs(terumet.options.vulcan.recipes) do
|
||||
--minetest.log(string.format('%s => %s x %s', source or 'NIL', result[1] or 'NIL', result[2] or 'NIL'))
|
||||
unified_inventory.register_craft{
|
||||
type = 'terumet_vulcan',
|
||||
output = result[1] .. ' ' .. result[2],
|
||||
items = {source}
|
||||
}
|
||||
end
|
||||
|
||||
-- add each valid ore for ore saw to UnInv
|
||||
for node, _ in pairs(terumet.options.ore_saw.VALID_ORES) do
|
||||
unified_inventory.register_craft{
|
||||
type = 'terumet_ore_saw',
|
||||
output = node,
|
||||
items = {node}
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
-- dummy item to display amount of flux needed to alloy
|
||||
minetest.register_craftitem( terumet.id('uninv_flux_req'), {
|
||||
description = "terumetal flux (in smelter tank)",
|
||||
inventory_image = terumet.tex('uninv_flux_req'),
|
||||
groups={not_in_creative_inventory=1}
|
||||
})
|
||||
|
||||
-- dummy item to display amount of time needed to alloy
|
||||
minetest.register_craftitem( terumet.id('uninv_time_req'), {
|
||||
description = "time (seconds)",
|
||||
inventory_image = terumet.tex('uninv_time_req'),
|
||||
groups={not_in_creative_inventory=1}
|
||||
})
|
||||
|
||||
-- dummy item to display amount of repair material
|
||||
minetest.register_craftitem( terumet.id('uninv_repmat'), {
|
||||
description = "repair material value",
|
||||
inventory_image = terumet.tex('uninv_repmat'),
|
||||
groups={not_in_creative_inventory=1}
|
||||
})
|
||||
|
||||
-- register terumetal alloying with UnInv
|
||||
unified_inventory.register_craft_type( 'terumet_alloy', {
|
||||
description = 'Terumetal Alloy Smelting',
|
||||
icon = 'terumet_asmelt_front_lit.png',
|
||||
width=3,
|
||||
height=2,
|
||||
})
|
||||
|
||||
-- register crushing with UnInv
|
||||
unified_inventory.register_craft_type( 'terumet_crush', {
|
||||
description = 'Expansion Crusher',
|
||||
icon = 'terumet_crush_front_lit.png',
|
||||
width=1,
|
||||
height=1,
|
||||
})
|
||||
|
||||
-- register repair materials with UnInv
|
||||
unified_inventory.register_craft_type( 'terumet_repmat', {
|
||||
description = 'Equipment Reformer\n(material)',
|
||||
icon = 'terumet_repm_front.png',
|
||||
width=1,
|
||||
height=1,
|
||||
})
|
||||
|
||||
-- register tool repair with UnInv
|
||||
unified_inventory.register_craft_type( 'terumet_repair', {
|
||||
description = 'Equipment Reformer\n(for 100% wear)',
|
||||
icon = 'terumet_repm_front.png',
|
||||
width=2,
|
||||
height=1,
|
||||
})
|
||||
|
||||
-- register crystal vulcanizing with UnInv
|
||||
unified_inventory.register_craft_type( 'terumet_vulcan', {
|
||||
description = 'Crystal Vulcanizer',
|
||||
icon = 'terumet_vulcan_front.png',
|
||||
width=1,
|
||||
height=1,
|
||||
})
|
||||
|
||||
-- register ore saw gathering
|
||||
unified_inventory.register_craft_type( 'terumet_ore_saw', {
|
||||
description = 'Ore-cutting Saw',
|
||||
icon = 'terumet_tool_ore_saw.png^[transformFX',
|
||||
width=1,
|
||||
height=1,
|
||||
})
|
||||
|
||||
-- register vacuum oven with UnInv
|
||||
unified_inventory.register_craft_type( 'terumet_vacoven', {
|
||||
description = 'Vacuum Oven',
|
||||
icon = 'terumet_vacoven_front.png',
|
||||
width=3,
|
||||
height=2,
|
||||
})
|
||||
|
||||
-- call after all mods are loaded to catch new submod recipes/changes
|
||||
minetest.after(0.01, function() add_terumet_recipes() end)
|
||||
Reference in New Issue
Block a user