diff --git a/basis/lib.lua b/basis/lib.lua index a988728..2a2bc89 100644 --- a/basis/lib.lua +++ b/basis/lib.lua @@ -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 diff --git a/furnace/cooking.lua b/furnace/cooking.lua index ee82e0c..88cc205 100644 --- a/furnace/cooking.lua +++ b/furnace/cooking.lua @@ -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] - return Recipes[key].output +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 diff --git a/furnace/furnace_top.lua b/furnace/furnace_top.lua index a00b439..5f62a25 100644 --- a/furnace/furnace_top.lua +++ b/furnace/furnace_top.lua @@ -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}, diff --git a/furnace/recipes.lua b/furnace/recipes.lua index a568153..709d244 100644 --- a/furnace/recipes.lua +++ b/furnace/recipes.lua @@ -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, +}) diff --git a/iron_age/hammer.lua b/iron_age/hammer.lua index ab2168d..f8b57fd 100644 --- a/iron_age/hammer.lua +++ b/iron_age/hammer.lua @@ -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" diff --git a/nodes/basalt.lua b/nodes/basalt.lua index 3d62524..bd87762 100644 --- a/nodes/basalt.lua +++ b/nodes/basalt.lua @@ -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 = { diff --git a/textures/techage_appl_electric_gen_side.png b/textures/techage_appl_electric_gen_side.png index b021d62..c770b05 100644 Binary files a/textures/techage_appl_electric_gen_side.png and b/textures/techage_appl_electric_gen_side.png differ diff --git a/textures/techage_basalt_glass.png b/textures/techage_basalt_glass.png index 7e30d29..099c20e 100644 Binary files a/textures/techage_basalt_glass.png and b/textures/techage_basalt_glass.png differ diff --git a/textures/techage_basalt_glass2.png b/textures/techage_basalt_glass2.png new file mode 100644 index 0000000..f22db4a Binary files /dev/null and b/textures/techage_basalt_glass2.png differ diff --git a/textures/techage_basalt_glass3.png b/textures/techage_basalt_glass3.png new file mode 100644 index 0000000..099c20e Binary files /dev/null and b/textures/techage_basalt_glass3.png differ diff --git a/textures/techage_constr_plan.png b/textures/techage_constr_plan.png index e9b1429..6f5a626 100644 Binary files a/textures/techage_constr_plan.png and b/textures/techage_constr_plan.png differ diff --git a/textures/techage_constr_plan_inv.png b/textures/techage_constr_plan_inv.png index 066e313..d5859a5 100644 Binary files a/textures/techage_constr_plan_inv.png and b/textures/techage_constr_plan_inv.png differ diff --git a/textures/techage_form_gear_fg.png b/textures/techage_form_gear_fg.png deleted file mode 100644 index b7a762a..0000000 Binary files a/textures/techage_form_gear_fg.png and /dev/null differ diff --git a/textures/techage_industriallamp_inv3.png b/textures/techage_industriallamp_inv3.png index d387935..f3af873 100644 Binary files a/textures/techage_industriallamp_inv3.png and b/textures/techage_industriallamp_inv3.png differ