diff --git a/basic_machines/autocrafter.lua b/basic_machines/autocrafter.lua index 8618b38..ac804ea 100644 --- a/basic_machines/autocrafter.lua +++ b/basic_machines/autocrafter.lua @@ -3,7 +3,7 @@ TechAge ======= - Copyright (C) 2019-2020 Joachim Stolberg + Copyright (C) 2019-2023 Joachim Stolberg AGPL v3 See LICENSE.txt for more information diff --git a/basis/command.lua b/basis/command.lua index 584adbe..85ee760 100644 --- a/basis/command.lua +++ b/basis/command.lua @@ -283,6 +283,18 @@ function techage.pack_node(pos, oldnode, number) end end +------------------------------------------------------------------- +-- Used by the assembly tool +------------------------------------------------------------------- +function techage.pre_add_node(pos, number) + local key = minetest.hash_node_position(pos) + NumbersToBeRecycled[key] = number +end + +function techage.post_remove_node(pos) + local key = minetest.hash_node_position(pos) + NumbersToBeRecycled[key] = nil +end ------------------------------------------------------------------- -- Node register function diff --git a/doc/manual_ta3_DE.lua b/doc/manual_ta3_DE.lua index f2f7b8b..2fbda2d 100644 --- a/doc/manual_ta3_DE.lua +++ b/doc/manual_ta3_DE.lua @@ -84,7 +84,8 @@ return { "3,TechAge Programmer", "3,TechAge Kelle / Trowel", "3,TA3 Bohrgestängezange / TA3 Drill Pipe Wrench", - "3,Techage Schraubendreher", + "3,Techage Schraubendreher / Screwdriver", + "3,TechAge Montagewerkzeug / Assembly Tool", }, texts = { "Bei TA3 gilt es\\, die Dampf-betriebenen Maschinen durch leistungsfähigere und mit elektrischem Strom betriebene Maschinen abzulösen.\n".. @@ -741,6 +742,15 @@ return { "\n".. "\n".. "\n", + "Das TechAge Montagewerkzeug dient zum Entfernen und wieder Setzen von Techage Blöcken\\, ohne dass diese Blöcke ihre Blocknummer verlieren\\, bzw. beim Setzen eine neue Nummer zugeteilt bekommen. Dies ist bspw. bei Steinbrechern hilfreich\\, da diese oft umgesetzt werden müssen.\n".. + "\n".. + " - Linke Taste: Entfernen eines Blocks\n".. + " - Rechte Taste: Setzen eines Blocks\n".. + "\n".. + "Der Block\\, der zuvor mit dem Montagewerkzeug entfernt wurde und wieder gesetzt werden soll\\, muss sich im Spieler-Inventar ganz links befinden.\n".. + "\n".. + "\n".. + "\n", }, images = { "techage_ta3", @@ -828,6 +838,7 @@ return { "ta3_trowel", "ta3_drill_pipe_wrench", "ta3_screwdriver", + "techage:assembly_tool", }, plans = { "", @@ -915,5 +926,6 @@ return { "", "", "", + "", } } \ No newline at end of file diff --git a/doc/manual_ta3_EN.lua b/doc/manual_ta3_EN.lua index fcd2c3e..2ea25d7 100644 --- a/doc/manual_ta3_EN.lua +++ b/doc/manual_ta3_EN.lua @@ -85,6 +85,7 @@ return { "3,TechAge Trowel / Trowel", "3,TA3 drill pipe wrench", "3,Techage Screwdriver", + "3,TechAge Assembly Tool", }, texts = { "At TA3 it is important to replace the steam-powered machines with more powerful and electric-powered machines.\n".. @@ -738,6 +739,15 @@ return { "\n".. " \n".. "\n", + "The TechAge Assembly Tool is used to remove and reposition Techage blocks without these blocks losing their block number or being assigned a new number when setting. This is helpful\\, for example\\, for quarries\\, as they often have to be moved.\n".. + "\n".. + " - Left button: Remove a block\n".. + " - Right button: Set a block\n".. + "\n".. + "The block that was previously removed with the assembly tool and is to be placed again must be on the far left of the player inventory.\n".. + "\n".. + "\n".. + "\n", }, images = { "techage_ta3", @@ -825,6 +835,7 @@ return { "ta3_trowel", "ta3_drill_pipe_wrench", "ta3_screwdriver", + "techage:assembly_tool", }, plans = { "", @@ -912,5 +923,6 @@ return { "", "", "", + "", } } \ No newline at end of file diff --git a/init.lua b/init.lua index fc1c391..eb3491e 100644 --- a/init.lua +++ b/init.lua @@ -226,7 +226,8 @@ dofile(MP.."/furnace/recipes.lua") -- Tools dofile(MP.."/tools/trowel.lua") -dofile(MP.."/tools/repairkit.lua") +dofile(MP.."/tools/end_wrench.lua") +dofile(MP.."/tools/assembly_tool.lua") dofile(MP.."/tools/pipe_wrench.lua") dofile(MP.."/basic_machines/blackhole.lua") dofile(MP.."/basic_machines/forceload.lua") diff --git a/locale/techage.de.tr b/locale/techage.de.tr index b1f05be..6a40183 100644 --- a/locale/techage.de.tr +++ b/locale/techage.de.tr @@ -21,6 +21,10 @@ Red Mud Canister=Rotschlamm Kanister [TA] Area is protected!=[TA] Bereich ist geschützt [TA] Not enough space!=[TA] Nicht ausreichend Platz! +### assembly_tool.lua ### + +TechAge Assembly Tool=TechAge Montagewerkzeug + ### autocrafter.lua ### Autocrafter=Autocrafter @@ -482,6 +486,21 @@ TA2 Ele Fab=TA2 E-Fabrik TA3 Ele Fab=TA3 E-Fabrik TA4 Ele Fab=TA4 E-Fabrik +### end_wrench.lua ### + +Biome=Biom +Node owner=Blockbesitzer +Position=Position +Position temperature=Positionstemperatur +Pump connected to no/empty tank(s).=Pumpe an keine/leere Tank(s) angeschlossen. +Pump connected to tank(s) with: @1=Pumpe an Tank(s) angeschlossen mit: @1 +TechAge Info Tool (use @= read status info)=TechAge Info Werkzeug + +### end_wrench.lua ### +### meltingpot.lua ### + +Time=Zeit + ### epoxy.lua ### Epoxide Resin=Epoxidharz @@ -912,11 +931,6 @@ TA1 Burning=TA1 Brennen TA1 Melting=TA1 Schmelzen TA1 Melting Pot=TA1 Schmelztiegel -### meltingpot.lua ### -### repairkit.lua ### - -Time=Zeit - ### meridium.lua ### Meridium Axe=Meridium Axt @@ -1173,17 +1187,6 @@ Red Stone=Rotstein Red Stone Block=Rotsteinblock Red Stone Brick=Rotsteinziegel -### repairkit.lua ### - -Biome=Biom -Node owner=Blockbesitzer -Position=Position -Position temperature=Positionstemperatur -Pump connected to no/empty tank(s).=Pumpe an keine/leere Tank(s) angeschlossen. -Pump connected to tank(s) with: @1=Pumpe an Tank(s) angeschlossen mit: @1 -TechAge Info Tool (use @= read status info)=TechAge Info Werkzeug -TechAge Repair Kit=TechAge Reparaturset - ### repeater.lua ### TA3 Repeater=TA3 Wiederholer @@ -1572,25 +1575,3 @@ Remove detector=Entferne Detektor TA4 Collider Detector Worker=TA4 Collider Detektor Worker [TA4] Detector is being built!=[TA4] Detektor wird gebaut! [TA4] Detector is being removed!=[TA4] Detektor wird entfernt! - - -##### not used anymore ##### - -No plan available=Kein Plan verfügar -Plan=Plan -Sectional view=Schnittbild -Side view=Seitenansicht -Top view=Draufsicht -Blocks are back=Blöcke sind wieder da -Blocks are disappeared=Blöcke sind verschwunden -Remove=Entfernen -Set=Setzen -Commands@nhelp . . . print this text@ncls . . . . . clear screen@ngen . . . . print all generators@nsto . . . . . print all storage systems@ncon . . . . . print main consumers@n=Kommandos@nhelp . . . diesen Text ausgeben@ncls . . . . . Bildschirm löschen@ngen . . . . Alle Generatoren ausgeben@nsto . . . . . Alle Speichersysteme ausgeben@ncon . . . . . Hauptverbraucher ausgeben@n -Handover to A=Übergabe an A -Handover to B=Übergabe an B -Number of the next movecontroller=Nummer des nächsten Move Controllers -Number of the previous movecontroller=Nummer des vorhergehenden Move Controllers -TechAge Signal Lamp=TechAge Signallampe -TechAge Signal Lamp 2 =TechAge Signallampe 2 -TA4 Collider Terminal=TA4 Collider Terminal -Error: Max. length of the flight route exceeded !!=Fehler: Max. Flugstreckenlänge überschritten !! diff --git a/locale/template.txt b/locale/template.txt index 0ad7e28..466b0d7 100644 --- a/locale/template.txt +++ b/locale/template.txt @@ -21,6 +21,10 @@ Red Mud Canister= [TA] Area is protected!= [TA] Not enough space!= +### assembly_tool.lua ### + +TechAge Assembly Tool= + ### autocrafter.lua ### Autocrafter= @@ -482,6 +486,21 @@ TA2 Ele Fab= TA3 Ele Fab= TA4 Ele Fab= +### end_wrench.lua ### + +Biome= +Node owner= +Position= +Position temperature= +Pump connected to no/empty tank(s).= +Pump connected to tank(s) with: @1= +TechAge Info Tool (use @= read status info)= + +### end_wrench.lua ### +### meltingpot.lua ### + +Time= + ### epoxy.lua ### Epoxide Resin= @@ -912,11 +931,6 @@ TA1 Burning= TA1 Melting= TA1 Melting Pot= -### meltingpot.lua ### -### repairkit.lua ### - -Time= - ### meridium.lua ### Meridium Axe= @@ -1173,17 +1187,6 @@ Red Stone= Red Stone Block= Red Stone Brick= -### repairkit.lua ### - -Biome= -Node owner= -Position= -Position temperature= -Pump connected to no/empty tank(s).= -Pump connected to tank(s) with: @1= -TechAge Info Tool (use @= read status info)= -TechAge Repair Kit= - ### repeater.lua ### TA3 Repeater= diff --git a/manuals/manual_ta3_DE.md b/manuals/manual_ta3_DE.md index fb7fafd..add85b4 100644 --- a/manuals/manual_ta3_DE.md +++ b/manuals/manual_ta3_DE.md @@ -886,7 +886,7 @@ Mit diesem Werkzeug lassen sich die Bohrgestängezange Blöcke wieder entfernen, [ta3_drill_pipe_wrench|image] -### Techage Schraubendreher +### Techage Schraubendreher / Screwdriver Der Techage Schraubendreher dient als Ersatz für den normalen Schraubendreher. Es besitzt folgende Funktionen: @@ -896,3 +896,14 @@ Der Techage Schraubendreher dient als Ersatz für den normalen Schraubendreher. - Shift+Rechtsklick: Die gespeicherte Ausrichtung auf den angeklickten Block anwenden [ta3_screwdriver|image] + +### TechAge Montagewerkzeug / Assembly Tool + +Das TechAge Montagewerkzeug dient zum Entfernen und wieder Setzen von Techage Blöcken, ohne dass diese Blöcke ihre Blocknummer verlieren, bzw. beim Setzen eine neue Nummer zugeteilt bekommen. Dies ist bspw. bei Steinbrechern hilfreich, da diese oft umgesetzt werden müssen. + +- Linke Taste: Entfernen eines Blocks +- Rechte Taste: Setzen eines Blocks + +Der Block, der zuvor mit dem Montagewerkzeug entfernt wurde und wieder gesetzt werden soll, muss sich im Spieler-Inventar ganz links befinden. + +[techage:assembly_tool|image] \ No newline at end of file diff --git a/manuals/manual_ta3_EN.md b/manuals/manual_ta3_EN.md index 82b5fcd..631083c 100644 --- a/manuals/manual_ta3_EN.md +++ b/manuals/manual_ta3_EN.md @@ -887,3 +887,15 @@ The Techage Screwdriver serves as a replacement for the normal screwdriver. It h - Shift + right click: apply the saved alignment to the clicked block [ta3_screwdriver|image] + +### TechAge Assembly Tool + +The TechAge Assembly Tool is used to remove and reposition Techage blocks without these blocks losing their block number or being assigned a new number when setting. This is helpful, for example, for quarries, as they often have to be moved. + +- Left button: Remove a block +- Right button: Set a block + +The block that was previously removed with the assembly tool and is to be placed again must be on the far left of the player inventory. + +[techage:assembly_tool|image] + diff --git a/power/powerswitch.lua b/power/powerswitch.lua index 95378ab..9881524 100644 --- a/power/powerswitch.lua +++ b/power/powerswitch.lua @@ -275,7 +275,7 @@ techage.register_node({"techage:powerswitch", "techage:powerswitch_on", end, on_beduino_request_data = function(pos, src, topic, payload) local node = techage.get_node_lvm(pos) - if topic == 142 then + if topic == 131 or topic == 142 then if node.name == "techage:powerswitch_on" or node.name == "techage:powerswitchsmall_on" then return 0, {1} diff --git a/sounds/techage_tool1.ogg b/sounds/techage_tool1.ogg new file mode 100644 index 0000000..705c42d Binary files /dev/null and b/sounds/techage_tool1.ogg differ diff --git a/sounds/techage_tool2.ogg b/sounds/techage_tool2.ogg new file mode 100644 index 0000000..8b4dc5d Binary files /dev/null and b/sounds/techage_tool2.ogg differ diff --git a/tools/assembly_tool.lua b/tools/assembly_tool.lua new file mode 100644 index 0000000..1612324 --- /dev/null +++ b/tools/assembly_tool.lua @@ -0,0 +1,161 @@ +--[[ + + TechAge + ======= + + Copyright (C) 2017-2023 Joachim Stolberg + + AGPL v3 + See LICENSE.txt for more information + +]]-- + +-- for lazy programmers +local M = minetest.get_meta +local S = techage.S +local P2S = function(pos) if pos then return minetest.pos_to_string(pos) end end + +local function base_checks(user, pointed_thing, place) + if pointed_thing.type ~= "node" then + return false + end + + if not user then + return false + end + + local pos = place and pointed_thing.above or pointed_thing.under + local player_name = user:get_player_name() + + if minetest.is_protected(pos, player_name) then + return false + end + + return true, pos, player_name +end + +---------------------------------------------------------------------------- +local function add_to_inventory(pos, item, user) + local inv = user:get_inventory() + if inv and item and inv:room_for_item("main", item) then + inv:add_item("main", item) + else + minetest.item_drop(item, user, pos) + end +end + +local function take_from_inventory(user) + local inv = user:get_inventory() + local stack = inv:get_stack("main", 1) + local taken = stack:take_item(1) + + if taken:get_count() == 1 then + local imeta = taken:get_meta() + if imeta:get_string("node_number") ~= "" then + inv:set_stack("main", 1, stack) + return taken + end + end +end + +----------------------------------------------------------------------------- +local function remove_node(pos, digger) + local node = minetest.get_node(pos) + local number = M(pos):get_string("node_number") + local item = ItemStack(node.name) + local imeta = item:get_meta() + local ndef = minetest.registered_nodes[node.name] + local oldmetadata = minetest.get_meta(pos):to_table() + + if number ~= "" and ndef and ndef.after_dig_node then + minetest.remove_node(pos) + ndef.after_dig_node(pos, node, oldmetadata, digger) + techage.post_remove_node(pos) + imeta:set_string("node_number", number) + imeta:set_string("description", ndef.description .. " : " .. number) + return item + end +end + +local function place_node(pos, item, placer, pointed_thing) + local imeta = item:get_meta() + local number = imeta:get_string("node_number") + local name = item:get_name() + local param2 = minetest.dir_to_facedir(placer:get_look_dir()) + local ndef = minetest.registered_nodes[name] + + if number ~= "" and ndef and ndef.after_place_node then + techage.pre_add_node(pos, number) + minetest.add_node(pos, {name = name, param2 = param2}) + ndef.after_place_node(pos, placer, item, pointed_thing) + return true + end +end + +---------------------------------------------------------------------------- +local function on_place_node(itemstack, pos, user, player_name, pointed_thing) + local item = take_from_inventory(user) + if item then + if place_node(pos, item, user, pointed_thing) then + itemstack:add_wear(65636/200) + minetest.sound_play("techage_tool2", { + pos = pos, + gain = 1, + max_hear_distance = 10}) + return itemstack + else + add_to_inventory(pos, item, user) + end + end +end + +local function on_remove_node(itemstack, pos, user, player_name) + local item = remove_node(pos, user) + if item then + add_to_inventory(pos, item, user) + itemstack:add_wear(65636/200) + minetest.sound_play("techage_tool1", { + pos = pos, + gain = 1, + max_hear_distance = 10}) + end + return itemstack +end + +---------------------------------------------------------------------------- +local function on_place(itemstack, user, pointed_thing) + local res, pos, player_name = base_checks(user, pointed_thing, true) + if res then + return on_place_node(itemstack, pos, user, player_name, pointed_thing) + end +end + +local function on_use(itemstack, user, pointed_thing) + local res, pos, player_name = base_checks(user, pointed_thing, false) + if res then + return on_remove_node(itemstack, pos, user, player_name) + end +end + +---------------------------------------------------------------------------- +minetest.register_tool("techage:assembly_tool", { + description = S("TechAge Assembly Tool"), + inventory_image = "techage_repairkit.png", + wield_image = "techage_repairkit.png^[transformR270", + groups = {cracky=1, book=1}, + on_use = on_use, + on_place = on_place, + node_placement_prediction = "", + stack_max = 1, +}) + +minetest.register_craft({ + output = "techage:assembly_tool", + recipe = { + {"", "techage:screwdriver", ""}, + {"basic_materials:plastic_sheet", "basic_materials:plastic_strip", "basic_materials:plastic_sheet"}, + {"", "techage:end_wrench", ""}, + }, +}) + +minetest.register_alias("techage:repairkit", "techage:assembly_tool") \ No newline at end of file diff --git a/tools/repairkit.lua b/tools/end_wrench.lua similarity index 89% rename from tools/repairkit.lua rename to tools/end_wrench.lua index 1ef971e..cd5c6de 100644 --- a/tools/repairkit.lua +++ b/tools/end_wrench.lua @@ -3,7 +3,7 @@ TechAge ======= - Copyright (C) 2017-2021 Joachim Stolberg + Copyright (C) 2017-2023 Joachim Stolberg AGPL v3 See LICENSE.txt for more information @@ -222,34 +222,6 @@ local function on_place(itemstack, placer, pointed_thing) end end -local function repair(itemstack, placer, pointed_thing) - if pointed_thing.type == "node" then - local pos = pointed_thing.under - if not placer or minetest.is_protected(pos, placer:get_player_name()) then - return - end - local number = techage.get_node_number(pos) - if number and not techage.get_node_info(number) then - techage.repair_number(pos) - minetest.chat_send_player(placer:get_player_name(), "Node repaired!") - itemstack:add_wear(65636/200) - return itemstack - end - end -end - -minetest.register_tool("techage:repairkit", { - description = S("TechAge Repair Kit"), - inventory_image = "techage_repairkit.png", - wield_image = "techage_repairkit.png^[transformR270", - groups = {cracky=1, book=1}, - on_use = repair, - on_place = repair, - node_placement_prediction = "", - stack_max = 1, -}) - - minetest.register_tool("techage:end_wrench", { description = S("TechAge Info Tool (use = read status info)"), inventory_image = "techage_end_wrench.png", @@ -270,12 +242,3 @@ minetest.register_craft({ {"default:steel_ingot", "", ""}, }, }) - ---minetest.register_craft({ --- output = "techage:repairkit", --- recipe = { --- {"", "", ""}, --- {"", "techage:end_wrench", ""}, --- {"", "", ""}, --- }, ---})