diff --git a/elepower_dynamics/crafting.lua b/elepower_dynamics/crafting.lua index 835424a..80d9ffe 100644 --- a/elepower_dynamics/crafting.lua +++ b/elepower_dynamics/crafting.lua @@ -129,8 +129,8 @@ minetest.register_craft({ minetest.register_craft({ output = "elepower_dynamics:fluid_transfer_node", recipe = { - {"group:stone", "elepower_dynamics:fluid_duct", "group:stone"}, - {"elepower_dynamics:steel_gear", "elepower_dynamics:servo_valve", "elepower_dynamics:steel_gear"}, + {"group:stone", "elepower_dynamics:control_circuit", "group:stone"}, + {"elepower_dynamics:viridisium_gear", "elepower_dynamics:servo_valve", "elepower_dynamics:viridisium_gear"}, {"group:stone", "elepower_dynamics:fluid_duct", "group:stone"}, } }) @@ -158,6 +158,15 @@ minetest.register_craft({ } }) +minetest.register_craft({ + output = "elepower_dynamics:wound_silver_coil", + recipe = { + {"", "moreores:silver_ingot", ""}, + {"moreores:silver_ingot", "elepower_dynamics:iron_ingot", "moreores:silver_ingot"}, + {"", "moreores:silver_ingot", ""} + } +}) + minetest.register_craft({ output = "elepower_dynamics:copper_wire", recipe = { @@ -183,6 +192,42 @@ minetest.register_craft({ } }) +minetest.register_craft({ + output = "elepower_dynamics:chip", + recipe = { + {"homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting"}, + {"default:mese_crystal", "dye:black", "default:mese_crystal"}, + {"default:copper_ingot", "moreores:silver_ingot", "default:copper_ingot"}, + } +}) + +minetest.register_craft({ + output = "elepower_dynamics:capacitor", + recipe = { + {"homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting"}, + {"moreores:silver_ingot", "default:mese_crystal", "moreores:silver_ingot"}, + {"default:copper_ingot", "dye:violet", "default:copper_ingot"}, + } +}) + +minetest.register_craft({ + output = "elepower_dynamics:integrated_circuit", + recipe = { + {"elepower_dynamics:chip", "elepower_dynamics:chip", "elepower_dynamics:chip"}, + {"elepower_dynamics:capacitor", "elepower_dynamics:pcb", "elepower_dynamics:capacitor"}, + {"default:copper_ingot", "default:mese_crystal", "default:gold_ingot"}, + } +}) + +minetest.register_craft({ + output = "elepower_dynamics:control_circuit", + recipe = { + {"elepower_dynamics:chip", "elepower_dynamics:chip", "elepower_dynamics:chip"}, + {"elepower_dynamics:capacitor", "elepower_dynamics:integrated_circuit", "elepower_dynamics:capacitor"}, + {"default:gold_ingot", "elepower_dynamics:viridisium_ingot", "default:gold_ingot"}, + } +}) + -------------- -- Smelting -- -------------- @@ -207,9 +252,9 @@ minetest.register_craft({ minetest.register_craft({ type = "cooking", - output = "default:steel_ingot", - recipe = "elepower_dynamics:iron_ingot", - cooktime = 20 + output = "elepower_dynamics:viridisium_ingot", + recipe = "elepower_dynamics:viridisium_lump", + cooktime = 10, }) ----------- diff --git a/elepower_dynamics/craftitems.lua b/elepower_dynamics/craftitems.lua index 83ea74b..37a67ac 100644 --- a/elepower_dynamics/craftitems.lua +++ b/elepower_dynamics/craftitems.lua @@ -35,6 +35,12 @@ minetest.register_craftitem("elepower_dynamics:electrum_ingot", { groups = {electrum = 1, ingot = 1} }) +minetest.register_craftitem("elepower_dynamics:viridisium_ingot", { + description = "Viridisium Ingot", + inventory_image = "elepower_viridisium_ingot.png", + groups = {viridisium = 1, ingot = 1} +}) + -- Lumps minetest.register_craftitem("elepower_dynamics:lead_lump", { @@ -49,7 +55,13 @@ minetest.register_craftitem("elepower_dynamics:nickel_lump", { groups = {nickel = 1, lump = 1} }) --- Other +minetest.register_craftitem("elepower_dynamics:viridisium_lump", { + description = "Viridisium Lump", + inventory_image = "elepower_viridisium_lump.png", + groups = {viridisium = 1, lump = 1} +}) + +-- Special minetest.register_craftitem("elepower_dynamics:carbon_fiber", { description = "Carbon Fibers", @@ -63,30 +75,38 @@ minetest.register_craftitem("elepower_dynamics:carbon_sheet", { groups = {carbon_fiber_sheet = 1, sheet = 1} }) +minetest.register_craftitem("elepower_dynamics:tree_tap", { + description = "Steel Treetap", + inventory_image = "elepower_tree_tap.png", + groups = {treetap = 1, static_component = 1} +}) + +minetest.register_craftitem("elepower_dynamics:pcb", { + description = "Printed Circuit Board (PCB)", + inventory_image = "elepower_pcb.png", + groups = {pcb = 1, static_component = 1} +}) + +-- Electronics + minetest.register_craftitem("elepower_dynamics:wound_copper_coil", { description = "Wound Copper Coil", inventory_image = "elepower_copper_coil.png", groups = {copper = 1, coil = 1, component = 1} }) +minetest.register_craftitem("elepower_dynamics:wound_silver_coil", { + description = "Wound Silver Coil", + inventory_image = "elepower_silver_coil.png", + groups = {silver = 1, coil = 1, component = 1} +}) + minetest.register_craftitem("elepower_dynamics:copper_wire", { description = "Copper Wire", inventory_image = "elepower_copper_wire.png", groups = {copper = 1, wire = 1, component = 1} }) -minetest.register_craftitem("elepower_dynamics:servo_valve", { - description = "Servo Valve", - inventory_image = "elepower_servo_valve.png", - groups = {servo_valve = 1, component = 1} -}) - -minetest.register_craftitem("elepower_dynamics:tree_tap", { - description = "Steel Treetap", - inventory_image = "elepower_tree_tap.png", - groups = {treetap = 1, component = 1} -}) - minetest.register_craftitem("elepower_dynamics:induction_coil", { description = "Induction Coil", inventory_image = "elepower_induction_coil.png", @@ -99,6 +119,38 @@ minetest.register_craftitem("elepower_dynamics:induction_coil_advanced", { groups = {induction_coil = 1, component = 1} }) +minetest.register_craftitem("elepower_dynamics:chip", { + description = "Chip", + inventory_image = "elepower_chip.png", + groups = {ic = 2, component = 1} +}) + +minetest.register_craftitem("elepower_dynamics:capacitor", { + description = "Capacitor", + inventory_image = "elepower_capacitor.png", + groups = {capacitor = 2, component = 1} +}) + +-- Assembled Components + +minetest.register_craftitem("elepower_dynamics:servo_valve", { + description = "Servo Valve", + inventory_image = "elepower_servo_valve.png", + groups = {servo_valve = 1, assembled_component = 1} +}) + +minetest.register_craftitem("elepower_dynamics:integrated_circuit", { + description = "Integrated Circuit", + inventory_image = "elepower_ic.png", + groups = {ic = 1, assembled_component = 1} +}) + +minetest.register_craftitem("elepower_dynamics:control_circuit", { + description = "Integrated Control Circuit", + inventory_image = "elepower_ic_2.png", + groups = {ic = 2, assembled_component = 1, control_circuit = 1} +}) + --------------- -- Overrides -- --------------- diff --git a/elepower_dynamics/dusts.lua b/elepower_dynamics/dusts.lua index a3dbea5..d4c8b5b 100644 --- a/elepower_dynamics/dusts.lua +++ b/elepower_dynamics/dusts.lua @@ -100,6 +100,11 @@ elepd.register_dust("electrum", { color = "#ebeb90" }) +elepd.register_dust("viridisium", { + description = "Viridisium", + color = "#5b9751" +}) + elepd.register_dust("wood", { description = "Wood Shavings", force_description = true, diff --git a/elepower_dynamics/gears.lua b/elepower_dynamics/gears.lua index 4da3dec..069652c 100644 --- a/elepower_dynamics/gears.lua +++ b/elepower_dynamics/gears.lua @@ -95,3 +95,8 @@ elepd.register_gear("electrum", { description = "Electrum", color = "#ebeb90" }) + +elepd.register_gear("viridisium", { + description = "Viridisium", + color = "#5b9751" +}) diff --git a/elepower_dynamics/mod.conf b/elepower_dynamics/mod.conf index ff91a33..536550d 100644 --- a/elepower_dynamics/mod.conf +++ b/elepower_dynamics/mod.conf @@ -1,4 +1,4 @@ name = elepower_dynamics description = Elepower Dynamics. Conduits and materials! -depends = elepower_papi,elepower_fapi,default,fluid_tanks +depends = elepower_papi,elepower_fapi,default,fluid_tanks,dye optional_depends = moreores,pipeworks,homedecor diff --git a/elepower_dynamics/nodes.lua b/elepower_dynamics/nodes.lua index 3c56470..df7521b 100644 --- a/elepower_dynamics/nodes.lua +++ b/elepower_dynamics/nodes.lua @@ -23,6 +23,14 @@ minetest.register_node("elepower_dynamics:stone_with_nickel", { sounds = default.node_sound_stone_defaults(), }) +minetest.register_node("elepower_dynamics:stone_with_viridisium", { + description = "Viridisium Ore", + tiles = {"default_stone.png^elepower_mineral_viridisium.png"}, + groups = {cracky = 3}, + drop = 'elepower_dynamics:viridisium_lump', + sounds = default.node_sound_stone_defaults(), +}) + minetest.register_node("elepower_dynamics:particle_board", { description = "Particle Board", tiles = {"elepower_particle_board.png"}, diff --git a/elepower_dynamics/textures/elepower_capacitor.png b/elepower_dynamics/textures/elepower_capacitor.png new file mode 100644 index 0000000..499ddc4 Binary files /dev/null and b/elepower_dynamics/textures/elepower_capacitor.png differ diff --git a/elepower_dynamics/textures/elepower_chip.png b/elepower_dynamics/textures/elepower_chip.png new file mode 100644 index 0000000..dd046c4 Binary files /dev/null and b/elepower_dynamics/textures/elepower_chip.png differ diff --git a/elepower_dynamics/textures/elepower_conduit.png b/elepower_dynamics/textures/elepower_conduit.png index 9000955..f20abf7 100644 Binary files a/elepower_dynamics/textures/elepower_conduit.png and b/elepower_dynamics/textures/elepower_conduit.png differ diff --git a/elepower_dynamics/textures/elepower_ic.png b/elepower_dynamics/textures/elepower_ic.png new file mode 100644 index 0000000..546bf30 Binary files /dev/null and b/elepower_dynamics/textures/elepower_ic.png differ diff --git a/elepower_dynamics/textures/elepower_ic_2.png b/elepower_dynamics/textures/elepower_ic_2.png new file mode 100644 index 0000000..6496f1a Binary files /dev/null and b/elepower_dynamics/textures/elepower_ic_2.png differ diff --git a/elepower_dynamics/textures/elepower_mineral_viridisium.png b/elepower_dynamics/textures/elepower_mineral_viridisium.png new file mode 100644 index 0000000..b1c21e0 Binary files /dev/null and b/elepower_dynamics/textures/elepower_mineral_viridisium.png differ diff --git a/elepower_dynamics/textures/elepower_pcb.png b/elepower_dynamics/textures/elepower_pcb.png new file mode 100644 index 0000000..4067d70 Binary files /dev/null and b/elepower_dynamics/textures/elepower_pcb.png differ diff --git a/elepower_dynamics/textures/elepower_silver_coil.png b/elepower_dynamics/textures/elepower_silver_coil.png new file mode 100644 index 0000000..51a002a Binary files /dev/null and b/elepower_dynamics/textures/elepower_silver_coil.png differ diff --git a/elepower_dynamics/textures/elepower_viridisium_ingot.png b/elepower_dynamics/textures/elepower_viridisium_ingot.png new file mode 100644 index 0000000..a83e70a Binary files /dev/null and b/elepower_dynamics/textures/elepower_viridisium_ingot.png differ diff --git a/elepower_dynamics/textures/elepower_viridisium_lump.png b/elepower_dynamics/textures/elepower_viridisium_lump.png new file mode 100644 index 0000000..488d151 Binary files /dev/null and b/elepower_dynamics/textures/elepower_viridisium_lump.png differ diff --git a/elepower_dynamics/worldgen.lua b/elepower_dynamics/worldgen.lua index 7e81e46..0f6dd41 100644 --- a/elepower_dynamics/worldgen.lua +++ b/elepower_dynamics/worldgen.lua @@ -61,3 +61,38 @@ minetest.register_ore({ y_max = -8096, y_min = -31000, }) + +-- Viridisium + +minetest.register_ore({ + ore_type = "scatter", + ore = "elepower_dynamics:stone_with_viridisium", + wherein = "default:stone", + clust_scarcity = 25 * 25 * 25, + clust_num_ores = 5, + clust_size = 3, + y_max = -1028, + y_min = -31000, +}) + +minetest.register_ore({ + ore_type = "scatter", + ore = "elepower_dynamics:stone_with_viridisium", + wherein = "default:stone", + clust_scarcity = 20 * 20 * 20, + clust_num_ores = 5, + clust_size = 3, + y_max = -8096, + y_min = -31000, +}) + +minetest.register_ore({ + ore_type = "scatter", + ore = "elepower_dynamics:stone_with_viridisium", + wherein = "default:stone", + clust_scarcity = 10 * 10 * 10, + clust_num_ores = 5, + clust_size = 3, + y_max = -12000, + y_min = -31000, +}) diff --git a/elepower_farming/crafting.lua b/elepower_farming/crafting.lua index 1a4017a..b52ba16 100644 --- a/elepower_farming/crafting.lua +++ b/elepower_farming/crafting.lua @@ -17,7 +17,7 @@ minetest.register_craft({ minetest.register_craft({ output = "elepower_farming:planter", recipe = { - {"homedecor:plastic_sheeting", "elepower_dynamics:copper_wire", "homedecor:plastic_sheeting"}, + {"elepower_dynamics:viridisium_ingot", "elepower_dynamics:control_circuit", "elepower_dynamics:viridisium_ingot"}, {"farming:hoe_steel", "elepower_farming:device_frame", "farming:hoe_steel"}, {"elepower_dynamics:wound_copper_coil", "elepower_dynamics:diamond_gear", "elepower_dynamics:wound_copper_coil"}, } @@ -27,7 +27,7 @@ minetest.register_craft({ minetest.register_craft({ output = "elepower_farming:harvester", recipe = { - {"homedecor:plastic_sheeting", "elepower_dynamics:copper_wire", "homedecor:plastic_sheeting"}, + {"elepower_dynamics:viridisium_ingot", "elepower_dynamics:control_circuit", "elepower_dynamics:viridisium_ingot"}, {"default:axe_steel", "elepower_farming:device_frame", "farming:hoe_steel"}, {"elepower_dynamics:wound_copper_coil", "elepower_dynamics:diamond_gear", "elepower_dynamics:wound_copper_coil"}, } @@ -37,7 +37,7 @@ minetest.register_craft({ minetest.register_craft({ output = "elepower_farming:tree_extractor", recipe = { - {"homedecor:plastic_sheeting", "bucket:bucket_empty", "homedecor:plastic_sheeting"}, + {"default:steel_ingot", "bucket:bucket_empty", "default:steel_ingot"}, {"elepower_dynamics:tree_tap", "elepower_farming:device_frame", "elepower_dynamics:tree_tap"}, {"elepower_dynamics:copper_gear", "elepower_dynamics:servo_valve", "elepower_dynamics:copper_gear"}, } diff --git a/elepower_machines/craft.lua b/elepower_machines/craft.lua index 158d93a..09a9705 100644 --- a/elepower_machines/craft.lua +++ b/elepower_machines/craft.lua @@ -56,9 +56,15 @@ function elepm.register_craft(craftdef) table.insert(elepm.craft[ctype], recipe) end +local no_recipe = { + time = 0, + new_input = {}, + output = {} +} + function elepm.get_recipe(type, inputs) if not elepm.craft[type] or not inputs then - return nil + return no_recipe end -- Minetest's cooking builtin type @@ -70,7 +76,7 @@ function elepm.get_recipe(type, inputs) }) if not result or result.time == 0 then - return nil + return no_recipe else return { time = result.time, @@ -81,7 +87,7 @@ function elepm.get_recipe(type, inputs) end -- Custom types - local result = nil + local result = no_recipe for _,recipe in ipairs(elepm.craft[type]) do local recip_match = true local inputs_full = {} diff --git a/elepower_machines/crafting.lua b/elepower_machines/crafting.lua index f34584b..99329f1 100644 --- a/elepower_machines/crafting.lua +++ b/elepower_machines/crafting.lua @@ -111,13 +111,25 @@ end) -- CRAFTING RECIPES -- --******************-- +-- Coal-fired Alloy Furnace +minetest.register_craft({ + output = "elepower_machines:coal_alloy_furnace", + recipe = { + {"default:brick", "default:brick", "default:brick"}, + {"default:furnace", "bucket:bucket_lava", "default:furnace"} + }, + replacements = { + {"bucket:bucket_lava", "bucket:bucket_empty"} + } +}) + -- Machine block minetest.register_craft({ output = "elepower_machines:machine_block", recipe = { - {"group:glass", "default:steel_ingot", "group:glass"}, + {"elepower_dynamics:viridisium_ingot", "default:steel_ingot", "elepower_dynamics:viridisium_ingot"}, {"default:steel_ingot", "default:mese_crystal", "default:steel_ingot"}, - {"group:glass", "default:steel_ingot", "group:glass"}, + {"elepower_dynamics:viridisium_ingot", "elepower_dynamics:tin_gear", "elepower_dynamics:viridisium_ingot"}, } }) @@ -135,9 +147,13 @@ minetest.register_craft({ minetest.register_craft({ output = "elepower_machines:alloy_furnace", recipe = { - {"", "elepower_dynamics:copper_wire", ""}, + {"", "elepower_dynamics:integrated_circuit", ""}, {"default:brick", "elepower_machines:machine_block", "default:brick"}, - {"default:furnace", "elepower_dynamics:wound_copper_coil", "default:furnace"}, + { + "elepower_dynamics:wound_copper_coil", + "elepower_machines:coal_alloy_furnace", + "elepower_dynamics:wound_copper_coil" + }, } }) @@ -145,7 +161,7 @@ minetest.register_craft({ minetest.register_craft({ output = "elepower_machines:furnace", recipe = { - {"", "elepower_dynamics:copper_wire", ""}, + {"", "elepower_dynamics:integrated_circuit", ""}, {"default:clay_brick", "elepower_machines:machine_block", "default:clay_brick"}, {"elepower_dynamics:wound_copper_coil", "default:furnace", "elepower_dynamics:wound_copper_coil"}, } @@ -155,7 +171,7 @@ minetest.register_craft({ minetest.register_craft({ output = "elepower_machines:pulverizer", recipe = { - {"", "elepower_dynamics:copper_wire", ""}, + {"", "elepower_dynamics:integrated_circuit", ""}, {"default:flint", "elepower_machines:machine_block", "default:flint"}, {"elepower_dynamics:wound_copper_coil", "elepower_dynamics:lead_gear", "elepower_dynamics:wound_copper_coil"}, } @@ -165,7 +181,7 @@ minetest.register_craft({ minetest.register_craft({ output = "elepower_machines:sawmill", recipe = { - {"", "elepower_dynamics:copper_wire", ""}, + {"", "elepower_dynamics:integrated_circuit", ""}, {"elepower_dynamics:steel_gear", "elepower_machines:machine_block", "elepower_dynamics:steel_gear"}, {"elepower_dynamics:lead_ingot", "elepower_dynamics:diamond_gear", "elepower_dynamics:lead_ingot"}, } @@ -175,7 +191,7 @@ minetest.register_craft({ minetest.register_craft({ output = "elepower_machines:power_cell_0", recipe = { - {"elepower_dynamics:lead_ingot", "elepower_dynamics:copper_wire", "elepower_dynamics:lead_ingot"}, + {"elepower_dynamics:lead_ingot", "elepower_dynamics:control_circuit", "elepower_dynamics:lead_ingot"}, {"elepower_dynamics:wound_copper_coil", "elepower_machines:machine_block", "elepower_dynamics:wound_copper_coil"}, {"elepower_dynamics:lead_ingot", "elepower_dynamics:diamond_gear", "elepower_dynamics:lead_ingot"}, } diff --git a/elepower_machines/formspec.lua b/elepower_machines/formspec.lua index 3c2723d..8ea5faa 100644 --- a/elepower_machines/formspec.lua +++ b/elepower_machines/formspec.lua @@ -65,3 +65,26 @@ function ele.formspec.get_storage_formspec(power) "listring[current_player;main]".. default.get_hotbar_bg(0, 4.25) end + +function elepm.get_coal_alloy_furnace_formspec(fuel_percent, item_percent) + return "size[8,8.5]".. + default.gui_bg.. + default.gui_bg_img.. + default.gui_slots.. + "list[context;src;2,0.5;2,1;]".. + "list[context;fuel;2.5,2.5;1,1;]".. + "image[2.5,1.5;1,1;default_furnace_fire_bg.png^[lowpart:".. + (100-fuel_percent)..":default_furnace_fire_fg.png]".. + "image[4,1.5;1,1;gui_furnace_arrow_bg.png^[lowpart:".. + (item_percent)..":gui_furnace_arrow_fg.png^[transformR270]".. + "list[context;dst;5,0.96;2,2;]".. + "list[current_player;main;0,4.25;8,1;]".. + "list[current_player;main;0,5.5;8,3;8]".. + "listring[context;dst]".. + "listring[current_player;main]".. + "listring[context;src]".. + "listring[current_player;main]".. + "listring[context;fuel]".. + "listring[current_player;main]".. + default.get_hotbar_bg(0, 4.25) +end diff --git a/elepower_machines/machines/bases/crafter.lua b/elepower_machines/machines/bases/crafter.lua index cc0f0fb..7faf8ac 100644 --- a/elepower_machines/machines/bases/crafter.lua +++ b/elepower_machines/machines/bases/crafter.lua @@ -36,14 +36,14 @@ function elepm.register_crafter(nodename, nodedef) local power_operation = false -- Determine if there is enough power for this action - if result and storage >= usage then + if result.time ~= 0 and storage >= usage then power_operation = true end - if not result or not power_operation then + if result.time == 0 or not power_operation then ele.helpers.swap_node(pos, machine_node) - if not result then + if result.time == 0 then meta:set_string("formspec", ele.formspec.get_crafter_formspec(craft_type, pow_percent)) meta:set_int("src_time", 0) meta:set_string("infotext", ("%s Idle"):format(nodedef.description) .. diff --git a/elepower_machines/machines/coal_alloy_furnace.lua b/elepower_machines/machines/coal_alloy_furnace.lua new file mode 100644 index 0000000..10745ab --- /dev/null +++ b/elepower_machines/machines/coal_alloy_furnace.lua @@ -0,0 +1,224 @@ + +local function can_dig(pos, player) + local meta = minetest.get_meta(pos); + local inv = meta:get_inventory() + return inv:is_empty("fuel") and inv:is_empty("dst") and inv:is_empty("src") +end + +local function allow_metadata_inventory_put(pos, listname, index, stack, player) + if minetest.is_protected(pos, player:get_player_name()) then + return 0 + end + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + if listname == "fuel" then + if minetest.get_craft_result({method="fuel", width=1, items={stack}}).time ~= 0 then + return stack:get_count() + else + return 0 + end + elseif listname == "src" then + return stack:get_count() + elseif listname == "dst" then + return 0 + end +end + +local function allow_metadata_inventory_move(pos, from_list, from_index, to_list, to_index, count, player) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + local stack = inv:get_stack(from_list, from_index) + return allow_metadata_inventory_put(pos, to_list, to_index, stack, player) +end + +local function allow_metadata_inventory_take(pos, listname, index, stack, player) + if minetest.is_protected(pos, player:get_player_name()) then + return 0 + end + return stack:get_count() +end + +local function alloy_furnace_timer(pos, elapsed) + -- + -- Inizialize metadata + -- + local meta = minetest.get_meta(pos) + local fuel_time = meta:get_float("fuel_time") or 0 + local src_time = meta:get_float("src_time") or 0 + local fuel_totaltime = meta:get_float("fuel_totaltime") or 0 + + local inv = meta:get_inventory() + local srclist, fuellist + + local alloyable + local fuel + local time = 0 + + local update = true + while elapsed > 0 and update do + update = false + + srclist = inv:get_list("src") + fuellist = inv:get_list("fuel") + + -- + -- Alloying + -- + + -- Check if we have alloyable content + local alloy = elepm.get_recipe("alloy", srclist) + local afteralloy = alloy.new_input + alloyable = alloy.time ~= 0 + + local el = math.min(elapsed, fuel_totaltime - fuel_time) + if alloyable then -- fuel lasts long enough, adjust el to cooking duration + time = alloy.time + 4 + el = math.min(el, time - src_time) + end + + -- Check if we have enough fuel to burn + if fuel_time < fuel_totaltime then + -- The furnace is currently active and has enough fuel + fuel_time = fuel_time + el + -- If there is a alloyable item then check if it is ready yet + if alloyable then + src_time = src_time + el + if src_time >= time then + -- Place result in dst list if possible + if inv:room_for_item("dst", alloy.output) then + inv:add_item("dst", alloy.output) + inv:set_list("src", afteralloy) + src_time = src_time - time + update = true + end + else + -- Item could not be alloy: probably missing fuel + update = true + end + end + else + -- Furnace ran out of fuel + if alloyable then + -- We need to get new fuel + local afterfuel + fuel, afterfuel = minetest.get_craft_result({method = "fuel", width = 1, items = fuellist}) + + if fuel.time == 0 then + -- No valid fuel in fuel list + fuel_totaltime = 0 + src_time = 0 + else + -- Take fuel from fuel list + inv:set_stack("fuel", 1, afterfuel.items[1]) + update = true + fuel_totaltime = fuel.time + (fuel_totaltime - fuel_time) + end + else + -- We don't need to get new fuel since there is no alloyable item + fuel_totaltime = 0 + src_time = 0 + end + fuel_time = 0 + end + + elapsed = elapsed - el + end + + if fuel and fuel_totaltime > time then + fuel_totaltime = time + end + if srclist[1]:is_empty() then + src_time = 0 + end + + -- + -- Update formspec, infotext and node + -- + local formspec + local item_percent = 0 + if alloyable then + item_percent = math.floor(src_time / time * 100) + end + + local active = "Inactive" + local result = false + + if fuel_totaltime ~= 0 then + active = "Active" + local fuel_percent = math.floor(fuel_time / fuel_totaltime * 100) + formspec = elepm.get_coal_alloy_furnace_formspec(fuel_percent, item_percent) + ele.helpers.swap_node(pos, "elepower_machines:coal_alloy_furnace_active") + result = true + else + formspec = elepm.get_coal_alloy_furnace_formspec(100, 0) + ele.helpers.swap_node(pos, "elepower_machines:coal_alloy_furnace") + minetest.get_node_timer(pos):stop() + end + + local infotext = "Alloy Furnace " .. active + + -- + -- Set meta values + -- + meta:set_float("fuel_totaltime", fuel_totaltime) + meta:set_float("fuel_time", fuel_time) + meta:set_float("src_time", src_time) + meta:set_string("formspec", formspec) + meta:set_string("infotext", infotext) + + return result +end + +local function metadata_inventory_changed(pos) + local t = minetest.get_node_timer(pos) + + if not t:is_started() then + t:start(1.0) + end +end + +ele.register_base_device("elepower_machines:coal_alloy_furnace", { + description = "Coal-fired Alloy Furnace", + paramtype2 = "facedir", + ele_active_node = true, + ele_active_nodedef = { + tiles = { + "elepower_cfalloy_top.png", "elepower_cfalloy_bottom.png", "elepower_cfalloy_side.png", + "elepower_cfalloy_side.png", "elepower_cfalloy_side.png", { + name = "elepower_cfalloy_front_active.png", + animation = { + aspect_h = 16, + aspect_w = 16, + length = 1, + type = "vertical_frames", + } + } + } + }, + tiles = { + "elepower_cfalloy_top.png", "elepower_cfalloy_bottom.png", "elepower_cfalloy_side.png", + "elepower_cfalloy_side.png", "elepower_cfalloy_side.png", "elepower_cfalloy_front.png" + }, + on_construct = function (pos) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + + inv:set_size("src", 2) + inv:set_size("dst", 4) + inv:set_size("fuel", 1) + + meta:set_string("formspec", elepm.get_coal_alloy_furnace_formspec(100, 0)) + end, + allow_metadata_inventory_put = allow_metadata_inventory_put, + allow_metadata_inventory_take = allow_metadata_inventory_take, + allow_metadata_inventory_move = allow_metadata_inventory_move, + on_metadata_inventory_move = metadata_inventory_changed, + on_metadata_inventory_take = metadata_inventory_changed, + on_metadata_inventory_put = metadata_inventory_changed, + can_dig = can_dig, + on_timer = alloy_furnace_timer, + groups = { + tubedevice = 1, + cracky = 2, + } +}) diff --git a/elepower_machines/machines/init.lua b/elepower_machines/machines/init.lua index 1a9666d..9bbf8db 100644 --- a/elepower_machines/machines/init.lua +++ b/elepower_machines/machines/init.lua @@ -3,6 +3,7 @@ dofile(elepm.modpath.."/machines/bases/init.lua") dofile(elepm.modpath.."/machines/accumulator.lua") dofile(elepm.modpath.."/machines/furnace.lua") dofile(elepm.modpath.."/machines/alloy_furnace.lua") +dofile(elepm.modpath.."/machines/coal_alloy_furnace.lua") dofile(elepm.modpath.."/machines/pulverizer.lua") dofile(elepm.modpath.."/machines/sawmill.lua") dofile(elepm.modpath.."/machines/generator.lua") diff --git a/elepower_machines/textures/elepower_cfalloy_bottom.png b/elepower_machines/textures/elepower_cfalloy_bottom.png new file mode 100644 index 0000000..a61269d Binary files /dev/null and b/elepower_machines/textures/elepower_cfalloy_bottom.png differ diff --git a/elepower_machines/textures/elepower_cfalloy_front.png b/elepower_machines/textures/elepower_cfalloy_front.png new file mode 100644 index 0000000..e63f08c Binary files /dev/null and b/elepower_machines/textures/elepower_cfalloy_front.png differ diff --git a/elepower_machines/textures/elepower_cfalloy_front_active.png b/elepower_machines/textures/elepower_cfalloy_front_active.png new file mode 100644 index 0000000..8c32379 Binary files /dev/null and b/elepower_machines/textures/elepower_cfalloy_front_active.png differ diff --git a/elepower_machines/textures/elepower_cfalloy_side.png b/elepower_machines/textures/elepower_cfalloy_side.png new file mode 100644 index 0000000..714b0b0 Binary files /dev/null and b/elepower_machines/textures/elepower_cfalloy_side.png differ diff --git a/elepower_machines/textures/elepower_cfalloy_top.png b/elepower_machines/textures/elepower_cfalloy_top.png new file mode 100644 index 0000000..2cc22f0 Binary files /dev/null and b/elepower_machines/textures/elepower_cfalloy_top.png differ diff --git a/elepower_nuclear/craftitems.lua b/elepower_nuclear/craftitems.lua new file mode 100644 index 0000000..d9b2a5f --- /dev/null +++ b/elepower_nuclear/craftitems.lua @@ -0,0 +1,72 @@ + +--------------------------- +-- Fission-related items -- +--------------------------- + +-- Uranium + +minetest.register_craftitem("elepower_nuclear:uranium_lump", { + description = "Uranium Lump", + inventory_image = "elenuclear_uranium_lump.png" +}) + +minetest.register_craftitem("elepower_nuclear:uranium_ingot", { + description = "Enriched Uranium Ingot", + inventory_image = "elenuclear_uranium_ingot.png" +}) + +minetest.register_craftitem("elepower_nuclear:depleted_uranium_ingot", { + description = "Depleted Uranium Ingot", + inventory_image = "elenuclear_depleted_uranium_ingot.png" +}) + +-- Dusts + +minetest.register_craftitem("elepower_nuclear:uranium_dust", { + description = "Enriched Uranium Dust", + inventory_image = "elenuclear_uranium_dust.png" +}) + +minetest.register_craftitem("elepower_nuclear:depleted_uranium_dust", { + description = "Depleted Uranium Dust", + inventory_image = "elenuclear_depleted_uranium_dust.png" +}) + +minetest.register_craftitem("elepower_nuclear:uranium_waste", { + description = "Uranium Waste", + inventory_image = "elenuclear_uranium_waste.png" +}) + +-- Fuel rods + +minetest.register_craftitem("elepower_nuclear:fuel_rod_empty", { + description = "Empty Fuel Rod", + inventory_image = "elenuclear_fuel_rod_empty.png" +}) + +minetest.register_craftitem("elepower_nuclear:fuel_rod_fissile", { + description = "Fissile Fuel Rod", + inventory_image = "elenuclear_fuel_rod_fissile.png" +}) + +minetest.register_craftitem("elepower_nuclear:fuel_rod_depleted", { + description = "Depleted Fuel Rod", + inventory_image = "elenuclear_fuel_rod_depleted.png" +}) + +-------------------------- +-- Fusion-related items -- +-------------------------- + + + +------------------------- +-- Crafting components -- +------------------------- + +-- Graphite + +minetest.register_craftitem("elepower_nuclear:graphite_rod", { + description = "Graphite Rod", + inventory_image = "elenuclear_graphite_rod.png" +}) diff --git a/elepower_nuclear/init.lua b/elepower_nuclear/init.lua index a9a5dc3..02e76d7 100644 --- a/elepower_nuclear/init.lua +++ b/elepower_nuclear/init.lua @@ -5,3 +5,5 @@ local modpath = minetest.get_modpath(minetest.get_current_modname()) elenuclear = rawget(_G, "elenuclear") or {} elenuclear.modpath = modpath + +dofile(modpath.."/craftitems.lua") diff --git a/elepower_nuclear/textures/elenuclear_depleted_uranium_dust.png b/elepower_nuclear/textures/elenuclear_depleted_uranium_dust.png new file mode 100644 index 0000000..04ba652 Binary files /dev/null and b/elepower_nuclear/textures/elenuclear_depleted_uranium_dust.png differ diff --git a/elepower_nuclear/textures/elenuclear_depleted_uranium_ingot.png b/elepower_nuclear/textures/elenuclear_depleted_uranium_ingot.png new file mode 100644 index 0000000..b84f066 Binary files /dev/null and b/elepower_nuclear/textures/elenuclear_depleted_uranium_ingot.png differ diff --git a/elepower_nuclear/textures/elenuclear_fuel_rod_depleted.png b/elepower_nuclear/textures/elenuclear_fuel_rod_depleted.png new file mode 100644 index 0000000..09f55b7 Binary files /dev/null and b/elepower_nuclear/textures/elenuclear_fuel_rod_depleted.png differ diff --git a/elepower_nuclear/textures/elenuclear_fuel_rod_empty.png b/elepower_nuclear/textures/elenuclear_fuel_rod_empty.png new file mode 100644 index 0000000..da78820 Binary files /dev/null and b/elepower_nuclear/textures/elenuclear_fuel_rod_empty.png differ diff --git a/elepower_nuclear/textures/elenuclear_fuel_rod_fissile.png b/elepower_nuclear/textures/elenuclear_fuel_rod_fissile.png new file mode 100644 index 0000000..894d4e3 Binary files /dev/null and b/elepower_nuclear/textures/elenuclear_fuel_rod_fissile.png differ diff --git a/elepower_nuclear/textures/elenuclear_graphite_moderator.png b/elepower_nuclear/textures/elenuclear_graphite_moderator.png new file mode 100644 index 0000000..d5aa6d1 Binary files /dev/null and b/elepower_nuclear/textures/elenuclear_graphite_moderator.png differ diff --git a/elepower_nuclear/textures/elenuclear_graphite_rod.png b/elepower_nuclear/textures/elenuclear_graphite_rod.png new file mode 100644 index 0000000..a63f298 Binary files /dev/null and b/elepower_nuclear/textures/elenuclear_graphite_rod.png differ diff --git a/elepower_nuclear/textures/elenuclear_heat_exchanger.png b/elepower_nuclear/textures/elenuclear_heat_exchanger.png new file mode 100644 index 0000000..73ab9ab Binary files /dev/null and b/elepower_nuclear/textures/elenuclear_heat_exchanger.png differ diff --git a/elepower_nuclear/textures/elenuclear_reinforced_block.png b/elepower_nuclear/textures/elenuclear_reinforced_block.png new file mode 100644 index 0000000..91cc573 Binary files /dev/null and b/elepower_nuclear/textures/elenuclear_reinforced_block.png differ diff --git a/elepower_nuclear/textures/elenuclear_uranium_dust.png b/elepower_nuclear/textures/elenuclear_uranium_dust.png new file mode 100644 index 0000000..20fb31c Binary files /dev/null and b/elepower_nuclear/textures/elenuclear_uranium_dust.png differ diff --git a/elepower_nuclear/textures/elenuclear_uranium_ingot.png b/elepower_nuclear/textures/elenuclear_uranium_ingot.png new file mode 100644 index 0000000..8856985 Binary files /dev/null and b/elepower_nuclear/textures/elenuclear_uranium_ingot.png differ diff --git a/elepower_nuclear/textures/elenuclear_uranium_lump.png b/elepower_nuclear/textures/elenuclear_uranium_lump.png new file mode 100644 index 0000000..f0ce3c0 Binary files /dev/null and b/elepower_nuclear/textures/elenuclear_uranium_lump.png differ diff --git a/elepower_nuclear/textures/elenuclear_uranium_waste.png b/elepower_nuclear/textures/elenuclear_uranium_waste.png new file mode 100644 index 0000000..368768f Binary files /dev/null and b/elepower_nuclear/textures/elenuclear_uranium_waste.png differ diff --git a/elepower_papi/machine.lua b/elepower_papi/machine.lua index c105778..b3a9289 100644 --- a/elepower_papi/machine.lua +++ b/elepower_papi/machine.lua @@ -74,7 +74,7 @@ local function allow_metadata_inventory_take(pos, listname, index, stack, player return stack:get_count() end -function metadata_inventory_changed(pos) +local function metadata_inventory_changed(pos) local t = minetest.get_node_timer(pos) if not t:is_started() then