From c44e26c00b73a26b2fd97557714778124efce871 Mon Sep 17 00:00:00 2001 From: ademant Date: Wed, 31 Oct 2018 14:37:06 +0100 Subject: [PATCH] #1 start integration of technic mod --- battery_box.lua | 20 +++++ cables.lua | 14 +++ generator.lua | 18 ++++ grinder.lua | 13 +++ init.lua | 1 + technic.lua | 20 +++++ texture/farming_technic_oven_back.png | Bin 0 -> 93 bytes texture/farming_technic_oven_bottom.png | Bin 0 -> 91 bytes texture/farming_technic_oven_front.png | Bin 0 -> 110 bytes texture/farming_technic_oven_sides.png | Bin 0 -> 84 bytes texture/farming_technic_oven_top.png | Bin 0 -> 149 bytes water_mill.lua | 109 ++++++++++++++++++++++++ 12 files changed, 195 insertions(+) create mode 100644 battery_box.lua create mode 100644 cables.lua create mode 100644 generator.lua create mode 100644 grinder.lua create mode 100644 technic.lua create mode 100755 texture/farming_technic_oven_back.png create mode 100755 texture/farming_technic_oven_bottom.png create mode 100755 texture/farming_technic_oven_front.png create mode 100755 texture/farming_technic_oven_sides.png create mode 100755 texture/farming_technic_oven_top.png create mode 100644 water_mill.lua diff --git a/battery_box.lua b/battery_box.lua new file mode 100644 index 0000000..b30c15a --- /dev/null +++ b/battery_box.lua @@ -0,0 +1,20 @@ +-- VP Flywheel + +minetest.register_craft({ + output = 'farming_technic:vp_battery_box0', + recipe = { + {'group:wood', 'group:wood', 'group:wood'}, + {'farming_technic:flywheel', 'farming_technic:gear', 'farming_technic:flywheel'}, + {'farming_technic:flywheel', 'farming_technic:vp_cable', 'farming_technic:flywheel'}, + } +}) + +technic.register_battery_box({ + tier = "VP", + max_charge = 20000, + charge_rate = 150, + discharge_rate = 400, + charge_step = 50, + discharge_step = 80, +}) + diff --git a/cables.lua b/cables.lua new file mode 100644 index 0000000..e8d8b88 --- /dev/null +++ b/cables.lua @@ -0,0 +1,14 @@ + +minetest.register_alias("vp_cable", "farming_technic:vp_cable") + +minetest.register_craft({ + output = 'farming_technic:vp_cable 6', + recipe = { + {'group:wool', 'group:wool', 'group:wool'}, + {'group:wood', 'group:wood', 'group:wood'}, + {'group:wool', 'group:wool', 'group:wool'}, + } +}) + +technic.register_cable("VP", 2/16) + diff --git a/generator.lua b/generator.lua new file mode 100644 index 0000000..f1a5b1d --- /dev/null +++ b/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("vp_generator", "farming_technic:vp_generator") + +minetest.register_craft({ + output = 'farming_technic:vp_generator', + recipe = { + {'default:stone', 'default:furnace', 'default:stone'}, + {'default:stone', 'farming_technic:boiler', 'default:stone'}, + {'default:stone', 'farming_technic:vp_cable', 'default:stone'}, + } +}) + +technic.register_generator({tier="VP", supply=150}) + diff --git a/grinder.lua b/grinder.lua new file mode 100644 index 0000000..6a51503 --- /dev/null +++ b/grinder.lua @@ -0,0 +1,13 @@ + +--minetest.register_alias("grinder", "technic:lv_grinder") +minetest.register_craft({ + output = 'farming_technic:vp_grinder', + recipe = { + {'default:desert_stone', 'default:diamond', 'default:desert_stone'}, + {'default:desert_stone', 'farming_technic:gear', 'default:desert_stone'}, + {'technic:granite', 'farming_technic:vp_cable', 'technic:granite'}, + } +}) + +technic.register_grinder({tier="VP", demand={150}, speed=0.65}) + diff --git a/init.lua b/init.lua index 918e356..aba0698 100644 --- a/init.lua +++ b/init.lua @@ -13,6 +13,7 @@ minetest.log("action", "[MOD]"..minetest.get_current_modname().." -- start loadi dofile(farming_technic.path .. "/craft.lua") +dofile(farming_technic.path .. "/technic.lua") diff --git a/technic.lua b/technic.lua new file mode 100644 index 0000000..3c90521 --- /dev/null +++ b/technic.lua @@ -0,0 +1,20 @@ + + +if minetest.get_modpath("technic") ~= nil then + technic.register_tier("VP", "Vapor driven") + + local path = farming_technic.modpath + + -- Wiring stuff + dofile(path.."/cables.lua") + dofile(path.."/battery_box.lua") + + -- Generators + dofile(path.."/water_mill.lua") + dofile(path.."/generator.lua") + + -- Machines + dofile(path.."/vapor_furnace.lua") + dofile(path.."/grinder.lua") + +end diff --git a/texture/farming_technic_oven_back.png b/texture/farming_technic_oven_back.png new file mode 100755 index 0000000000000000000000000000000000000000..cb2be26f6f66c09efcd5e50b16523362fc26f384 GIT binary patch literal 93 zcmeAS@N?(olHy`uVBq!ia0vp^0wBx*Bp9q_EZ7UAR6JcALn;`PXEd`(Je#qIL4{G2 pkB?6@g^^D{!IvSC%}BzAiQ(EV=f2+-7og|;-!iU36N3!a6CY$4w!KxAytj70Q zU{Gn$$!8I>;AIbBWLdDhVPfDOK>-I1ojO7B`O18(32F?R=Ct3oIipbuGRV`_&t;uc GLK6VaHyRfJ literal 0 HcmV?d00001 diff --git a/texture/farming_technic_oven_sides.png b/texture/farming_technic_oven_sides.png new file mode 100755 index 0000000000000000000000000000000000000000..e654797da48c36f08f4070a064e0fb5dc03ec47d GIT binary patch literal 84 zcmeAS@N?(olHy`uVBq!ia0vp^0wBx*Bp9q_EZ7UAq&;06Ln;`PXEd{I;GE;eB%#%| gqv3~4p#?(`!>T#ce-<*d=Yy1cy85}Sb4q9e0OVK|Y5)KL literal 0 HcmV?d00001 diff --git a/texture/farming_technic_oven_top.png b/texture/farming_technic_oven_top.png new file mode 100755 index 0000000000000000000000000000000000000000..00eadee1d1de90619523b2f037acf0d7fb4f6988 GIT binary patch literal 149 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61SBU+%rFB|F`h1tAr*|tGn|zeG7VIv1THLC zwCE5cvxAuvbBvT0BeTp3hJ}p2Qq$QcFVdQ&MBb@09yemv;Y7A literal 0 HcmV?d00001 diff --git a/water_mill.lua b/water_mill.lua new file mode 100644 index 0000000..b578a0d --- /dev/null +++ b/water_mill.lua @@ -0,0 +1,109 @@ +-- A water mill produces LV EUs by exploiting flowing water across it +-- It is a LV EU supplyer and fairly low yield (max 180EUs) +-- It is a little over half as good as the thermal generator. + +local S = technic.getter + +local cable_entry = "^technic_cable_connection_overlay.png" + +--minetest.register_alias("water_mill", "technic:water_mill") + +minetest.register_craft({ + output = 'farming_technic:water_mill', + recipe = { + {'technic:marble', 'default:diamond', 'technic:marble'}, + {'group:wood', 'farming_technic:gear', 'group:wood'}, + {'technic:marble', 'farming_technic:vp_cable', '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:river_water_flowing" then + return node.param2 -- returns approx. water flow, if any + end + return false +end + +local run = function(pos, node) + local meta = minetest.get_meta(pos) + local water_flow = 0 + local production_level = 0 + local eu_supply = 0 + local max_output = 4 * 40 -- keeping it around 180, little more than previous 150 :) + + 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_flow = water_flow + check + end + end + + eu_supply = math.min(4 * water_flow, max_output) + production_level = math.floor(100 * eu_supply / max_output) + + meta:set_int("VP_EU_supply", eu_supply) + + meta:set_string("infotext", + S("Hydro %s Generator"):format("VP").." ("..production_level.."%)") + + if production_level > 0 and + minetest.get_node(pos).name == "farming_technic:water_mill" then + technic.swap_node (pos, "farming_technic:water_mill_active") + meta:set_int("VP_EU_supply", 0) + return + end + if production_level == 0 then + technic.swap_node(pos, "farming_technic:water_mill") + end +end + +minetest.register_node("farming_technic:water_mill", { + description = S("Hydro %s Generator"):format("VP"), + tiles = { + "technic_water_mill_top.png", + "technic_machine_bottom.png"..cable_entry, + "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, technic_vp=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("VP")) + meta:set_int("VP_EU_supply", 0) + end, + technic_run = run, +}) + +minetest.register_node("technic:water_mill_active", { + description = S("Hydro %s Generator"):format("VP"), + 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, technic_vp=1, not_in_creative_inventory=1}, + legacy_facedir_simple = true, + sounds = default.node_sound_wood_defaults(), + drop = "farming_technic:water_mill", + technic_run = run, + technic_disabled_machine_name = "farming_technic:water_mill", +}) + +technic.register_machine("VP", "farming_technic:water_mill", technic.producer) +technic.register_machine("VP", "farming_technic:water_mill_active", technic.producer) +