diff --git a/doc/manual_ta2_DE.lua b/doc/manual_ta2_DE.lua index 99b1fd0..c572c6d 100644 --- a/doc/manual_ta2_DE.lua +++ b/doc/manual_ta2_DE.lua @@ -12,6 +12,7 @@ return { "2,TA2 Energiespeicher", "3,TA2 Seilwinde / TA2 Winch", "3,TA2 Gewichtekiste / TA2 Weight Chest", + "3,TA2 Kupplung / TA2 Clutch", "2,Items schieben und sortieren", "3,Röhren / TechAge Tube", "3,Röhren Konzentrator / Tube Concentrator", @@ -107,6 +108,10 @@ return { "\n".. "\n".. "\n", + "Mit der Kupplung können Achsen und Maschinen vom Energiespeicher getrennt werden. Damit kommen die Achsen nach der Kupplung zum Stillstand und Maschinenanlagen können umgebaut werden.\n".. + "\n".. + "\n".. + "\n", "Um Gegenstände (Items) von einer Verarbeitungsstation zur nächsten weiter zu transportieren\\, werden Schieber und Röhren verwendet. Siehe Plan.\n".. "\n".. "\n".. @@ -247,6 +252,7 @@ return { "", "ta2_winch", "ta2_weight_chest", + "techage:ta2_clutch_off", "", "tube", "concentrator", @@ -279,6 +285,7 @@ return { "ta2_storage", "", "", + "", "itemtransport", "", "", diff --git a/doc/manual_ta2_EN.lua b/doc/manual_ta2_EN.lua index 60d7faa..ccf29d7 100644 --- a/doc/manual_ta2_EN.lua +++ b/doc/manual_ta2_EN.lua @@ -12,6 +12,7 @@ return { "2,TA2 energy storage", "3,TA2 Winch", "3,TA2 Weight Chest", + "3,TA2 Clutch", "2,Push and sort items", "3,TechAge Tube", "3,Tube Concentrator", @@ -105,6 +106,10 @@ return { "\n".. "\n".. "\n", + "With the clutch\\, axles and machines can be separated from the energy storage. This means that the axles after the clutch come to a standstill and machine systems can be rebuilt.\n".. + "\n".. + "\n".. + "\n", "In order to transport objects from one processing station to the next\\, pushers and tubes are used. See plan.\n".. "\n".. "\n".. @@ -245,6 +250,7 @@ return { "", "ta2_winch", "ta2_weight_chest", + "techage:ta2_clutch_off", "", "tube", "concentrator", @@ -277,6 +283,7 @@ return { "ta2_storage", "", "", + "", "itemtransport", "", "", diff --git a/doc/plans.lua b/doc/plans.lua index 82078cb..818db16 100644 --- a/doc/plans.lua +++ b/doc/plans.lua @@ -175,6 +175,7 @@ local AXL90 = {"techage_axle.png^[transformR90", "techage:axle"} local WINCH = {"techage_filling_ta2.png^techage_appl_winch.png^techage_frame_ta2.png", "techage:ta2_winch"} local ROPE_ = {"techage_rope_inv.png", "techage:ta2_rope"} local WCHST = {"techage_filling_ta2.png^techage_frame_ta2.png^techage_appl_chest_back_ta3.png^techage_weight_side.png", "techage:ta2_weight_chest"} +local CLTCH = {"techage_filling_ta2.png^techage_appl_clutch.png^techage_frame_ta2.png", "techage:ta2_clutch_off"} plans["ta2_storage"] = { {false, false, false, GRBOX, WINCH, false, SIDEV}, @@ -186,7 +187,7 @@ plans["ta2_storage"] = { {false, false, false, AXL90, ROPE_, false, false}, {false, false, false, AXL90, WCHST, false, false}, {false, false, false, AXL90, false, false, false}, - {AXL00, AXL00, AXL00, GRBOX, false, false, false}, + {AXL00, CLTCH, AXL00, GRBOX, false, false, false}, } -- diff --git a/init.lua b/init.lua index e2d5797..fc1c391 100644 --- a/init.lua +++ b/init.lua @@ -166,6 +166,7 @@ dofile(MP.."/steam_engine/flywheel.lua") dofile(MP.."/ta2_energy_storage/ta2_rope.lua") dofile(MP.."/ta2_energy_storage/ta2_winch.lua") dofile(MP.."/ta2_energy_storage/ta2_weight_chest.lua") +dofile(MP.."/ta2_energy_storage/ta2_clutch.lua") -- Liquids I dofile(MP.."/liquids/liquid_pipe.lua") diff --git a/locale/techage.de.tr b/locale/techage.de.tr index 3f3c2ff..8d82605 100644 --- a/locale/techage.de.tr +++ b/locale/techage.de.tr @@ -1347,7 +1347,7 @@ TA1 Axle Bearing=TA1 Achsenlager ### ta2_clutch.lua ### -TA2 Clutch= +TA2 Clutch=TA2 Kupplung ### ta2_weight_chest.lua ### diff --git a/manuals/manual_ta2_DE.md b/manuals/manual_ta2_DE.md index 493db80..5d29a33 100644 --- a/manuals/manual_ta2_DE.md +++ b/manuals/manual_ta2_DE.md @@ -109,6 +109,14 @@ Diese Kiste muss mit bis zu 10 Blöcken Abstand unter die Seilwinde gesetzt und +### TA2 Kupplung / TA2 Clutch + +Mit der Kupplung können Achsen und Maschinen vom Energiespeicher getrennt werden. Damit kommen die Achsen nach der Kupplung zum Stillstand und Maschinenanlagen können umgebaut werden. + +[techage:ta2_clutch_off|image] + + + ## Items schieben und sortieren Um Gegenstände (Items) von einer Verarbeitungsstation zur nächsten weiter zu transportieren, werden Schieber und Röhren verwendet. Siehe Plan. diff --git a/manuals/manual_ta2_EN.md b/manuals/manual_ta2_EN.md index 2bd5ce6..789c24a 100644 --- a/manuals/manual_ta2_EN.md +++ b/manuals/manual_ta2_EN.md @@ -108,6 +108,14 @@ This chest must be placed under the winch with a distance of up to 10 blocks and +### TA2 Clutch + +With the clutch, axles and machines can be separated from the energy storage. This means that the axles after the clutch come to a standstill and machine systems can be rebuilt. + +[techage:ta2_clutch_off|image] + + + ## Push and sort items In order to transport objects from one processing station to the next, pushers and tubes are used. See plan. diff --git a/ta2_energy_storage/ta2_clutch.lua b/ta2_energy_storage/ta2_clutch.lua new file mode 100644 index 0000000..55dda22 --- /dev/null +++ b/ta2_energy_storage/ta2_clutch.lua @@ -0,0 +1,185 @@ +--[[ + + TechAge + ======= + + Copyright (C) 2019-2023 Joachim Stolberg + + AGPL v3 + See LICENSE.txt for more information + + TA2 Axle clutch + +]]-- + +-- for lazy programmers +local P2S = minetest.pos_to_string +local M = minetest.get_meta +local S = techage.S + +local CYCLE_TIME = 2 +local PWR_PERF = 100 +local DESCR = S("TA2 Clutch") + +local Axle = techage.Axle +local power = networks.power + +-- Axles texture animation +local function switch_axles(pos, on) + local outdir = M(pos):get_int("outdir") + Axle:switch_tube_line(pos, outdir, on and "on" or "off") +end + +local function start_node(pos, nvm, state) + local outdir = M(pos):get_int("outdir") + switch_axles(pos, true) + nvm.load = 0 + power.start_storage_calc(pos, Axle, outdir) + outdir = networks.Flip[outdir] + power.start_storage_calc(pos, Axle, outdir) +end + +local function stop_node(pos, nvm, state) + local outdir = M(pos):get_int("outdir") + switch_axles(pos, false) + power.start_storage_calc(pos, Axle, outdir) + outdir = networks.Flip[outdir] + power.start_storage_calc(pos, Axle, outdir) +end + +local State = techage.NodeStates:new({ + node_name_passive = "techage:ta2_clutch_off", + node_name_active = "techage:ta2_clutch_on", + infotext_name = DESCR, + cycle_time = CYCLE_TIME, + standby_ticks = 0, + start_node = start_node, + stop_node = stop_node, +}) + +local function node_timer(pos, elapsed) + local nvm = techage.get_nvm(pos) + local outdir2 = M(pos):get_int("outdir") + local outdir1 = networks.Flip[outdir2] + local data = power.transfer_duplex(pos, Axle, outdir1, Axle, outdir2, PWR_PERF) + local power_flow = (data.curr_load1 == 0 and data.curr_load2 == 0) or (data.curr_load1 > 0 and data.curr_load2 > 0) + if not power_flow then + power.start_storage_calc(pos, Axle, outdir1) + power.start_storage_calc(pos, Axle, outdir2) + end + return true +end + +local function on_rightclick(pos, node, clicker) + local nvm = techage.get_nvm(pos) + if techage.is_running(nvm) then + State:stop(pos, nvm) + else + State:start(pos, nvm) + end + minetest.sound_play("techage_button", { + pos = pos, + gain = 0.5, + max_hear_distance = 5}) +end + +local function after_place_node(pos, placer, itemstack) + local meta = M(pos) + local nvm = techage.get_nvm(pos) + local own_num = techage.add_node(pos, "techage:ta2_clutch_off") + meta:set_string("owner", placer:get_player_name()) + local outdir = networks.side_to_outdir(pos, "R") + meta:set_int("outdir", outdir) + Axle:after_place_node(pos, {outdir, networks.Flip[outdir]}) + State:node_init(pos, nvm, own_num) +end + +local function after_dig_node(pos, oldnode, oldmetadata, digger) + local outdir = tonumber(oldmetadata.fields.outdir or 0) + Axle:after_dig_node(pos, {outdir, networks.Flip[outdir]}) + techage.del_mem(pos) +end + +local function get_generator_data(pos, outdir, tlib2) + local nvm = techage.get_nvm(pos) + if techage.is_running(nvm) then + return {level = (nvm.load or 0) / PWR_PERF, perf = PWR_PERF, capa = PWR_PERF * 2} + end +end + +minetest.register_node("techage:ta2_clutch_off", { + description = DESCR, + tiles = { + -- up, down, right, left, back, front + "techage_filling_ta2.png^techage_frame_ta2_top.png", + "techage_filling_ta2.png^techage_frame_ta2.png", + "techage_filling_ta2.png^techage_frame_ta2.png^techage_axle_gearbox.png", + "techage_filling_ta2.png^techage_frame_ta2.png^techage_axle_gearbox.png", + "techage_filling_ta2.png^techage_appl_clutch.png^techage_frame_ta2.png", + "techage_filling_ta2.png^techage_appl_clutch.png^techage_frame_ta2.png", + }, + + on_timer = node_timer, + on_rightclick = on_rightclick, + after_place_node = after_place_node, + after_dig_node = after_dig_node, + get_generator_data = get_generator_data, + paramtype2 = "facedir", + groups = {cracky=2, crumbly=2, choppy=2}, + on_rotate = screwdriver.disallow, + is_ground_content = false, + sounds = default.node_sound_wood_defaults(), +}) + +minetest.register_node("techage:ta2_clutch_on", { + description = DESCR, + tiles = { + -- up, down, right, left, back, front + "techage_filling_ta2.png^techage_frame_ta2_top.png", + "techage_filling_ta2.png^techage_frame_ta2.png", + { + name = "techage_filling4_ta2.png^techage_axle_gearbox4.png^techage_frame4_ta2.png", + backface_culling = false, + animation = { + type = "vertical_frames", + aspect_w = 32, + aspect_h = 32, + length = 0.6, + }, + }, + { + name = "techage_filling4_ta2.png^techage_axle_gearbox4.png^techage_frame4_ta2.png", + backface_culling = false, + animation = { + type = "vertical_frames", + aspect_w = 32, + aspect_h = 32, + length = 0.6, + }, + }, + "techage_filling_ta2.png^techage_appl_clutch_on.png^techage_frame_ta2.png", + "techage_filling_ta2.png^techage_appl_clutch_on.png^techage_frame_ta2.png", + }, + + on_timer = node_timer, + on_rightclick = on_rightclick, + get_generator_data = get_generator_data, + paramtype2 = "facedir", + drop = "", + groups = {not_in_creative_inventory=1}, + diggable = false, + on_rotate = screwdriver.disallow, + is_ground_content = false, + sounds = default.node_sound_wood_defaults(), +}) + +power.register_nodes({"techage:ta2_clutch_off", "techage:ta2_clutch_on"}, Axle, "gen", {"R", "L"}) + +minetest.register_craft({ + output = "techage:ta2_clutch_off", + recipe = { + {"default:junglewood", "techage:axle", "default:wood"}, + {"techage:axle", "basic_materials:gear_steel", "techage:axle"}, + {"default:wood", "techage:axle", "default:junglewood"}, + }, +}) diff --git a/textures/techage_appl_clutch.png b/textures/techage_appl_clutch.png new file mode 100644 index 0000000..b5d7240 Binary files /dev/null and b/textures/techage_appl_clutch.png differ diff --git a/textures/techage_appl_clutch_on.png b/textures/techage_appl_clutch_on.png new file mode 100644 index 0000000..0ea4611 Binary files /dev/null and b/textures/techage_appl_clutch_on.png differ