ind. furnace menu improved

basalt glass reworked
This commit is contained in:
Joachim Stolberg 2019-06-21 17:45:15 +02:00
parent 1c4bd6eed2
commit aa639fb531
14 changed files with 232 additions and 37 deletions

View File

@ -74,6 +74,12 @@ function techage.index(list, x)
return nil
end
function techage.add_to_set(set, x)
if not techage.index(set, x) then
table.insert(set, x)
end
end
function techage.get_node_lvm(pos)
local node = minetest.get_node_or_nil(pos)
if node then

View File

@ -21,12 +21,42 @@ local M = minetest.get_meta
local MP = minetest.get_modpath("techage")
local I,_ = dofile(MP.."/intllib.lua")
local range = techage.range
local Recipes = {} -- registered recipes
local Ingredients = {}
local KeyList = {} -- index to Recipes key translation
local NumRecipes = 0
techage.furnace = {}
-- Return a list with all outputs of the given list of ingredients
local function get_recipes(ingr)
if #ingr > 0 then
local tbl = {}
for _,item in ipairs(ingr) do
if Ingredients[item] then
for _,output in ipairs(Ingredients[item]) do
tbl[#tbl+1] = output
end
end
end
return tbl
else
return KeyList
end
end
function techage.furnace.get_ingredients(pos)
local inv = M(pos):get_inventory()
local tbl = {}
for _,stack in ipairs(inv:get_list('src')) do
if stack:get_name() ~= "" then
tbl[#tbl+1] = stack:get_name()
end
end
return tbl
end
-- move recipe src items to output inventory
local function process(inv, recipe)
local res
@ -75,13 +105,18 @@ function techage.furnace.smelting(pos, mem, elapsed)
return techage.STANDBY
end
function techage.furnace.get_output(idx)
local key = KeyList[idx] or KeyList[1]
function techage.furnace.get_output(ingr, idx)
local tbl = get_recipes(ingr)
idx = range(idx, 1, #tbl)
local key = tbl[idx] or tbl[1]
if Recipes[key] then
return Recipes[key].output
end
return Recipes[KeyList[1]].output
end
function techage.furnace.get_num_recipes()
return NumRecipes
function techage.furnace.get_num_recipes(ingr)
return #get_recipes(ingr)
end
function techage.furnace.reset_cooking(mem)
@ -108,7 +143,13 @@ function techage.furnace.register_recipe(recipe)
number = number,
time = math.max((recipe.time or 3) * number, 2),
}
NumRecipes = NumRecipes + 1
for _,item in ipairs(recipe.recipe) do
if Ingredients[item] then
techage.add_to_set(Ingredients[item], output)
else
Ingredients[item] = {output}
end
end
if minetest.global_exists("unified_inventory") then
recipe.items = recipe.recipe

View File

@ -32,10 +32,15 @@ local smelting = techage.furnace.smelting
local get_output = techage.furnace.get_output
local num_recipes = techage.furnace.get_num_recipes
local reset_cooking = techage.furnace.reset_cooking
local get_ingredients = techage.furnace.get_ingredients
local range = techage.range
local function formspec(self, pos, mem)
local idx = mem.recipe_idx or 1
local num, output = num_recipes(), get_output(idx)
local ingr = get_ingredients(pos)
local num = num_recipes(ingr)
mem.recipe_idx = range(mem.recipe_idx or 1, 1, num)
local idx = mem.recipe_idx
local output = get_output(ingr, idx)
return "size[8,7.2]"..
default.gui_bg..
default.gui_bg_img..
@ -56,7 +61,7 @@ local function formspec(self, pos, mem)
"listring[current_player;main]"..
"listring[context;dst]" ..
"listring[current_player;main]"..
default.get_hotbar_bg(0, 4)
default.get_hotbar_bg(0, 3.5)
end
local function on_rightclick(pos, node, clicker)
@ -102,6 +107,7 @@ local function allow_metadata_inventory_put(pos, listname, index, stack, player)
return 0
end
if listname == "src" then
local mem = tubelib2.get_mem(pos)
CRD(pos).State:start_if_standby(pos)
return stack:get_count()
elseif listname == "dst" then
@ -123,6 +129,12 @@ local function allow_metadata_inventory_take(pos, listname, index, stack, player
return stack:get_count()
end
local function on_metadata_inventory(pos)
local mem = tubelib2.get_mem(pos)
local crd = CRD(pos)
M(pos):set_string("formspec", formspec(crd.State, pos, mem))
end
local function on_receive_fields(pos, formname, fields, player)
if minetest.is_protected(pos, player:get_player_name()) then
return
@ -130,11 +142,13 @@ local function on_receive_fields(pos, formname, fields, player)
local mem = tubelib2.get_mem(pos)
mem.recipe_idx = mem.recipe_idx or 1
if fields.next == ">>" then
mem.recipe_idx = math.min(mem.recipe_idx + 1, num_recipes())
local ingr = get_ingredients(pos)
mem.recipe_idx = math.min(mem.recipe_idx + 1, num_recipes(ingr))
M(pos):set_string("formspec", formspec(CRD(pos).State, pos, mem))
reset_cooking(mem)
elseif fields.priv == "<<" then
mem.recipe_idx = math.max(mem.recipe_idx - 1, 1)
local ingr = get_ingredients(pos)
mem.recipe_idx = range(mem.recipe_idx - 1, 1, num_recipes(ingr))
M(pos):set_string("formspec", formspec(CRD(pos).State, pos, mem))
reset_cooking(mem)
end
@ -228,6 +242,9 @@ local _, node_name_ta3, _ =
allow_metadata_inventory_put = allow_metadata_inventory_put,
allow_metadata_inventory_move = allow_metadata_inventory_move,
allow_metadata_inventory_take = allow_metadata_inventory_take,
on_metadata_inventory_put = on_metadata_inventory,
on_metadata_inventory_take = on_metadata_inventory,
on_metadata_inventory_move = on_metadata_inventory,
groups = {choppy=2, cracky=2, crumbly=2},
sounds = default.node_sound_wood_defaults(),
num_items = {0,1,1,1},

View File

@ -54,3 +54,69 @@ minetest.after(1, function()
end
end
end)
techage.furnace.register_recipe({
output = "techage:basalt_glass2",
recipe = {
"techage:basalt_gravel",
"techage:basalt_gravel",
"techage:basalt_gravel",
"techage:basalt_gravel",
},
time = 4,
})
techage.furnace.register_recipe({
output = "techage:basalt_glass",
recipe = {
"techage:sieved_basalt_gravel",
"techage:sieved_basalt_gravel",
"techage:sieved_basalt_gravel",
"techage:sieved_basalt_gravel",
},
time = 4,
})
techage.furnace.register_recipe({
output = "techage:basalt_glass_thin2 4",
recipe = {
"techage:basalt_gravel",
"techage:basalt_gravel",
"techage:basalt_gravel",
"techage:basalt_gravel",
},
time = 4,
})
techage.furnace.register_recipe({
output = "techage:basalt_glass_thin 4",
recipe = {
"techage:sieved_basalt_gravel",
"techage:sieved_basalt_gravel",
"techage:sieved_basalt_gravel",
"techage:sieved_basalt_gravel",
},
time = 4,
})
techage.furnace.register_recipe({
output = "techage:basalt_glass_thin_xl2 2",
recipe = {
"techage:basalt_gravel",
"techage:basalt_gravel",
"techage:basalt_gravel",
"techage:basalt_gravel",
},
time = 4,
})
techage.furnace.register_recipe({
output = "techage:basalt_glass_thin_xl 2",
recipe = {
"techage:sieved_basalt_gravel",
"techage:sieved_basalt_gravel",
"techage:sieved_basalt_gravel",
"techage:sieved_basalt_gravel",
},
time = 4,
})

View File

@ -40,7 +40,7 @@ local function handler(player_name, node, itemstack, digparams)
end
end
end
if node.name == "techage:basalt_stone" then
if node.name == "techage:basalt_stone" or node.name == "techage:basalt_cobble" then
node.name = "techage:basalt_gravel"
else
node.name = "default:gravel"

View File

@ -84,6 +84,95 @@ minetest.register_node("techage:basalt_glass", {
sounds = default.node_sound_glass_defaults(),
})
minetest.register_node("techage:basalt_glass2", {
description = "Basalt Glass 2",
drawtype = "glasslike_framed_optional",
tiles = {"techage_basalt_glass2.png"},
use_texture_alpha = true,
paramtype = "light",
paramtype2 = "glasslikeliquidlevel",
sunlight_propagates = true,
is_ground_content = false,
groups = {cracky = 3, oddly_breakable_by_hand = 3},
sounds = default.node_sound_glass_defaults(),
})
minetest.register_node("techage:basalt_glass_thin", {
description = "Basalt Glass Thin",
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {
{-8/16, -8/16, -1/16, 8/16, 8/16, 1/16},
},
},
tiles = {"techage_basalt_glass.png"},
use_texture_alpha = true,
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
is_ground_content = false,
groups = {cracky = 3, oddly_breakable_by_hand = 3},
sounds = default.node_sound_glass_defaults(),
})
minetest.register_node("techage:basalt_glass_thin2", {
description = "Basalt Glass Thin 2",
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {
{-8/16, -8/16, -1/16, 8/16, 8/16, 1/16},
},
},
tiles = {"techage_basalt_glass2.png"},
use_texture_alpha = true,
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
is_ground_content = false,
groups = {cracky = 3, oddly_breakable_by_hand = 3},
sounds = default.node_sound_glass_defaults(),
})
minetest.register_node("techage:basalt_glass_thin_xl", {
description = "Basalt Glass Thin XL",
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {
{-8/16, -8/16, -1/16, 16/16, 16/16, 1/16},
},
},
tiles = {"techage_basalt_glass.png"},
use_texture_alpha = true,
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
is_ground_content = false,
groups = {cracky = 3, oddly_breakable_by_hand = 3},
sounds = default.node_sound_glass_defaults(),
})
minetest.register_node("techage:basalt_glass_thin_xl2", {
description = "Basalt Glass Thin XL 2",
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {
{-8/16, -8/16, -1/16, 16/16, 16/16, 1/16},
},
},
tiles = {"techage_basalt_glass2.png"},
use_texture_alpha = true,
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
is_ground_content = false,
groups = {cracky = 3, oddly_breakable_by_hand = 3},
sounds = default.node_sound_glass_defaults(),
})
stairs.register_stair_and_slab(
"basalt_stone",
"techage:basalt_stone",
@ -128,23 +217,6 @@ stairs.register_stair_and_slab(
false
)
stairs.register_stair_and_slab(
"basalt_glass",
"techage:basalt_glass",
{cracky = 3, oddly_breakable_by_hand = 3},
{"techage_basalt_glass.png"},
"Basalt Glass Stair",
"Basalt Glass Slab",
default.node_sound_glass_defaults(),
false
)
minetest.register_craft({
type = "cooking",
output = "techage:basalt_stone",
recipe = "techage:basalt_cobble",
})
minetest.register_craft({
output = "techage:basalt_stone_brick 4",
recipe = {
@ -153,13 +225,6 @@ minetest.register_craft({
}
})
minetest.register_craft({
type = "cooking",
output = "techage:basalt_glass",
recipe = "techage:sieved_basalt_gravel",
cooktime = 4,
})
minetest.register_craft({
output = "techage:basalt_stone_block 9",
recipe = {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 279 B

After

Width:  |  Height:  |  Size: 215 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 491 B

After

Width:  |  Height:  |  Size: 403 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 427 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 403 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 809 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 387 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.2 KiB

After

Width:  |  Height:  |  Size: 789 B