From 888b0ebfec8c2eff9015163549a7e47443cb8665 Mon Sep 17 00:00:00 2001 From: Vanessa Ezekowitz Date: Fri, 1 Apr 2016 21:00:20 -0400 Subject: "explode" all modpacks into their individual components (you can't have a modpack buried inside a modpack) --- technic/machines/LV/alloy_furnace.lua | 14 ++ technic/machines/LV/battery_box.lua | 19 ++ technic/machines/LV/cables.lua | 14 ++ technic/machines/LV/cnc.lua | 237 ++++++++++++++++++++ technic/machines/LV/cnc_api.lua | 369 +++++++++++++++++++++++++++++++ technic/machines/LV/cnc_nodes.lua | 91 ++++++++ technic/machines/LV/compressor.lua | 13 ++ technic/machines/LV/electric_furnace.lua | 16 ++ technic/machines/LV/extractor.lua | 13 ++ technic/machines/LV/generator.lua | 18 ++ technic/machines/LV/geothermal.lua | 111 ++++++++++ technic/machines/LV/grinder.lua | 13 ++ technic/machines/LV/init.lua | 29 +++ technic/machines/LV/music_player.lua | 130 +++++++++++ technic/machines/LV/solar_array.lua | 18 ++ technic/machines/LV/solar_panel.lua | 67 ++++++ technic/machines/LV/water_mill.lua | 102 +++++++++ 17 files changed, 1274 insertions(+) create mode 100644 technic/machines/LV/alloy_furnace.lua create mode 100644 technic/machines/LV/battery_box.lua create mode 100644 technic/machines/LV/cables.lua create mode 100644 technic/machines/LV/cnc.lua create mode 100644 technic/machines/LV/cnc_api.lua create mode 100644 technic/machines/LV/cnc_nodes.lua create mode 100644 technic/machines/LV/compressor.lua create mode 100644 technic/machines/LV/electric_furnace.lua create mode 100644 technic/machines/LV/extractor.lua create mode 100644 technic/machines/LV/generator.lua create mode 100644 technic/machines/LV/geothermal.lua create mode 100644 technic/machines/LV/grinder.lua create mode 100644 technic/machines/LV/init.lua create mode 100644 technic/machines/LV/music_player.lua create mode 100644 technic/machines/LV/solar_array.lua create mode 100644 technic/machines/LV/solar_panel.lua create mode 100644 technic/machines/LV/water_mill.lua (limited to 'technic/machines/LV') diff --git a/technic/machines/LV/alloy_furnace.lua b/technic/machines/LV/alloy_furnace.lua new file mode 100644 index 0000000..bdf2f31 --- /dev/null +++ b/technic/machines/LV/alloy_furnace.lua @@ -0,0 +1,14 @@ +-- LV Alloy furnace + +-- FIXME: kpoppel: I'd like to introduce an induction heating element here... +minetest.register_craft({ + output = 'technic:lv_alloy_furnace', + recipe = { + {'default:brick', 'default:brick', 'default:brick'}, + {'default:brick', 'technic:machine_casing', 'default:brick'}, + {'default:brick', 'technic:lv_cable0', 'default:brick'}, + } +}) + +technic.register_alloy_furnace({tier = "LV", speed = 1, demand = {300}}) + diff --git a/technic/machines/LV/battery_box.lua b/technic/machines/LV/battery_box.lua new file mode 100644 index 0000000..429bcd6 --- /dev/null +++ b/technic/machines/LV/battery_box.lua @@ -0,0 +1,19 @@ + +minetest.register_craft({ + output = 'technic:lv_battery_box0', + recipe = { + {'group:wood', 'group:wood', 'group:wood'}, + {'technic:battery', 'technic:machine_casing', 'technic:battery'}, + {'technic:battery', 'technic:lv_cable0', 'technic:battery'}, + } +}) + +technic.register_battery_box({ + tier = "LV", + max_charge = 40000, + charge_rate = 1000, + discharge_rate = 4000, + charge_step = 500, + discharge_step = 800, +}) + diff --git a/technic/machines/LV/cables.lua b/technic/machines/LV/cables.lua new file mode 100644 index 0000000..e18eae1 --- /dev/null +++ b/technic/machines/LV/cables.lua @@ -0,0 +1,14 @@ + +minetest.register_alias("lv_cable", "technic:lv_cable0") + +minetest.register_craft({ + output = 'technic:lv_cable0 6', + recipe = { + {'default:paper', 'default:paper', 'default:paper'}, + {'default:copper_ingot', 'default:copper_ingot', 'default:copper_ingot'}, + {'default:paper', 'default:paper', 'default:paper'}, + } +}) + +technic.register_cable("LV", 2/16) + diff --git a/technic/machines/LV/cnc.lua b/technic/machines/LV/cnc.lua new file mode 100644 index 0000000..dd67e9b --- /dev/null +++ b/technic/machines/LV/cnc.lua @@ -0,0 +1,237 @@ +-- Technic CNC v1.0 by kpoppel +-- Based on the NonCubic Blocks MOD v1.4 by yves_de_beck + +-- Idea: +-- Somehow have a tabbed/paged panel if the number of shapes should expand +-- beyond what is available in the panel today. +-- I could imagine some form of API allowing modders to come with their own node +-- box definitions and easily stuff it in the this machine for production. + +local S = technic.getter + +local shape = {} +local onesize_products = { + slope = 2, + slope_edge = 1, + slope_inner_edge = 1, + pyramid = 2, + spike = 1, + cylinder = 2, + oblate_spheroid = 1, + sphere = 1, + stick = 8, + slope_upsdown = 2, + slope_edge_upsdown = 1, + slope_inner_edge_upsdown = 1, + cylinder_horizontal = 2, + slope_lying = 2, + onecurvededge = 1, + twocurvededge = 1, +} +local twosize_products = { + element_straight = 4, + element_end = 2, + element_cross = 1, + element_t = 1, + element_edge = 2, +} + +local cnc_formspec = + "invsize[9,11;]".. + "label[1,0;"..S("Choose Milling Program:").."]".. + "image_button[1,0.5;1,1;technic_cnc_slope.png;slope; ]".. + "image_button[2,0.5;1,1;technic_cnc_slope_edge.png;slope_edge; ]".. + "image_button[3,0.5;1,1;technic_cnc_slope_inner_edge.png;slope_inner_edge; ]".. + "image_button[4,0.5;1,1;technic_cnc_pyramid.png;pyramid; ]".. + "image_button[5,0.5;1,1;technic_cnc_spike.png;spike; ]".. + "image_button[6,0.5;1,1;technic_cnc_cylinder.png;cylinder; ]".. + "image_button[7,0.5;1,1;technic_cnc_oblate_spheroid.png;oblate_spheroid; ]".. + "image_button[8,0.5;1,1;technic_cnc_stick.png;stick; ]".. + + "image_button[1,1.5;1,1;technic_cnc_slope_upsdwn.png;slope_upsdown; ]".. + "image_button[2,1.5;1,1;technic_cnc_slope_edge_upsdwn.png;slope_edge_upsdown; ]".. + "image_button[3,1.5;1,1;technic_cnc_slope_inner_edge_upsdwn.png;slope_inner_edge_upsdown; ]".. + "image_button[4,1.5;1,1;technic_cnc_cylinder_horizontal.png;cylinder_horizontal; ]".. + "image_button[5,1.5;1,1;technic_cnc_sphere.png;sphere; ]".. + + "image_button[1,2.5;1,1;technic_cnc_slope_lying.png;slope_lying; ]".. + "image_button[2,2.5;1,1;technic_cnc_onecurvededge.png;onecurvededge; ]".. + "image_button[3,2.5;1,1;technic_cnc_twocurvededge.png;twocurvededge; ]".. + + "label[1,3.5;"..S("Slim Elements half / normal height:").."]".. + + "image_button[1,4;1,0.5;technic_cnc_full.png;full; ]".. + "image_button[1,4.5;1,0.5;technic_cnc_half.png;half; ]".. + "image_button[2,4;1,1;technic_cnc_element_straight.png;element_straight; ]".. + "image_button[3,4;1,1;technic_cnc_element_end.png;element_end; ]".. + "image_button[4,4;1,1;technic_cnc_element_cross.png;element_cross; ]".. + "image_button[5,4;1,1;technic_cnc_element_t.png;element_t; ]".. + "image_button[6,4;1,1;technic_cnc_element_edge.png;element_edge; ]".. + + "label[0, 5.5;"..S("In:").."]".. + "list[current_name;src;0.5,5.5;1,1;]".. + "label[4, 5.5;"..S("Out:").."]".. + "list[current_name;dst;5,5.5;4,1;]".. + + "list[current_player;main;0,7;8,4;]".. + "listring[current_name;dst]".. + "listring[current_player;main]".. + "listring[current_name;src]".. + "listring[current_player;main]" + +local size = 1; + +-- The form handler is declared here because we need it in both the inactive and active modes +-- in order to be able to change programs wile it is running. +local function form_handler(pos, formname, fields, sender) + -- REGISTER MILLING PROGRAMS AND OUTPUTS: + ------------------------------------------ + -- Program for half/full size + if fields["full"] then + size = 1 + return + end + + if fields["half"] then + size = 2 + return + end + + -- Resolve the node name and the number of items to make + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + local inputstack = inv:get_stack("src", 1) + local inputname = inputstack:get_name() + local multiplier = 0 + for k, _ in pairs(fields) do + -- Set a multipier for the half/full size capable blocks + if twosize_products[k] ~= nil then + multiplier = size * twosize_products[k] + else + multiplier = onesize_products[k] + end + + if onesize_products[k] ~= nil or twosize_products[k] ~= nil then + meta:set_float( "cnc_multiplier", multiplier) + meta:set_string("cnc_user", sender:get_player_name()) + end + + if onesize_products[k] ~= nil or (twosize_products[k] ~= nil and size==2) then + meta:set_string("cnc_product", inputname .. "_technic_cnc_" .. k) + --print(inputname .. "_technic_cnc_" .. k) + break + end + + if twosize_products[k] ~= nil and size==1 then + meta:set_string("cnc_product", inputname .. "_technic_cnc_" .. k .. "_double") + --print(inputname .. "_technic_cnc_" .. k .. "_double") + break + end + end + return +end + +-- Action code performing the transformation +local run = function(pos, node) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + local eu_input = meta:get_int("LV_EU_input") + local machine_name = S("%s CNC Machine"):format("LV") + local machine_node = "technic:cnc" + local demand = 450 + + local result = meta:get_string("cnc_product") + if inv:is_empty("src") or + (not minetest.registered_nodes[result]) or + (not inv:room_for_item("dst", result)) then + technic.swap_node(pos, machine_node) + meta:set_string("infotext", S("%s Idle"):format(machine_name)) + meta:set_string("cnc_product", "") + meta:set_int("LV_EU_demand", 0) + return + end + + if eu_input < demand then + technic.swap_node(pos, machine_node) + meta:set_string("infotext", S("%s Unpowered"):format(machine_name)) + elseif eu_input >= demand then + technic.swap_node(pos, machine_node.."_active") + meta:set_string("infotext", S("%s Active"):format(machine_name)) + meta:set_int("src_time", meta:get_int("src_time") + 1) + if meta:get_int("src_time") >= 3 then -- 3 ticks per output + meta:set_int("src_time", 0) + srcstack = inv:get_stack("src", 1) + srcstack:take_item() + inv:set_stack("src", 1, srcstack) + inv:add_item("dst", result.." "..meta:get_int("cnc_multiplier")) + end + end + meta:set_int("LV_EU_demand", demand) +end + +-- The actual block inactive state +minetest.register_node("technic:cnc", { + description = S("%s CNC Machine"):format("LV"), + tiles = {"technic_cnc_top.png", "technic_cnc_bottom.png", "technic_cnc_side.png", + "technic_cnc_side.png", "technic_cnc_side.png", "technic_cnc_front.png"}, + drawtype = "nodebox", + paramtype = "light", + paramtype2 = "facedir", + node_box = { + type = "fixed", + fixed = { + {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5}, + }, + }, + groups = {cracky=2, technic_machine=1}, + legacy_facedir_simple = true, + on_construct = function(pos) + local meta = minetest.get_meta(pos) + meta:set_string("infotext", S("%s CNC Machine"):format("LV")) + meta:set_float("technic_power_machine", 1) + meta:set_string("formspec", cnc_formspec) + local inv = meta:get_inventory() + inv:set_size("src", 1) + inv:set_size("dst", 4) + end, + can_dig = technic.machine_can_dig, + allow_metadata_inventory_put = technic.machine_inventory_put, + allow_metadata_inventory_take = technic.machine_inventory_take, + allow_metadata_inventory_move = technic.machine_inventory_move, + on_receive_fields = form_handler, + technic_run = run, +}) + +-- Active state block +minetest.register_node("technic:cnc_active", { + description = S("%s CNC Machine"):format("LV"), + tiles = {"technic_cnc_top_active.png", "technic_cnc_bottom.png", "technic_cnc_side.png", + "technic_cnc_side.png", "technic_cnc_side.png", "technic_cnc_front_active.png"}, + paramtype2 = "facedir", + drop = "technic:cnc", + groups = {cracky=2, technic_machine=1, not_in_creative_inventory=1}, + legacy_facedir_simple = true, + can_dig = technic.machine_can_dig, + allow_metadata_inventory_put = technic.machine_inventory_put, + allow_metadata_inventory_take = technic.machine_inventory_take, + allow_metadata_inventory_move = technic.machine_inventory_move, + on_receive_fields = form_handler, + technic_run = run, + technic_disabled_machine_name = "technic:cnc", +}) + +technic.register_machine("LV", "technic:cnc", technic.receiver) +technic.register_machine("LV", "technic:cnc_active", technic.receiver) + +------------------------- +-- CNC Machine Recipe +------------------------- +minetest.register_craft({ + output = 'technic:cnc', + recipe = { + {'default:glass', 'technic:diamond_drill_head', 'default:glass'}, + {'technic:control_logic_unit', 'technic:machine_casing', 'technic:motor'}, + {'technic:carbon_steel_ingot', 'technic:lv_cable0', 'technic:carbon_steel_ingot'}, + }, +}) + diff --git a/technic/machines/LV/cnc_api.lua b/technic/machines/LV/cnc_api.lua new file mode 100644 index 0000000..f5aae5c --- /dev/null +++ b/technic/machines/LV/cnc_api.lua @@ -0,0 +1,369 @@ +-- API for the technic CNC machine +-- Again code is adapted from the NonCubic Blocks MOD v1.4 by yves_de_beck + +local S = technic.getter + +technic.cnc = {} + +-- REGISTER NONCUBIC FORMS, CREATE MODELS AND RECIPES: +------------------------------------------------------ + +-- Define slope boxes for the various nodes +------------------------------------------- +technic.cnc.programs = { + { suffix = "technic_cnc_stick", + model = {-0.15, -0.5, -0.15, 0.15, 0.5, 0.15}, + desc = S("Stick") + }, + + { suffix = "technic_cnc_element_end_double", + model = {-0.3, -0.5, -0.3, 0.3, 0.5, 0.5}, + desc = S("Element End Double") + }, + + { suffix = "technic_cnc_element_cross_double", + model = { + {0.3, -0.5, -0.3, 0.5, 0.5, 0.3}, + {-0.3, -0.5, -0.5, 0.3, 0.5, 0.5}, + {-0.5, -0.5, -0.3, -0.3, 0.5, 0.3}}, + desc = S("Element Cross Double") + }, + + { suffix = "technic_cnc_element_t_double", + model = { + {-0.3, -0.5, -0.5, 0.3, 0.5, 0.3}, + {-0.5, -0.5, -0.3, -0.3, 0.5, 0.3}, + {0.3, -0.5, -0.3, 0.5, 0.5, 0.3}}, + desc = S("Element T Double") + }, + + { suffix = "technic_cnc_element_edge_double", + model = { + {-0.3, -0.5, -0.5, 0.3, 0.5, 0.3}, + {-0.5, -0.5, -0.3, -0.3, 0.5, 0.3}}, + desc = S("Element Edge Double") + }, + + { suffix = "technic_cnc_element_straight_double", + model = {-0.3, -0.5, -0.5, 0.3, 0.5, 0.5}, + desc = S("Element Straight Double") + }, + + { suffix = "technic_cnc_element_end", + model = {-0.3, -0.5, -0.3, 0.3, 0, 0.5}, + desc = S("Element End") + }, + + { suffix = "technic_cnc_element_cross", + model = { + {0.3, -0.5, -0.3, 0.5, 0, 0.3}, + {-0.3, -0.5, -0.5, 0.3, 0, 0.5}, + {-0.5, -0.5, -0.3, -0.3, 0, 0.3}}, + desc = S("Element Cross") + }, + + { suffix = "technic_cnc_element_t", + model = { + {-0.3, -0.5, -0.5, 0.3, 0, 0.3}, + {-0.5, -0.5, -0.3, -0.3, 0, 0.3}, + {0.3, -0.5, -0.3, 0.5, 0, 0.3}}, + desc = S("Element T") + }, + + { suffix = "technic_cnc_element_edge", + model = { + {-0.3, -0.5, -0.5, 0.3, 0, 0.3}, + {-0.5, -0.5, -0.3, -0.3, 0, 0.3}}, + desc = S("Element Edge") + }, + + { suffix = "technic_cnc_element_straight", + model = {-0.3, -0.5, -0.5, 0.3, 0, 0.5}, + desc = S("Element Straight") + }, + + { suffix = "technic_cnc_oblate_spheroid", + model = "technic_oblate_spheroid.obj", + desc = S("Oblate spheroid"), + cbox = { + type = "fixed", + fixed = { + { -6/16, 4/16, -6/16, 6/16, 8/16, 6/16 }, + { -8/16, -4/16, -8/16, 8/16, 4/16, 8/16 }, + { -6/16, -8/16, -6/16, 6/16, -4/16, 6/16 } + } + } + }, + + { suffix = "technic_cnc_sphere", + model = "technic_sphere.obj", + desc = S("Sphere") + }, + + { suffix = "technic_cnc_cylinder_horizontal", + model = "technic_cylinder_horizontal.obj", + desc = S("Horizontal Cylinder") + }, + + { suffix = "technic_cnc_cylinder", + model = "technic_cylinder.obj", + desc = S("Cylinder") + }, + + { suffix = "technic_cnc_twocurvededge", + model = "technic_two_curved_edge.obj", + desc = S("Two Curved Edge/Corner Block") + }, + + { suffix = "technic_cnc_onecurvededge", + model = "technic_one_curved_edge.obj", + desc = S("One Curved Edge Block") + }, + + { suffix = "technic_cnc_spike", + model = "technic_pyramid_spike.obj", + desc = S("Spike"), + cbox = { + type = "fixed", + fixed = { + { -2/16, 4/16, -2/16, 2/16, 8/16, 2/16 }, + { -4/16, 0, -4/16, 4/16, 4/16, 4/16 }, + { -6/16, -4/16, -6/16, 6/16, 0, 6/16 }, + { -8/16, -8/16, -8/16, 8/16, -4/16, 8/16 } + } + } + }, + + { suffix = "technic_cnc_pyramid", + model = "technic_pyramid.obj", + desc = S("Pyramid"), + cbox = { + type = "fixed", + fixed = { + { -2/16, -2/16, -2/16, 2/16, 0, 2/16 }, + { -4/16, -4/16, -4/16, 4/16, -2/16, 4/16 }, + { -6/16, -6/16, -6/16, 6/16, -4/16, 6/16 }, + { -8/16, -8/16, -8/16, 8/16, -6/16, 8/16 } + } + } + }, + + { suffix = "technic_cnc_slope_inner_edge_upsdown", + model = "technic_innercorner_upsdown.obj", + desc = S("Slope Upside Down Inner Edge/Corner"), + sbox = { + type = "fixed", + fixed = { -0.5, -0.5, -0.5, 0.5, 0.5, 0.5 } + }, + cbox = { + type = "fixed", + fixed = { + { 0.25, -0.25, -0.5, 0.5, -0.5, 0.5 }, + { -0.5, -0.25, 0.25, 0.5, -0.5, 0.5 }, + { 0, 0, -0.5, 0.5, -0.25, 0.5 }, + { -0.5, 0, 0, 0.5, -0.25, 0.5 }, + { -0.25, 0.25, -0.5, 0.5, 0, -0.25 }, + { -0.5, 0.25, -0.25, 0.5, 0, 0.5 }, + { -0.5, 0.5, -0.5, 0.5, 0.25, 0.5 } + } + } + }, + + { suffix = "technic_cnc_slope_edge_upsdown", + model = "technic_outercorner_upsdown.obj", + desc = S("Slope Upside Down Outer Edge/Corner"), + cbox = { + type = "fixed", + fixed = { + { -8/16, 8/16, -8/16, 8/16, 4/16, 8/16 }, + { -4/16, 4/16, -4/16, 8/16, 0, 8/16 }, + { 0, 0, 0, 8/16, -4/16, 8/16 }, + { 4/16, -4/16, 4/16, 8/16, -8/16, 8/16 } + } + } + }, + + { suffix = "technic_cnc_slope_inner_edge", + model = "technic_innercorner.obj", + desc = S("Slope Inner Edge/Corner"), + sbox = { + type = "fixed", + fixed = { -0.5, -0.5, -0.5, 0.5, 0.5, 0.5 } + }, + cbox = { + type = "fixed", + fixed = { + { -0.5, -0.5, -0.5, 0.5, -0.25, 0.5 }, + { -0.5, -0.25, -0.25, 0.5, 0, 0.5 }, + { -0.25, -0.25, -0.5, 0.5, 0, -0.25 }, + { -0.5, 0, 0, 0.5, 0.25, 0.5 }, + { 0, 0, -0.5, 0.5, 0.25, 0.5 }, + { -0.5, 0.25, 0.25, 0.5, 0.5, 0.5 }, + { 0.25, 0.25, -0.5, 0.5, 0.5, 0.5 } + } + } + }, + + { suffix = "technic_cnc_slope_edge", + model = "technic_outercorner.obj", + desc = S("Slope Outer Edge/Corner"), + cbox = { + type = "fixed", + fixed = { + { 4/16, 4/16, 4/16, 8/16, 8/16, 8/16 }, + { 0, 0, 0, 8/16, 4/16, 8/16 }, + { -4/16, -4/16, -4/16, 8/16, 0, 8/16 }, + { -8/16, -8/16, -8/16, 8/16, -4/16, 8/16 } + } + } + }, + + { suffix = "technic_cnc_slope_upsdown", + model = "technic_slope_upsdown.obj", + desc = S("Slope Upside Down"), + cbox = { + type = "fixed", + fixed = { + { -8/16, 8/16, -8/16, 8/16, 4/16, 8/16 }, + { -8/16, 4/16, -4/16, 8/16, 0, 8/16 }, + { -8/16, 0, 0, 8/16, -4/16, 8/16 }, + { -8/16, -4/16, 4/16, 8/16, -8/16, 8/16 } + } + } + }, + + { suffix = "technic_cnc_slope_lying", + model = "technic_slope_horizontal.obj", + desc = S("Slope Lying"), + cbox = { + type = "fixed", + fixed = { + { 4/16, -8/16, 4/16, 8/16, 8/16, 8/16 }, + { 0, -8/16, 0, 4/16, 8/16, 8/16 }, + { -4/16, -8/16, -4/16, 0, 8/16, 8/16 }, + { -8/16, -8/16, -8/16, -4/16, 8/16, 8/16 } + } + } + }, + + { suffix = "technic_cnc_slope", + model = "technic_slope.obj", + desc = S("Slope"), + cbox = { + type = "fixed", + fixed = { + { -8/16, 4/16, 4/16, 8/16, 8/16, 8/16 }, + { -8/16, 0, 0, 8/16, 4/16, 8/16 }, + { -8/16, -4/16, -4/16, 8/16, 0, 8/16 }, + { -8/16, -8/16, -8/16, 8/16, -4/16, 8/16 } + } + } + }, + +} + +-- Allow disabling certain programs for some node. Default is allowing all types for all nodes +technic.cnc.programs_disable = { + -- ["default:brick"] = {"technic_cnc_stick"}, -- Example: Disallow the stick for brick + -- ... + ["default:dirt"] = {"technic_cnc_oblate_spheroid", "technic_cnc_slope_upsdown", "technic_cnc_edge", + "technic_cnc_inner_edge", "technic_cnc_slope_edge_upsdown", + "technic_cnc_slope_inner_edge_upsdown", "technic_cnc_stick", + "technic_cnc_cylinder_horizontal"} +} + +-- Generic function for registering all the different node types +function technic.cnc.register_program(recipeitem, suffix, model, groups, images, description, cbox, sbox) + + local dtype + local nodeboxdef + local meshdef + + if type(model) ~= "string" then -- assume a nodebox if it's a table or function call + dtype = "nodebox" + nodeboxdef = { + type = "fixed", + fixed = model + } + else + dtype = "mesh" + meshdef = model + end + + if cbox and not sbox then sbox = cbox end + + minetest.register_node(":"..recipeitem.."_"..suffix, { + description = description, + drawtype = dtype, + node_box = nodeboxdef, + mesh = meshdef, + tiles = images, + paramtype = "light", + paramtype2 = "facedir", + walkable = true, + groups = groups, + selection_box = sbox, + collision_box = cbox + }) +end + +-- function to iterate over all the programs the CNC machine knows +function technic.cnc.register_all(recipeitem, groups, images, description) + for _, data in ipairs(technic.cnc.programs) do + -- Disable node creation for disabled node types for some material + local do_register = true + if technic.cnc.programs_disable[recipeitem] ~= nil then + for __, disable in ipairs(technic.cnc.programs_disable[recipeitem]) do + if disable == data.suffix then + do_register = false + end + end + end + -- Create the node if it passes the test + if do_register then + technic.cnc.register_program(recipeitem, data.suffix, data.model, + groups, images, description.." "..data.desc, data.cbox, data.sbox) + end + end +end + + +-- REGISTER NEW TECHNIC_CNC_API's PART 2: technic.cnc..register_element_end(subname, recipeitem, groups, images, desc_element_xyz) +----------------------------------------------------------------------------------------------------------------------- +function technic.cnc.register_slope_edge_etc(recipeitem, groups, images, desc_slope, desc_slope_lying, desc_slope_upsdown, desc_slope_edge, desc_slope_inner_edge, desc_slope_upsdwn_edge, desc_slope_upsdwn_inner_edge, desc_pyramid, desc_spike, desc_onecurvededge, desc_twocurvededge, desc_cylinder, desc_cylinder_horizontal, desc_spheroid, desc_element_straight, desc_element_edge, desc_element_t, desc_element_cross, desc_element_end) + + technic.cnc.register_slope(recipeitem, groups, images, desc_slope) + technic.cnc.register_slope_lying(recipeitem, groups, images, desc_slope_lying) + technic.cnc.register_slope_upsdown(recipeitem, groups, images, desc_slope_upsdown) + technic.cnc.register_slope_edge(recipeitem, groups, images, desc_slope_edge) + technic.cnc.register_slope_inner_edge(recipeitem, groups, images, desc_slope_inner_edge) + technic.cnc.register_slope_edge_upsdown(recipeitem, groups, images, desc_slope_upsdwn_edge) + technic.cnc.register_slope_inner_edge_upsdown(recipeitem, groups, images, desc_slope_upsdwn_inner_edge) + technic.cnc.register_pyramid(recipeitem, groups, images, desc_pyramid) + technic.cnc.register_spike(recipeitem, groups, images, desc_spike) + technic.cnc.register_onecurvededge(recipeitem, groups, images, desc_onecurvededge) + technic.cnc.register_twocurvededge(recipeitem, groups, images, desc_twocurvededge) + technic.cnc.register_cylinder(recipeitem, groups, images, desc_cylinder) + technic.cnc.register_cylinder_horizontal(recipeitem, groups, images, desc_cylinder_horizontal) + technic.cnc.register_spheroid(recipeitem, groups, images, desc_spheroid) + technic.cnc.register_element_straight(recipeitem, groups, images, desc_element_straight) + technic.cnc.register_element_edge(recipeitem, groups, images, desc_element_edge) + technic.cnc.register_element_t(recipeitem, groups, images, desc_element_t) + technic.cnc.register_element_cross(recipeitem, groups, images, desc_element_cross) + technic.cnc.register_element_end(recipeitem, groups, images, desc_element_end) +end + +-- REGISTER STICKS: noncubic.register_xyz(recipeitem, groups, images, desc_element_xyz) +------------------------------------------------------------------------------------------------------------ +function technic.cnc.register_stick_etc(recipeitem, groups, images, desc_stick) + technic.cnc.register_stick(recipeitem, groups, images, desc_stick) +end + +function technic.cnc.register_elements(recipeitem, groups, images, desc_element_straight_double, desc_element_edge_double, desc_element_t_double, desc_element_cross_double, desc_element_end_double) + technic.cnc.register_element_straight_double(recipeitem, groups, images, desc_element_straight_double) + technic.cnc.register_element_edge_double(recipeitem, groups, images, desc_element_edge_double) + technic.cnc.register_element_t_double(recipeitem, groups, images, desc_element_t_double) + technic.cnc.register_element_cross_double(recipeitem, groups, images, desc_element_cross_double) + technic.cnc.register_element_end_double(recipeitem, groups, images, desc_element_end_double) +end + diff --git a/technic/machines/LV/cnc_nodes.lua b/technic/machines/LV/cnc_nodes.lua new file mode 100644 index 0000000..05be9af --- /dev/null +++ b/technic/machines/LV/cnc_nodes.lua @@ -0,0 +1,91 @@ +-- REGISTER MATERIALS AND PROPERTIES FOR NONCUBIC ELEMENTS: +----------------------------------------------------------- + +local S = technic.getter + +-- DIRT +------- +technic.cnc.register_all("default:dirt", + {snappy=2,choppy=2,oddly_breakable_by_hand=3,not_in_creative_inventory=1}, + {"default_grass.png", "default_dirt.png", "default_grass.png"}, + S("Dirt")) +-- WOOD +------- +technic.cnc.register_all("default:wood", + {snappy=2, choppy=2, oddly_breakable_by_hand=2, not_in_creative_inventory=1}, + {"default_wood.png"}, + S("Wooden")) +-- STONE +-------- +technic.cnc.register_all("default:stone", + {cracky=3, not_in_creative_inventory=1}, + {"default_stone.png"}, + S("Stone")) +-- COBBLE +--------- +technic.cnc.register_all("default:cobble", + {cracky=3, not_in_creative_inventory=1}, + {"default_cobble.png"}, + S("Cobble")) +-- BRICK +-------- +technic.cnc.register_all("default:brick", + {cracky=3, not_in_creative_inventory=1}, + {"default_brick.png"}, + S("Brick")) + +-- SANDSTONE +------------ +technic.cnc.register_all("default:sandstone", + {crumbly=2, cracky=3, not_in_creative_inventory=1}, + {"default_sandstone.png"}, + S("Sandstone")) + +-- LEAVES +--------- +technic.cnc.register_all("default:leaves", + {snappy=2, choppy=2, oddly_breakable_by_hand=3, not_in_creative_inventory=1}, + {"default_leaves.png"}, + S("Leaves")) +-- TREE +------- +technic.cnc.register_all("default:tree", + {snappy=1, choppy=2, oddly_breakable_by_hand=2, flammable=3, wood=1, not_in_creative_inventory=1}, + {"default_tree.png"}, + S("Tree")) + +-- WROUGHT IRON +--------------- +technic.cnc.register_all("default:steelblock", + {cracky=1, level=2, not_in_creative_inventory=1}, + {"technic_wrought_iron_block.png"}, + S("Wrought Iron")) + +-- Bronze +-------- +technic.cnc.register_all("default:bronzeblock", + {cracky=1, level=2, not_in_creative_inventory=1}, + {"default_bronze_block.png"}, + S("Bronze")) + +-- Stainless Steel +-------- +technic.cnc.register_all("technic:stainless_steel_block", + {cracky=1, level=2, not_in_creative_inventory=1}, + {"technic_stainless_steel_block.png"}, + S("Stainless Steel")) + +-- Marble +------------ +technic.cnc.register_all("technic:marble", + {cracky=3, not_in_creative_inventory=1}, + {"technic_marble.png"}, + S("Marble")) + +-- Granite +------------ +technic.cnc.register_all("technic:granite", + {cracky=1, not_in_creative_inventory=1}, + {"technic_granite.png"}, + S("Granite")) + diff --git a/technic/machines/LV/compressor.lua b/technic/machines/LV/compressor.lua new file mode 100644 index 0000000..e2bde40 --- /dev/null +++ b/technic/machines/LV/compressor.lua @@ -0,0 +1,13 @@ + +minetest.register_alias("compressor", "technic:lv_compressor") + +minetest.register_craft({ + output = 'technic:lv_compressor', + recipe = { + {'default:stone', 'technic:motor', 'default:stone'}, + {'mesecons:piston', 'technic:machine_casing', 'mesecons:piston'}, + {'technic:fine_silver_wire', 'technic:lv_cable0', 'technic:fine_silver_wire'}, + } +}) + +technic.register_compressor({tier = "LV", demand = {300}, speed = 1}) diff --git a/technic/machines/LV/electric_furnace.lua b/technic/machines/LV/electric_furnace.lua new file mode 100644 index 0000000..cc4daff --- /dev/null +++ b/technic/machines/LV/electric_furnace.lua @@ -0,0 +1,16 @@ +-- LV Electric Furnace +-- This is a faster version of the stone furnace which runs on EUs + +-- FIXME: kpoppel I'd like to introduce an induction heating element here also +minetest.register_craft({ + output = 'technic:electric_furnace', + recipe = { + {'default:cobble', 'default:cobble', 'default:cobble'}, + {'default:cobble', 'technic:machine_casing', 'default:cobble'}, + {'default:cobble', 'technic:lv_cable0', 'default:cobble'}, + } +}) + +technic.register_electric_furnace({tier="LV", demand={300}, speed = 2}) + + diff --git a/technic/machines/LV/extractor.lua b/technic/machines/LV/extractor.lua new file mode 100644 index 0000000..363d2e3 --- /dev/null +++ b/technic/machines/LV/extractor.lua @@ -0,0 +1,13 @@ + +minetest.register_alias("extractor", "technic:lv_extractor") + +minetest.register_craft({ + output = 'technic:lv_extractor', + recipe = { + {'technic:treetap', 'technic:motor', 'technic:treetap'}, + {'technic:treetap', 'technic:machine_casing', 'technic:treetap'}, + {'', 'technic:lv_cable0', ''}, + } +}) + +technic.register_extractor({tier = "LV", demand = {300}, speed = 1}) diff --git a/technic/machines/LV/generator.lua b/technic/machines/LV/generator.lua new file mode 100644 index 0000000..999dbc5 --- /dev/null +++ b/technic/machines/LV/generator.lua @@ -0,0 +1,18 @@ +-- The electric generator. +-- A simple device to get started on the electric machines. +-- Inefficient and expensive in fuel (200EU per tick) +-- Also only allows for LV machinery to run. + +minetest.register_alias("lv_generator", "technic:lv_generator") + +minetest.register_craft({ + output = 'technic:lv_generator', + recipe = { + {'default:stone', 'default:furnace', 'default:stone'}, + {'default:stone', 'technic:machine_casing', 'default:stone'}, + {'default:stone', 'technic:lv_cable0', 'default:stone'}, + } +}) + +technic.register_generator({tier="LV", supply=200}) + diff --git a/technic/machines/LV/geothermal.lua b/technic/machines/LV/geothermal.lua new file mode 100644 index 0000000..e88d3c9 --- /dev/null +++ b/technic/machines/LV/geothermal.lua @@ -0,0 +1,111 @@ +-- A geothermal EU generator +-- Using hot lava and water this device can create energy from steam +-- The machine is only producing LV EUs and can thus not drive more advanced equipment +-- The output is a little more than the coal burning generator (max 300EUs) + +minetest.register_alias("geothermal", "technic:geothermal") + +local S = technic.getter + +minetest.register_craft({ + output = 'technic:geothermal', + recipe = { + {'technic:granite', 'default:diamond', 'technic:granite'}, + {'technic:fine_copper_wire', 'technic:machine_casing', 'technic:fine_copper_wire'}, + {'technic:granite', 'technic:lv_cable0', 'technic:granite'}, + } +}) + +minetest.register_craftitem("technic:geothermal", { + description = S("Geothermal %s Generator"):format("LV"), +}) + +local check_node_around = function(pos) + local node = minetest.get_node(pos) + if node.name == "default:water_source" or node.name == "default:water_flowing" then return 1 end + if node.name == "default:lava_source" or node.name == "default:lava_flowing" then return 2 end + return 0 +end + +local run = function(pos, node) + local meta = minetest.get_meta(pos) + local water_nodes = 0 + local lava_nodes = 0 + local production_level = 0 + local eu_supply = 0 + + -- Correct positioning is water on one side and lava on the other. + -- The two cannot be adjacent because the lava the turns into obsidian or rock. + -- To get to 100% production stack the water and lava one extra block down as well: + -- WGL (W=Water, L=Lava, G=the generator, |=an LV cable) + -- W|L + + local positions = { + {x=pos.x+1, y=pos.y, z=pos.z}, + {x=pos.x+1, y=pos.y-1, z=pos.z}, + {x=pos.x-1, y=pos.y, z=pos.z}, + {x=pos.x-1, y=pos.y-1, z=pos.z}, + {x=pos.x, y=pos.y, z=pos.z+1}, + {x=pos.x, y=pos.y-1, z=pos.z+1}, + {x=pos.x, y=pos.y, z=pos.z-1}, + {x=pos.x, y=pos.y-1, z=pos.z-1}, + } + for _, p in pairs(positions) do + local check = check_node_around(p) + if check == 1 then water_nodes = water_nodes + 1 end + if check == 2 then lava_nodes = lava_nodes + 1 end + end + + if water_nodes == 1 and lava_nodes == 1 then production_level = 25; eu_supply = 50 end + if water_nodes == 2 and lava_nodes == 1 then production_level = 50; eu_supply = 100 end + if water_nodes == 1 and lava_nodes == 2 then production_level = 75; eu_supply = 200 end + if water_nodes == 2 and lava_nodes == 2 then production_level = 100; eu_supply = 300 end + + if production_level > 0 then + meta:set_int("LV_EU_supply", eu_supply) + end + + meta:set_string("infotext", + S("Geothermal %s Generator"):format("LV").." ("..production_level.."%)") + + if production_level > 0 and minetest.get_node(pos).name == "technic:geothermal" then + technic.swap_node (pos, "technic:geothermal_active") + return + end + if production_level == 0 then + technic.swap_node(pos, "technic:geothermal") + meta:set_int("LV_EU_supply", 0) + end +end + +minetest.register_node("technic:geothermal", { + description = S("Geothermal %s Generator"):format("LV"), + tiles = {"technic_geothermal_top.png", "technic_machine_bottom.png", "technic_geothermal_side.png", + "technic_geothermal_side.png", "technic_geothermal_side.png", "technic_geothermal_side.png"}, + paramtype2 = "facedir", + groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, technic_machine=1}, + legacy_facedir_simple = true, + sounds = default.node_sound_wood_defaults(), + on_construct = function(pos) + local meta = minetest.get_meta(pos) + meta:set_string("infotext", S("Geothermal %s Generator"):format("LV")) + meta:set_int("LV_EU_supply", 0) + end, + technic_run = run, +}) + +minetest.register_node("technic:geothermal_active", { + description = S("Geothermal %s Generator"):format("LV"), + tiles = {"technic_geothermal_top_active.png", "technic_machine_bottom.png", "technic_geothermal_side.png", + "technic_geothermal_side.png", "technic_geothermal_side.png", "technic_geothermal_side.png"}, + paramtype2 = "facedir", + groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, not_in_creative_inventory=1}, + legacy_facedir_simple = true, + sounds = default.node_sound_wood_defaults(), + drop = "technic:geothermal", + technic_run = run, +}) + +technic.register_machine("LV", "technic:geothermal", technic.producer) +technic.register_machine("LV", "technic:geothermal_active", technic.producer) + diff --git a/technic/machines/LV/grinder.lua b/technic/machines/LV/grinder.lua new file mode 100644 index 0000000..da9ea29 --- /dev/null +++ b/technic/machines/LV/grinder.lua @@ -0,0 +1,13 @@ + +minetest.register_alias("grinder", "technic:lv_grinder") +minetest.register_craft({ + output = 'technic:lv_grinder', + recipe = { + {'default:desert_stone', 'default:diamond', 'default:desert_stone'}, + {'default:desert_stone', 'technic:machine_casing', 'default:desert_stone'}, + {'technic:granite', 'technic:lv_cable0', 'technic:granite'}, + } +}) + +technic.register_grinder({tier="LV", demand={200}, speed=1}) + diff --git a/technic/machines/LV/init.lua b/technic/machines/LV/init.lua new file mode 100644 index 0000000..30523c9 --- /dev/null +++ b/technic/machines/LV/init.lua @@ -0,0 +1,29 @@ + +technic.register_tier("LV", "Low Voltage") + +local path = technic.modpath.."/machines/LV" + +-- Wiring stuff +dofile(path.."/cables.lua") +dofile(path.."/battery_box.lua") + +-- Generators +dofile(path.."/solar_panel.lua") +dofile(path.."/solar_array.lua") +dofile(path.."/geothermal.lua") +dofile(path.."/water_mill.lua") +dofile(path.."/generator.lua") + +-- Machines +dofile(path.."/alloy_furnace.lua") +dofile(path.."/electric_furnace.lua") +dofile(path.."/grinder.lua") +dofile(path.."/extractor.lua") +dofile(path.."/compressor.lua") + +dofile(path.."/music_player.lua") + +dofile(path.."/cnc.lua") +dofile(path.."/cnc_api.lua") +dofile(path.."/cnc_nodes.lua") + diff --git a/technic/machines/LV/music_player.lua b/technic/machines/LV/music_player.lua new file mode 100644 index 0000000..dc7e2d0 --- /dev/null +++ b/technic/machines/LV/music_player.lua @@ -0,0 +1,130 @@ +-- LV Music player. +-- The player can play music. But it is high ampage! + +local S = technic.getter + +minetest.register_alias("music_player", "technic:music_player") +minetest.register_craft({ + output = 'technic:music_player', + recipe = { + {'technic:chromium_ingot', 'default:diamond', 'technic:chromium_ingot'}, + {'default:diamond', 'technic:machine_casing', 'default:diamond'}, + {'default:mossycobble', 'technic:lv_cable0', 'default:mossycobble'}, + } +}) + +local music_handles = {} + +local function play_track(pos, track) + return minetest.sound_play("technic_track"..tostring(track), + {pos = pos, gain = 1.0, loop = true, max_hear_distance = 72,}) +end + +local run = function(pos, node) + local meta = minetest.get_meta(pos) + local eu_input = meta:get_int("LV_EU_input") + local machine_name = S("%s Music Player"):format("LV") + local machine_node = "technic:music_player" + local demand = 150 + + local current_track = meta:get_int("current_track") + local pos_hash = minetest.hash_node_position(pos) + local music_handle = music_handles[pos_hash] + + -- Setup meta data if it does not exist. + if not eu_input then + meta:set_int("LV_EU_demand", demand) + meta:set_int("LV_EU_input", 0) + return + end + + if meta:get_int("active") == 0 then + meta:set_string("infotext", S("%s Idle"):format(machine_name)) + meta:set_int("LV_EU_demand", 0) + return + end + + if eu_input < demand then + meta:set_string("infotext", S("%s Unpowered"):format(machine_name)) + if music_handle then + minetest.sound_stop(music_handle) + music_handle = nil + end + elseif eu_input >= demand then + meta:set_string("infotext", S("%s Active"):format(machine_name)) + if not music_handle then + music_handle = play_track(pos, current_track) + end + end + music_handles[pos_hash] = music_handle + meta:set_int("LV_EU_demand", demand) +end + +local function stop_player(pos, node) + local pos_hash = minetest.hash_node_position(pos) + local music_handle = music_handles[pos_hash] + if music_handle then + minetest.sound_stop(music_handle) + music_handles[pos_hash] = nil + end +end + +local function set_display(meta) + meta:set_string("formspec", + "size[4,4.5]".. + "item_image[0,0;1,1;technic:music_player]".. + "label[1,0;"..S("%s Music Player"):format("LV").."]".. + "button[0,1;1,1;track1;1]".. + "button[1,1;1,1;track2;2]".. + "button[2,1;1,1;track3;3]".. + "button[0,2;1,1;track4;4]".. + "button[1,2;1,1;track5;5]".. + "button[2,2;1,1;track6;6]".. + "button[0,3;1,1;track7;7]".. + "button[1,3;1,1;track8;8]".. + "button[2,3;1,1;track9;9]".. + "button[3,1;1,1;stop;Stop]".. + "label[0,4;"..minetest.formspec_escape( + meta:get_int("active") == 0 and + S("Stopped") or + S("Current track %s"):format(meta:get_int("current_track"))).."]") +end + +minetest.register_node("technic:music_player", { + description = S("%s Music Player"):format("LV"), + tiles = {"technic_music_player_top.png", "technic_machine_bottom.png", "technic_music_player_side.png", + "technic_music_player_side.png", "technic_music_player_side.png", "technic_music_player_side.png"}, + groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, technic_machine=1}, + sounds = default.node_sound_wood_defaults(), + on_construct = function(pos) + local meta = minetest.get_meta(pos) + meta:set_string("infotext", S("%s Music Player"):format("LV")) + set_display(meta) + end, + on_receive_fields = function(pos, formanme, fields, sender) + local new_track = nil + if fields.stop then new_track = 0 end + if fields.track1 then new_track = 1 end + if fields.track2 then new_track = 2 end + if fields.track3 then new_track = 3 end + if fields.track4 then new_track = 4 end + if fields.track5 then new_track = 5 end + if fields.track6 then new_track = 6 end + if fields.track7 then new_track = 7 end + if fields.track8 then new_track = 8 end + if fields.track9 then new_track = 9 end + if new_track then + stop_player(pos) + local meta = minetest.get_meta(pos) + meta:set_int("active", new_track == 0 and 0 or 1) + meta:set_int("current_track", new_track) + set_display(meta) + end + end, + on_destruct = stop_player, + technic_run = run, + technic_on_disable = stop_player, +}) + +technic.register_machine("LV", "technic:music_player", technic.receiver) + diff --git a/technic/machines/LV/solar_array.lua b/technic/machines/LV/solar_array.lua new file mode 100644 index 0000000..4d2c3b3 --- /dev/null +++ b/technic/machines/LV/solar_array.lua @@ -0,0 +1,18 @@ +-- The solar array is an assembly of panels into a powerful array +-- The assembly can deliver more energy than the individual panel because +-- of the transformer unit which converts the panel output variations into +-- a stable supply. +-- Solar arrays are not able to store large amounts of energy. +-- The LV arrays are used to make medium voltage arrays. + +minetest.register_craft({ + output = 'technic:solar_array_lv 1', + recipe = { + {'technic:solar_panel', 'technic:solar_panel', 'technic:solar_panel'}, + {'technic:carbon_steel_ingot', 'technic:lv_transformer', 'technic:carbon_steel_ingot'}, + {'', 'technic:lv_cable0', ''}, + } +}) + +technic.register_solar_array({tier="LV", power=10}) + diff --git a/technic/machines/LV/solar_panel.lua b/technic/machines/LV/solar_panel.lua new file mode 100644 index 0000000..41dff95 --- /dev/null +++ b/technic/machines/LV/solar_panel.lua @@ -0,0 +1,67 @@ +-- Solar panels are the building blocks of LV solar arrays +-- They can however also be used separately but with reduced efficiency due to the missing transformer. +-- Individual panels are less efficient than when the panels are combined into full arrays. + +local S = technic.getter + +local run = function(pos, node) + -- The action here is to make the solar panel prodice power + -- Power is dependent on the light level and the height above ground + -- There are many ways to cheat by using other light sources like lamps. + -- As there is no way to determine if light is sunlight that is just a shame. + -- To take care of some of it solar panels do not work outside daylight hours or if + -- built below 0m + local pos1 = {x=pos.x, y=pos.y+1, z=pos.z} + local machine_name = S("Small Solar %s Generator"):format("LV") + + local light = minetest.get_node_light(pos1, nil) + local time_of_day = minetest.get_timeofday() + local meta = minetest.get_meta(pos) + if light == nil then light = 0 end + -- turn on panel only during day time and if sufficient light + -- I know this is counter intuitive when cheating by using other light sources underground. + if light >= 12 and time_of_day >= 0.24 and time_of_day <= 0.76 and pos.y > -10 then + local charge_to_give = math.floor((light + pos1.y) * 3) + charge_to_give = math.max(charge_to_give, 0) + charge_to_give = math.min(charge_to_give, 200) + meta:set_string("infotext", S("@1 Active (@2 EU)", machine_name, technic.prettynum(charge_to_give))) + meta:set_int("LV_EU_supply", charge_to_give) + else + meta:set_string("infotext", S("%s Idle"):format(machine_name)) + meta:set_int("LV_EU_supply", 0) + end +end + +minetest.register_node("technic:solar_panel", { + tiles = {"technic_solar_panel_top.png", "technic_solar_panel_bottom.png", "technic_solar_panel_side.png", + "technic_solar_panel_side.png", "technic_solar_panel_side.png", "technic_solar_panel_side.png"}, + groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, technic_machine=1}, + sounds = default.node_sound_wood_defaults(), + description = S("Small Solar %s Generator"):format("LV"), + active = false, + drawtype = "nodebox", + paramtype = "light", + is_ground_content = true, + node_box = { + type = "fixed", + fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5}, + }, + on_construct = function(pos) + local meta = minetest.get_meta(pos) + meta:set_int("LV_EU_supply", 0) + meta:set_string("infotext", S("Small Solar %s Generator"):format("LV")) + end, + technic_run = run, +}) + +minetest.register_craft({ + output = 'technic:solar_panel', + recipe = { + {'technic:doped_silicon_wafer', 'technic:doped_silicon_wafer', 'technic:doped_silicon_wafer'}, + {'technic:fine_silver_wire', 'technic:lv_cable0', 'mesecons_materials:glue'}, + + } +}) + +technic.register_machine("LV", "technic:solar_panel", technic.producer) + diff --git a/technic/machines/LV/water_mill.lua b/technic/machines/LV/water_mill.lua new file mode 100644 index 0000000..9088d1d --- /dev/null +++ b/technic/machines/LV/water_mill.lua @@ -0,0 +1,102 @@ +-- A water mill produces LV EUs by exploiting flowing water across it +-- It is a LV EU supplyer and fairly low yield (max 120EUs) +-- It is a little under half as good as the thermal generator. + +local S = technic.getter + +minetest.register_alias("water_mill", "technic:water_mill") + +minetest.register_craft({ + output = 'technic:water_mill', + recipe = { + {'technic:marble', 'default:diamond', 'technic:marble'}, + {'group:wood', 'technic:machine_casing', 'group:wood'}, + {'technic:marble', 'technic:lv_cable0', 'technic:marble'}, + } +}) + +local function check_node_around_mill(pos) + local node = minetest.get_node(pos) + if node.name == "default:water_flowing" or + node.name == "default:water_source" then + return true + end + return false +end + +local run = function(pos, node) + local meta = minetest.get_meta(pos) + local water_nodes = 0 + local lava_nodes = 0 + local production_level = 0 + local eu_supply = 0 + + local positions = { + {x=pos.x+1, y=pos.y, z=pos.z}, + {x=pos.x-1, y=pos.y, z=pos.z}, + {x=pos.x, y=pos.y, z=pos.z+1}, + {x=pos.x, y=pos.y, z=pos.z-1}, + } + + for _, p in pairs(positions) do + local check = check_node_around_mill(p) + if check then + water_nodes = water_nodes + 1 + end + end + + production_level = 25 * water_nodes + eu_supply = 30 * water_nodes + + if production_level > 0 then + meta:set_int("LV_EU_supply", eu_supply) + end + + meta:set_string("infotext", + S("Hydro %s Generator"):format("LV").." ("..production_level.."%)") + + if production_level > 0 and + minetest.get_node(pos).name == "technic:water_mill" then + technic.swap_node (pos, "technic:water_mill_active") + meta:set_int("LV_EU_supply", 0) + return + end + if production_level == 0 then + technic.swap_node(pos, "technic:water_mill") + end +end + +minetest.register_node("technic:water_mill", { + description = S("Hydro %s Generator"):format("LV"), + tiles = {"technic_water_mill_top.png", "technic_machine_bottom.png", + "technic_water_mill_side.png", "technic_water_mill_side.png", + "technic_water_mill_side.png", "technic_water_mill_side.png"}, + paramtype2 = "facedir", + groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, technic_machine=1}, + legacy_facedir_simple = true, + sounds = default.node_sound_wood_defaults(), + on_construct = function(pos) + local meta = minetest.get_meta(pos) + meta:set_string("infotext", S("Hydro %s Generator"):format("LV")) + meta:set_int("LV_EU_supply", 0) + end, + technic_run = run, +}) + +minetest.register_node("technic:water_mill_active", { + description = S("Hydro %s Generator"):format("LV"), + tiles = {"technic_water_mill_top_active.png", "technic_machine_bottom.png", + "technic_water_mill_side.png", "technic_water_mill_side.png", + "technic_water_mill_side.png", "technic_water_mill_side.png"}, + paramtype2 = "facedir", + groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, technic_machine=1, not_in_creative_inventory=1}, + legacy_facedir_simple = true, + sounds = default.node_sound_wood_defaults(), + drop = "technic:water_mill", + technic_run = run, + technic_disabled_machine_name = "technic:water_mill", +}) + +technic.register_machine("LV", "technic:water_mill", technic.producer) +technic.register_machine("LV", "technic:water_mill_active", technic.producer) + -- cgit v1.2.3