diff --git a/README.md b/README.md index db87c55..554e2aa 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,9 @@ Copyright (C) 2019-2021 Joachim Stolberg Code: Licensed under the GNU AGPL version 3 or later. See LICENSE.txt Textures: CC BY-SA 3.0 +The TA1 mill sound is from https://freesound.org/people/JustinBW/sounds/70200/ +The TA1 watermill sound is from https://freesound.org/people/bmoreno/sounds/164182/ + Many thanks to Thomas-S and others for their contributions diff --git a/basic_machines/gravelrinser.lua b/basic_machines/gravelrinser.lua index a680fb0..1d91dd9 100644 --- a/basic_machines/gravelrinser.lua +++ b/basic_machines/gravelrinser.lua @@ -150,21 +150,22 @@ local function washing(pos, crd, nvm, inv) local src = ItemStack("techage:sieved_gravel") local dst = ItemStack("default:sand") if inv:contains_item("src", src) then + if not inv:room_for_item("dst", dst) then + crd.State:blocked(pos, nvm) + return + end local ore = get_random_gravel_ore() if ore then add_object({x=pos.x, y=pos.y+1, z=pos.z}, ore) end + inv:add_item("dst", dst) + inv:remove_item("src", src) + crd.State:keep_running(pos, nvm, COUNTDOWN_TICKS) + return else crd.State:idle(pos, nvm) return end - if not inv:room_for_item("dst", dst) then - crd.State:idle(pos, nvm) - return - end - inv:add_item("dst", dst) - inv:remove_item("src", src) - crd.State:keep_running(pos, nvm, COUNTDOWN_TICKS) end local function keep_running(pos, elapsed) diff --git a/basic_machines/grinder.lua b/basic_machines/grinder.lua index 1f38f50..9cf8dcd 100644 --- a/basic_machines/grinder.lua +++ b/basic_machines/grinder.lua @@ -23,8 +23,9 @@ local STANDBY_TICKS = 3 local COUNTDOWN_TICKS = 4 local CYCLE_TIME = 4 - --- Grinder recipes +-- Grinder recipes TA1 +local RecipesTa1 = {} +-- Grinder recipes TA2 - TA4 local Recipes = {} local function formspec(self, pos, nvm) @@ -250,6 +251,79 @@ local node_name_ta2, node_name_ta3, node_name_ta4 = tube_sides = {L=1, R=1, U=1}, }) +------------------------------------------------------------------------------- +-- TA1 Mill (watermill) +------------------------------------------------------------------------------- +local formspecStr = "size[8,8]".. + default.gui_bg.. + default.gui_bg_img.. + default.gui_slots.. + "list[context;src;1,1;1,1;]".. + "item_image[1,1;1,1;farming:wheat]".. + "image[1,1;1,1;techage_form_mask.png]".. + "image[3.5,1;1,1;techage_form_arrow.png]".. + "list[context;dst;6,1;1,1;]".. + "item_image[6,1;1,1;farming:flour]".. + "image[6,1;1,1;techage_form_mask.png]".. + "list[current_player;main;0,4;8,4;]".. + "listring[context;dst]".. + "listring[current_player;main]".. + "listring[context;src]".. + "listring[current_player;main]".. + default.get_hotbar_bg(0, 4) + +local function node_timer(pos, elapsed) + if techage.ta1_mill_has_power(pos, 2) then + local inv = M(pos):get_inventory() + local stack = inv:get_stack("src", 1) + if not stack:is_empty() then + local name = stack:get_name() + if RecipesTa1[name] then + local recipe = RecipesTa1[name] + src_to_dst(stack, 1, name, 1, recipe.inp_num, inv, recipe.output) + end + end + end + return true +end + +minetest.register_node("techage:ta1_mill_base", { + description = S("TA1 Mill Base"), + tiles = { + "techage_mill_base.png", + "default_stone_brick.png", + }, + after_place_node = function(pos, placer) + M(pos):set_string("formspec", formspecStr) + local inv = M(pos):get_inventory() + inv:set_size('src', 1) + inv:set_size('dst', 1) + minetest.get_node_timer(pos):start(4) + end, + can_dig = can_dig, + on_timer = node_timer, + allow_metadata_inventory_put = allow_metadata_inventory_take, + allow_metadata_inventory_move = allow_metadata_inventory_move, + allow_metadata_inventory_take = allow_metadata_inventory_take, + is_ground_content = false, + groups = {cracky = 2, crumbly = 2, choppy = 2}, +}) + +techage.register_node({"techage:ta1_mill_base"}, { + on_node_load = function(pos, node) + minetest.get_node_timer(pos):start(4) + end, +}) + +minetest.register_craft({ + output = "techage:ta1_mill_base", + recipe = { + {"default:stonebrick", "", "default:stonebrick"}, + {"", "techage:iron_ingot", ""}, + {"default:stonebrick", "", "default:stonebrick"}, + }, +}) + minetest.register_craft({ output = node_name_ta2, recipe = { @@ -284,16 +358,34 @@ if minetest.global_exists("unified_inventory") then width = 2, height = 2, }) + unified_inventory.register_craft_type("milling", { + description = S("Milling"), + icon = 'techage_mill_inv.png', + width = 2, + height = 2, + }) end -function techage.add_grinder_recipe(recipe) +function techage.add_grinder_recipe(recipe, ta1_permitted) local name, num = unpack(string.split(recipe.input, " ", false, 1)) - Recipes[name] = {input = name,inp_num = tonumber(num) or 1, output = recipe.output} - - if minetest.global_exists("unified_inventory") then - recipe.items = {recipe.input} - recipe.type = "grinding" - unified_inventory.register_craft(recipe) + if minetest.registered_items[name] then + if ta1_permitted then + RecipesTa1[name] = {input = name,inp_num = tonumber(num) or 1, output = recipe.output} + + if minetest.global_exists("unified_inventory") then + recipe.items = {recipe.input} + recipe.type = "milling" + unified_inventory.register_craft(table.copy(recipe)) + end + end + + Recipes[name] = {input = name,inp_num = tonumber(num) or 1, output = recipe.output} + + if minetest.global_exists("unified_inventory") then + recipe.items = {recipe.input} + recipe.type = "grinding" + unified_inventory.register_craft(recipe) + end end end @@ -326,14 +418,14 @@ techage.add_grinder_recipe({input="default:acacia_tree", output="default:acacia_ techage.add_grinder_recipe({input="default:aspen_tree", output="default:aspen_leaves 8"}) if minetest.global_exists("farming") then - techage.add_grinder_recipe({input="farming:wheat 3", output="farming:flour"}) - techage.add_grinder_recipe({input="farming:seed_wheat 6", output="farming:flour"}) - techage.add_grinder_recipe({input="farming:barley 3", output="farming:flour"}) - techage.add_grinder_recipe({input="farming:seed_barley 6", output="farming:flour"}) - techage.add_grinder_recipe({input="farming:rye 3", output="farming:flour"}) - techage.add_grinder_recipe({input="farming:seed_rye 6", output="farming:flour"}) - techage.add_grinder_recipe({input="farming:rice 3", output="farming:rice_flour"}) - techage.add_grinder_recipe({input="farming:seed_rice 6", output="farming:rice_flour"}) - techage.add_grinder_recipe({input="farming:oat 3", output="farming:flour"}) - techage.add_grinder_recipe({input="farming:seed_oat 6", output="farming:flour"}) + techage.add_grinder_recipe({input="farming:wheat 3", output="farming:flour"}, true) + techage.add_grinder_recipe({input="farming:seed_wheat 6", output="farming:flour"}, true) + techage.add_grinder_recipe({input="farming:barley 3", output="farming:flour"}, true) + techage.add_grinder_recipe({input="farming:seed_barley 6", output="farming:flour"}, true) + techage.add_grinder_recipe({input="farming:rye 3", output="farming:flour"}, true) + techage.add_grinder_recipe({input="farming:seed_rye 6", output="farming:flour"}, true) + techage.add_grinder_recipe({input="farming:rice 3", output="farming:rice_flour"}, true) + techage.add_grinder_recipe({input="farming:seed_rice 6", output="farming:rice_flour"}, true) + techage.add_grinder_recipe({input="farming:oat 3", output="farming:flour"}, true) + techage.add_grinder_recipe({input="farming:seed_oat 6", output="farming:flour"}, true) end diff --git a/doc/manual_DE.lua b/doc/manual_DE.lua index f3dc08a..6262bd7 100644 --- a/doc/manual_DE.lua +++ b/doc/manual_DE.lua @@ -15,6 +15,8 @@ techage.manual_DE.aTitel = { "1,TA1: Eisenzeitalter", "2,Köhler / Coal Pile", "2,Kohlebrenner / Coal Burner", + "2,Wassermühle", + "3,TA1 Mühle", "2,Erze und Werkzeuge", "3,Hammer", "3,Kiessieb / Gravel Sieve", @@ -339,6 +341,18 @@ techage.manual_DE.aText = { "\n".. "\n".. "\n", + "Mit der Wassermühle können Weizen und andere Getreide zu Mehl gemahlen und dann im Ofen zu Brot gebacken werden. Die Mühle wird mit\n".. + "Wasserkraft angetrieben. Dazu muss der Mühlbach über ein Kanal zum Wasserrad geführt werden. Für den Mühlbach muss oberhalb des Mühlerades\n".. + "ein Teich angelegt werden. Die Abbilding rechts (auf \"Plan\" klicken) zeigt den Aufbau.\n".. + "\n".. + "\n".. + "\n", + "Mit der Wassermühle können Weizen und andere Getreide zu Mehl gemahlen und dann im Ofen zu Brot gebacken werden. Die Mühle wird mit\n".. + "Wasserkraft angetrieben. Dazu muss der Mühlbach über ein Kanal zum Wasserrad geführt werden. Für den Mühlbach muss oberhalb des Mühlerades\n".. + "ein Teich angelegt werden. Die Abbilding rechts (auf \"Plan\" klicken) zeigt den Aufbau.\n".. + "\n".. + "\n".. + "\n", "TA1 hat seine eigenen Werkzeuge wie Hammer und Kiessieb\\, aber auch der Minecart Hopper kann genutzt werden.\n".. "\n".. "\n".. @@ -1723,6 +1737,8 @@ techage.manual_DE.aItemName = { "techage_ta1", "", "", + "", + "", "ta1_gravelsieve", "hammer", "ta1_gravelsieve", @@ -1930,6 +1946,8 @@ techage.manual_DE.aPlanTable = { "", "coalpile", "coalburner", + "watermill1", + "watermill2", "", "", "", diff --git a/doc/plans.lua b/doc/plans.lua index 05e2043..da6bdbc 100644 --- a/doc/plans.lua +++ b/doc/plans.lua @@ -81,6 +81,64 @@ techage.ConstructionPlans["hoppersieve"] = { {false, false, HOPPR, CHEST, false}, } +-- +-- TA1: Watermill +-- +local WATR1 = {"default_water.png" , "techage:water_flowing"} +local WATR3 = {"techage_water_flowing.png" , "techage:water_flowing"} +local WMILL = {"default_wood.png" , "techage:ta1_board1_apple"} +local SLUC1 = {"techage_sluice2_inv.png" , "techage:ta1_sluice_closed"} +local SLUC2 = {"techage_sluice1_inv.png" , "techage:ta1_sluice_handle_closed"} +local MIL11 = {"techage_watermill1_inv.png" , "techage:ta1_watermill"} +local MIL12 = {"techage_watermill1_inv.png^[transformR90" , "techage:ta1_watermill"} +local MIL13 = {"techage_watermill1_inv.png^[transformR180" , "techage:ta1_watermill"} +local MIL14 = {"techage_watermill1_inv.png^[transformR270" , "techage:ta1_watermill"} +local MIL21 = {"techage_watermill2_inv.png" , "techage:ta1_watermill"} +local MIL22 = {"techage_watermill2_inv.png^[transformR90" , "techage:ta1_watermill"} +local MIL23 = {"techage_watermill2_inv.png^[transformR180" , "techage:ta1_watermill"} +local MIL24 = {"techage_watermill2_inv.png^[transformR270" , "techage:ta1_watermill"} +local MIL31 = {"techage_watermill3_inv.png" , "techage:ta1_watermill"} +local MIL32 = {"techage_watermill3_inv.png^[transformR90" , "techage:ta1_watermill"} +local MIL33 = {"techage_watermill3_inv.png^[transformR180" , "techage:ta1_watermill"} +local MIL34 = {"techage_watermill3_inv.png^[transformR270" , "techage:ta1_watermill"} +local MIL40 = {"techage_watermill4_inv.png" , "techage:ta1_watermill"} +local BEARG = {"default_stone_brick.png^techage_axle_bearing_front.png", "techage:ta1_axle_bearing2"} +local BRICK = {"default_stone_brick.png", "default:stonebrick"} + + +techage.ConstructionPlans["watermill1"] = { + {false, false, false, false, false, false, false, false, false, false, false}, + {false, SLUC2, false, false, false, false, false, false, false, false, false}, + {WATR1, SLUC1, WMILL, WMILL, WMILL, WMILL, WMILL, WATR3, false, false, false}, + {WATR1, DDIRT, false, false, MIL31, MIL21, MIL11, MIL21, MIL34, false, false}, + {WATR1, DDIRT, false, false, MIL22, MIL40, MIL40, MIL40, MIL24, false, false}, + {DDIRT, DDIRT, DDIRT, false, MIL12, MIL40, BEARG, MIL40, MIL14, false, false}, + {DDIRT, DDIRT, DDIRT, false, MIL22, MIL40, BRICK, MIL40, MIL24, false, false}, + {DDIRT, DDIRT, DDIRT, DDIRT, MIL32, MIL23, BRICK, MIL23, MIL33, false, false}, + {DDIRT, DDIRT, DDIRT, DDIRT, DDIRT, DDIRT, DDIRT, WATR1, WATR1, WATR1, WATR1}, +} + + +local MILLF = {"default_wood.png" , "techage:ta1_watermill"} +local AXLE1 = {"techage_axle_bearing.png", "techage:ta1_axle"} +local MILLG = {"techage_wood50.png^techage_axle_bearing.png", "techage:ta1_mill_gear"} +local MILL_ = {"techage_mill_side.png", "techage:ta1_mill"} +local MILLB = {"default_stone_brick.png", "techage:ta1_mill_base"} +local FURNE = {"default_furnace_front.png", "default:furnace"} +local HOPER = {"techage_hopper.png", "minecart:hopper"} + +techage.ConstructionPlans["watermill2"] = { + {false, false, false, false, false, false, false, false, false, false, false, false}, + {false, false, false, false, false, false, false, false, false, false, false, false}, + {false, false, false, false, false, false, false, false, false, false, false, false}, + {false, false, false, false, false, false, false, false, MILLF, false, false, false}, + {false, false, false, false, false, false, false, false, MILLF, false, false, false}, + {false, false, false, false, false, MILLG, AXLE1, BEARG, MILLF, BEARG, false, false}, + {false, false, false, false, false, MILL_, false, BRICK, MILLF, BRICK, false, false}, + {false, CHEST, HOPER, FURNE, HOPER, MILLB, false, BRICK, MILLF, BRICK, false, false}, + {DDIRT, DDIRT, DDIRT, DDIRT, DDIRT, DDIRT, DDIRT, DDIRT, WATR1, DDIRT, DDIRT, DDIRT}, +} + -- -- Steam Engine -- diff --git a/init.lua b/init.lua index f8a7b60..363b9f0 100644 --- a/init.lua +++ b/init.lua @@ -133,8 +133,17 @@ dofile(MP.."/iron_age/meltingpot.lua") if techage.modified_recipes_enabled then dofile(MP.."/iron_age/tools.lua") end + +-- TA1 Watermill +dofile(MP.."/ta1_watermill/ta1_axle.lua") +dofile(MP.."/ta1_watermill/watermill.lua") +dofile(MP.."/ta1_watermill/water.lua") +dofile(MP.."/ta1_watermill/sluice.lua") +dofile(MP.."/ta1_watermill/millboard.lua") +dofile(MP.."/ta1_watermill/mill.lua") + dofile(MP.."/iron_age/recipes.lua") -if minetest.global_exists("wielded_light") then +if minetest.global_exists("wielded_light") or minetest.global_exists("illumination") then dofile(MP.."/iron_age/meridium.lua") end diff --git a/iron_age/hopper.lua b/iron_age/hopper.lua index 188ea80..374eb0f 100644 --- a/iron_age/hopper.lua +++ b/iron_age/hopper.lua @@ -76,3 +76,17 @@ minecart.register_inventory( }, } ) + +minecart.register_inventory( + { + "techage:ta1_mill_base", + }, + { + put = { + listname = "src", + }, + take = { + listname = "dst", + }, + } +) diff --git a/lamps/growlight.lua b/lamps/growlight.lua index 20dc22c..9165875 100644 --- a/lamps/growlight.lua +++ b/lamps/growlight.lua @@ -135,6 +135,8 @@ techage.register_lamp("techage:growlight", { {-8/16, -8/16, -8/16, 8/16, -13/32, 8/16}, }, }, + on_timer = node_timer_off, + on_switch_lamp = on_switch_lamp, high_power = true, },{ description = S("TA4 LED Grow Light"), @@ -156,6 +158,7 @@ techage.register_lamp("techage:growlight", { }, }, on_timer = node_timer_on, + on_switch_lamp = on_switch_lamp, high_power = true, }) diff --git a/locale/techage.de.tr b/locale/techage.de.tr index 16a92b5..fb785f5 100644 --- a/locale/techage.de.tr +++ b/locale/techage.de.tr @@ -446,6 +446,8 @@ TA4 Gravel Sieve=TA4 Kiessieb Grinder=Mühle Grinding=Mahlen +Milling=Mahlen +TA1 Mill Base=Mühlenunterteil ### growlight.lua ### @@ -642,6 +644,24 @@ Meridium Sword=Meridium Schwert TA3 Mesecons Converter=TA3 Mesecons Konverter +### mill.lua ### + +TA1 Mill=TA1 Mühle +TA1 Mill Gear=TA1 Mühlengetriebe + +### millboard.lua ### + +TA1 Acacia Millrace Board=TA1 Akazie Mühlbachbrett +TA1 Acacia Wood Board=TA1 Akazienholzbrett +TA1 Apple Millrace Board=TA1 Apfel Mühlbachbrett +TA1 Apple Wood Board=TA1 Apfelholzbrett +TA1 Aspen Millrace Board=TA1 Espe Mühlbachbrett +TA1 Aspen Wood Board=TA1 Espenholzbrett +TA1 Jungle Millrace Board=TA1 Dschungel Mühlbachbrett +TA1 Jungle Wood Board=TA1 Dschungelholzbrett +TA1 Pine Millrace Board=TA1 Kiefer Mühlbachbrett +TA1 Pine Wood Board=TA1 Kiefernholzbrett + ### minicell.lua ### TA4 Streetlamp Solar Cell=TA4 Straßenlampen-Solarzelle @@ -877,6 +897,12 @@ TA4 Silo=Silo TA Lamp=TA Lampe +### sluice.lua ### + +TA1 Sluice Gate=TA1 Schleusenschieber +TA1 Sluice Handle=TA1 Schleusengriff +Your pond is too small!=ein Teich ist zu klein! + ### solarcell.lua ### TA4 Solar Carrier Module=TA4 Solar Trägermodul @@ -925,6 +951,11 @@ Cancel=Abbruch Note: You can't change any values while the block is running!=Hinweis: Während der Block läuft, kann kein Wert geändert werden! Refresh=Aktualisieren +### ta1_axle.lua ### + +TA1 Axle=TA1 Achse +TA1 Axle Bearing=TA1 Achsenlager + ### ta2_weight_chest.lua ### TA2 Weight Chest=TA2 Gewichtekiste @@ -1067,13 +1098,23 @@ Usmium Powder=Usmium Pulver TA Valve=TA Ventil TA3 Valve=TA3 Ventil +### water.lua ### + +Flowing Water=Fließendes Wasser +Water Source=Wasserquelle + ### waterinlet.lua ### Error: No natural water!=Fehler: Kein natürliches Wasser! Error: No water available!=Fehler: Kein Wasser verfügbar! Error: Not on sea level!=Fehler: Nicht auf Meereshöhe! +Operational=Betriebsbereit TA4 Water Inlet=TA4 Wasssereinlass +### watermill.lua ### + +TA1 Watermill=TA1 Wasssermühle + ### waterpump.lua ### TA4 Water Pump=Wasserpumpe @@ -1090,4 +1131,3 @@ This is not the surface of the ocean!=Das ist nicht die Meeresoberfläche! [TA4 Wind Turbine]=[TA4 Windkraftanlage] biome and no ocean!=Biom und keine Meer (ocean)! is a suitable place for a wind turbine!=ist ein geeigneter Ort für eine Windkraftanlage! - diff --git a/locale/template.txt b/locale/template.txt index ac33dce..8fff581 100644 --- a/locale/template.txt +++ b/locale/template.txt @@ -446,6 +446,8 @@ TA4 Gravel Sieve= Grinder= Grinding= +Milling= +TA1 Mill Base= ### growlight.lua ### @@ -642,6 +644,24 @@ Meridium Sword= TA3 Mesecons Converter= +### mill.lua ### + +TA1 Mill= +TA1 Mill Gear= + +### millboard.lua ### + +TA1 Acacia Millrace Board= +TA1 Acacia Wood Board= +TA1 Apple Millrace Board= +TA1 Apple Wood Board= +TA1 Aspen Millrace Board= +TA1 Aspen Wood Board= +TA1 Jungle Millrace Board= +TA1 Jungle Wood Board= +TA1 Pine Millrace Board= +TA1 Pine Wood Board= + ### minicell.lua ### TA4 Streetlamp Solar Cell= @@ -877,6 +897,12 @@ TA4 Silo= TA Lamp= +### sluice.lua ### + +TA1 Sluice Gate= +TA1 Sluice Handle= +Your pond is too small!= + ### solarcell.lua ### TA4 Solar Carrier Module= @@ -925,6 +951,11 @@ Cancel= Note: You can't change any values while the block is running!= Refresh= +### ta1_axle.lua ### + +TA1 Axle= +TA1 Axle Bearing= + ### ta2_weight_chest.lua ### TA2 Weight Chest= @@ -1067,13 +1098,23 @@ Usmium Powder= TA Valve= TA3 Valve= +### water.lua ### + +Flowing Water= +Water Source= + ### waterinlet.lua ### Error: No natural water!= Error: No water available!= Error: Not on sea level!= +Operational= TA4 Water Inlet= +### watermill.lua ### + +TA1 Watermill= + ### waterpump.lua ### TA4 Water Pump= diff --git a/logic/terminal.lua b/logic/terminal.lua index bae261c..212356c 100644 --- a/logic/terminal.lua +++ b/logic/terminal.lua @@ -156,6 +156,23 @@ local function command(pos, command, player) return end + local cmnd, payload = command:match('^axle%s+([%w_]+)%s*(.*)$') + if cmnd then + if not minetest.check_player_privs(player, "server") then + output(pos, "server privs missing") + return + end + local resp = techage.transfer( + pos, + "B", -- outdir + cmnd, -- topic + payload, -- payload + techage.TA1Axle, -- network + nil) -- valid nodes + output(pos, dump(resp)) + return + end + if command ~= "" then output(pos, CMNDS_TA3) end diff --git a/manuals/manual_ta1_DE.md b/manuals/manual_ta1_DE.md index 487dba5..37463d9 100644 --- a/manuals/manual_ta1_DE.md +++ b/manuals/manual_ta1_DE.md @@ -53,6 +53,23 @@ Der Schmelztiegel hat ein eigenes Menü mit Rezepten und ein Inventar, wo du die [coalburner|plan] +## Wassermühle + +Mit der Wassermühle können Weizen und andere Getreide zu Mehl gemahlen und dann im Ofen zu Brot gebacken werden. Die Mühle wird mit +Wasserkraft angetrieben. Dazu muss der Mühlbach über ein Kanal zum Wasserrad geführt werden. Für den Mühlbach muss oberhalb des Mühlerades +ein Teich angelegt werden. Die Abbilding rechts (auf "Plan" klicken) zeigt den Aufbau. + +[watermill1|plan] + +### TA1 Mühle + +Mit der Wassermühle können Weizen und andere Getreide zu Mehl gemahlen und dann im Ofen zu Brot gebacken werden. Die Mühle wird mit +Wasserkraft angetrieben. Dazu muss der Mühlbach über ein Kanal zum Wasserrad geführt werden. Für den Mühlbach muss oberhalb des Mühlerades +ein Teich angelegt werden. Die Abbilding rechts (auf "Plan" klicken) zeigt den Aufbau. + +[watermill2|plan] + + ## Erze und Werkzeuge TA1 hat seine eigenen Werkzeuge wie Hammer und Kiessieb, aber auch der Minecart Hopper kann genutzt werden. diff --git a/manuals/toc_DE.md b/manuals/toc_DE.md index 438c601..16e584a 100644 --- a/manuals/toc_DE.md +++ b/manuals/toc_DE.md @@ -14,6 +14,8 @@ - [TA1: Eisenzeitalter](./manual_ta1_DE.md#ta1:-eisenzeitalter) - [Köhler / Coal Pile](./manual_ta1_DE.md#köhler--coal-pile) - [Kohlebrenner / Coal Burner](./manual_ta1_DE.md#kohlebrenner--coal-burner) + - [Wassermühle](./manual_ta1_DE.md#wassermühle) + - [TA1 Mühle](./manual_ta1_DE.md#ta1-mühle) - [Erze und Werkzeuge](./manual_ta1_DE.md#erze-und-werkzeuge) - [Hammer](./manual_ta1_DE.md#hammer) - [Kiessieb / Gravel Sieve](./manual_ta1_DE.md#kiessieb--gravel-sieve) diff --git a/sounds/techage_mill.ogg b/sounds/techage_mill.ogg new file mode 100644 index 0000000..de0617b Binary files /dev/null and b/sounds/techage_mill.ogg differ diff --git a/sounds/techage_watermill.ogg b/sounds/techage_watermill.ogg new file mode 100644 index 0000000..3e6486a Binary files /dev/null and b/sounds/techage_watermill.ogg differ diff --git a/ta1_watermill/mill.lua b/ta1_watermill/mill.lua new file mode 100644 index 0000000..35e0450 --- /dev/null +++ b/ta1_watermill/mill.lua @@ -0,0 +1,178 @@ +--[[ + + TechAge + ======= + + Copyright (C) 2021 Joachim Stolberg + + AGPL v3 + See LICENSE.txt for more information + + TA1 Mill + +]]-- + +local M = minetest.get_meta +local S = techage.S + +local function start_mill(pos) + local obj = minetest.add_entity(pos, "techage:ta1_mill_entity") + minetest.remove_node(pos) +end + +local function stop_mill(pos, self) + minetest.swap_node(pos, {name = "techage:ta1_mill", param2 = 0}) + minetest.get_node_timer(pos):start(2) + self.object:remove() +end + +local function has_power(pos, y_offs) + local pos1 = {x = pos.x, y = pos.y + y_offs, z = pos.z} + local nvm = techage.get_nvm(pos1) + nvm.watermill_trigger = (nvm.watermill_trigger or 1) - 1 + return nvm.watermill_trigger > 0 +end + +techage.ta1_mill_has_power = has_power + +minetest.register_node("techage:ta1_mill_gear", { + description = S("TA1 Mill Gear"), + tiles = { + "default_wood.png^techage_axle_bearing.png^[transformR90", + "default_wood.png^techage_axle_bearing.png", + }, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + {-1/2, -1/2, -1/2, 1/2, -1/8, 1/2}, + {-1/8, -1/8, -1/2, 1/8, 1/8, 1/2}, + }, + }, + + after_place_node = function(pos, placer) + techage.TA1Axle:after_place_node(pos) + end, + + after_dig_node = function(pos, oldnode, oldmetadata, digger) + techage.TA1Axle:after_dig_node(pos) + end, + + paramtype2 = "facedir", + paramtype = "light", + use_texture_alpha = techage.CLIP, + sunlight_propagates = true, + is_ground_content = false, + groups = {cracky = 2, crumbly = 2, choppy = 2}, +}) + +techage.register_node({"techage:ta1_mill_gear"}, { + on_transfer = function(pos, in_dir, topic, payload) + local nvm = techage.get_nvm(pos) + if topic == "trigger" then + nvm.watermill_trigger = 4 + return true + end + end, +}) + +minetest.register_node("techage:ta1_mill", { + description = S("TA1 Mill"), + tiles = { + -- up, down, right, left, back, front + "techage_mill_side.png", + "techage_mill_side.png", + "techage_mill_side.png", + "techage_mill_side.png", + "techage_mill_front.png", + "techage_mill_front.png", + }, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + {-1/8, -1/8, -1/8, 1/8, 4/8, 1/8}, + {-3/8, -3/8, -4/8, -1/8, 3/8, 4/8}, + {-3/8, -4/8, -3/8, -1/8, 4/8, 3/8}, + { 1/8, -3/8, -4/8, 3/8, 3/8, 4/8}, + { 1/8, -4/8, -3/8, 3/8, 4/8, 3/8}, + }, + }, + + after_place_node = function(pos, placer) + minetest.get_node_timer(pos):start(2) + end, + + on_rightclick = function(pos, node, clicker) + start_mill(pos) + end, + + on_timer = function(pos, elapsed) + if has_power(pos, 1) then + start_mill(pos) + end + return true + end, + + paramtype2 = "facedir", + paramtype = "light", + use_texture_alpha = techage.CLIP, + sunlight_propagates = true, + is_ground_content = false, + groups = {cracky = 2, crumbly = 2, choppy = 2}, +}) + +minetest.register_entity("techage:ta1_mill_entity", { + initial_properties = { + physical = true, + visual = "wielditem", + wield_item = "techage:ta1_mill", + visual_size = {x=0.67, y=0.67, z=0.67}, + static_save = true, + automatic_rotate = -math.pi * 0.2, + pointable = false, + }, + + on_step = function(self, dtime) + self.dtime = (self.dtime or 0) + dtime + + if self.dtime > 2 then + local pos = vector.round(self.object:get_pos()) + if not has_power(pos, 1) then + stop_mill(pos, self) + end + self.dtime = 0 + minetest.sound_play("techage_mill", {gain = 0.3, pos = pos, + max_hear_distance = 10}, true) + end + end, + + on_rightclick = function(self, clicker) + local pos = vector.round(self.object:get_pos()) + stop_mill(pos, self) + end, +}) + +techage.register_node({"techage:ta1_mill"}, { + on_node_load = function(pos, node) + minetest.get_node_timer(pos):start(2) + end, +}) + +minetest.register_craft({ + output = "techage:ta1_mill_gear", + recipe = { + {"default:wood", "", "default:wood"}, + {"techage:ta1_axle", "default:wood", "techage:ta1_axle"}, + {"default:wood", "techage:ta1_axle", "default:wood"}, + }, +}) + +minetest.register_craft({ + output = "techage:ta1_mill", + recipe = { + {"", "techage:iron_ingot", ""}, + {"stairs:slab_stone", "techage:iron_ingot", "stairs:slab_stone"}, + {"", "", ""}, + }, +}) diff --git a/ta1_watermill/millboard.lua b/ta1_watermill/millboard.lua new file mode 100644 index 0000000..b70c5c1 --- /dev/null +++ b/ta1_watermill/millboard.lua @@ -0,0 +1,91 @@ +--[[ + + TechAge + ======= + + Copyright (C) 2021 Joachim Stolberg + + AGPL v3 + See LICENSE.txt for more information + + TA1 mill boards + +]]-- + +local M = minetest.get_meta +local S = techage.S + +local function register_board1(output, description, tiles, input) + minetest.register_node(output, { + description = description, + tiles = tiles, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + {-1/2, -4/8, -1/2, 1/2, -3/8, 1/2}, + }, + }, + paramtype2 = "wallmounted", + paramtype = "light", + use_texture_alpha = techage.CLIP, + sunlight_propagates = true, + is_ground_content = false, + groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2, wood = 1}, + sounds = default.node_sound_wood_defaults(), + }) + + minetest.register_craft({ + output = output .. " 3", + recipe = { + {"", "", input}, + {"", "", input}, + {"", "", input}, + }, + }) +end + +local function register_board2(output, description, tiles, input1, input2) + minetest.register_node(output, { + description = description, + tiles = tiles, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + {-1/2, 3/8, -1/2, 1/2, 4/8, 1/2}, + {-1/2, 3/16, -2/16, 1/2, 6/16, 2/16}, + {-1/2, -5/16, -1/16, 1/2, -3/16, 1/16}, + }, + }, + + paramtype2 = "facedir", + paramtype = "light", + use_texture_alpha = techage.CLIP, + sunlight_propagates = true, + is_ground_content = false, + groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2, wood = 1}, + sounds = default.node_sound_wood_defaults(), + }) + + minetest.register_craft({ + output = output, + recipe = { + {"", input1, ""}, + {"", input2, ""}, + {"", "", ""}, + }, + }) +end + +register_board1("techage:ta1_board1_apple", S("TA1 Apple Wood Board"), {"default_wood.png"}, "stairs:slab_wood") +register_board1("techage:ta1_board1_jungle", S("TA1 Jungle Wood Board"), {"default_junglewood.png"}, "stairs:slab_junglewood") +register_board1("techage:ta1_board1_pine", S("TA1 Pine Wood Board"), {"default_pine_wood.png"}, "stairs:slab_pine_wood") +register_board1("techage:ta1_board1_acacia", S("TA1 Acacia Wood Board"), {"default_acacia_wood.png"}, "stairs:slab_acacia_wood") +register_board1("techage:ta1_board1_aspen", S("TA1 Aspen Wood Board"), {"default_aspen_wood.png"}, "stairs:slab_aspen_wood") + +register_board2("techage:ta1_board2_apple", S("TA1 Apple Millrace Board"), {"default_wood.png"}, "techage:ta1_board1_apple", "default:fence_rail_wood") +register_board2("techage:ta1_board2_jungle", S("TA1 Jungle Millrace Board"), {"default_junglewood.png"}, "techage:ta1_board1_jungle", "default:fence_rail_junglewood") +register_board2("techage:ta1_board2_pine", S("TA1 Pine Millrace Board"), {"default_pine_wood.png"}, "techage:ta1_board1_pine", "default:fence_rail_pine_wood") +register_board2("techage:ta1_board2_acacia", S("TA1 Acacia Millrace Board"), {"default_acacia_wood.png"}, "techage:ta1_board1_acacia", "default:fence_rail_acacia_wood") +register_board2("techage:ta1_board2_aspen", S("TA1 Aspen Millrace Board"), {"default_aspen_wood.png"}, "techage:ta1_board1_aspen", "default:fence_rail_aspen_wood") diff --git a/ta1_watermill/sluice.lua b/ta1_watermill/sluice.lua new file mode 100644 index 0000000..c4d796f --- /dev/null +++ b/ta1_watermill/sluice.lua @@ -0,0 +1,227 @@ +--[[ + + TechAge + ======= + + Copyright (C) 2021 Joachim Stolberg + + AGPL v3 + See LICENSE.txt for more information + + TA1 Sluice Gate + +]]-- + +local M = minetest.get_meta +local S = techage.S + +local RADIUS = 8 +local DEPTH = 2 +local AMOUNT = RADIUS * RADIUS * 1.5 + +local function check_position(pos, facedir) + local dir = minetest.facedir_to_dir(facedir) + local pos_ = vector.add(pos, dir) + local node = minetest.get_node(pos_) + + if node.name ~= "default:water_source" then + return + end + + dir = vector.multiply(dir, RADIUS) + local center = vector.add(pos, dir) + local pos1 = {x = center.x - RADIUS, y = center.y - DEPTH, z = center.z - RADIUS} + local pos2 = {x = center.x + RADIUS, y = center.y + 0, z = center.z + RADIUS} + local _, nodes = minetest.find_nodes_in_area(pos1, pos2, {"default:water_source"}) + return (nodes["default:water_source"] and nodes["default:water_source"] > AMOUNT) or false +end + +-- Function checks if a millpond is avaliable and +-- returns the pos for the new water block, and the type of block. +local function has_water(pos, facedir, player) + local facedir2, res, dir, pos2 + + -- check left side + facedir2 = (facedir + 3) % 4 + res = check_position(pos, facedir2) + facedir2 = (facedir + 1) % 4 + dir = minetest.facedir_to_dir(facedir2) + pos2 = vector.add(pos, dir) + + if res == nil then + return pos2, "air" + elseif res == true then + return pos2, "water" + else + minetest.chat_send_player(player:get_player_name(), S("Your pond is too small!")) + return pos2, "air" + end + + -- check right side + facedir2 = (facedir + 1) % 4 + res = check_position(pos, facedir2) + facedir2 = (facedir + 3) % 4 + dir = minetest.facedir_to_dir(facedir2) + pos2 = vector.add(pos, dir) + + if res == nil then + return pos2, "air" + elseif res == true then + return pos2, "water" + else + minetest.chat_send_player(player:get_player_name(), S("Your pond is too small!")) + return pos2, "air" + end +end + +local function on_rightclick(pos, node, clicker, itemstack, pointed_thing) + local pos2 = vector.add(pos, {x = 0, y = -1, z = 0}) + local node2 = minetest.get_node(pos2) + local pos3, res = has_water(pos2, node2.param2, clicker) + local node3 = minetest.get_node(pos3) + + if node2.name == "techage:ta1_sluice_closed" then + minetest.swap_node(pos, {name = "techage:ta1_sluice_handle_open", param2 = node.param2}) + minetest.swap_node(pos2, {name = "techage:ta1_sluice_open", param2 = node.param2}) + if res == "water" then + if node3.name == "air" or node3.name == "techage:water_flowing" then + minetest.add_node(pos3, {name = "techage:water_source"}) + minetest.get_node_timer(pos3):start(2) + end + else + minetest.add_node(pos3, {name = "air"}) + end + minetest.sound_play("doors_door_open", {gain = 0.5, pos = pos, + max_hear_distance = 10}, true) + elseif node2.name == "techage:ta1_sluice_open" then + minetest.swap_node(pos, {name = "techage:ta1_sluice_handle_closed", param2 = node.param2}) + minetest.swap_node(pos2, {name = "techage:ta1_sluice_closed", param2 = node.param2}) + if res == "water" then + if node3.name == "techage:water_source" then + minetest.add_node(pos3, {name = "techage:water_flowing"}) + end + else + if node3.name == "techage:water_flowing" then + minetest.add_node(pos3, {name = "air"}) + end + end + minetest.sound_play("doors_door_close", {gain = 0.5, pos = pos, + max_hear_distance = 10}, true) + end +end + +minetest.register_node("techage:ta1_sluice_closed", { + description = S("TA1 Sluice Gate"), + tiles = { + "default_wood.png^techage_junglewood_top.png", + "default_wood.png", + "default_wood.png^techage_junglewood.png", + "default_wood.png^techage_junglewood.png", + "default_wood.png", + "default_wood.png", + }, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + {-8/16, -8/16, 5/16, 8/16, 8/16, 8/16}, + {-8/16, -8/16, -8/16, 8/16, 8/16, -5/16}, + {-8/16, -8/16, -8/16, 8/16, -5/16, 8/16}, + {-1/16, -5/16, -7/16, 1/16, 8/16, 7/16}, + }, + }, + + paramtype2 = "facedir", + paramtype = "light", + use_texture_alpha = techage.CLIP, + sunlight_propagates = true, + is_ground_content = false, + groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2, wood = 1}, + sounds = default.node_sound_wood_defaults(), +}) + +minetest.register_node("techage:ta1_sluice_open", { + description = S("TA1 Sluice Gate"), + tiles = {"default_wood.png"}, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + {-8/16, -8/16, 5/16, 8/16, 8/16, 8/16}, + {-8/16, -8/16, -8/16, 8/16, 8/16, -5/16}, + {-8/16, -8/16, -8/16, 8/16, -5/16, 8/16}, + }, + }, + + paramtype2 = "facedir", + paramtype = "light", + use_texture_alpha = techage.CLIP, + sunlight_propagates = true, + is_ground_content = false, + groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2, wood = 1, not_in_creative_inventory = 1}, + sounds = default.node_sound_wood_defaults(), + drop = "techage:sluice_closed", +}) + +minetest.register_node("techage:ta1_sluice_handle_closed", { + description = S("TA1 Sluice Handle"), + tiles = {"default_wood.png"}, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + {-8/16, -8/16, -8/16, 8/16, 0/16, 8/16}, + {-1/16, 0/16, -1/16, 1/16, 4/16, 1/16}, + {-1/16, 2/16, -4/16, 1/16, 4/16, 4/16}, + }, + }, + on_rightclick = on_rightclick, + paramtype2 = "facedir", + paramtype = "light", + use_texture_alpha = techage.CLIP, + sunlight_propagates = true, + is_ground_content = false, + groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2, wood = 1}, + sounds = default.node_sound_wood_defaults(), +}) + +minetest.register_node("techage:ta1_sluice_handle_open", { + description = S("TA1 Sluice Handle"), + tiles = {"default_wood.png"}, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + {-8/16, -8/16, -8/16, 8/16, 0/16, 8/16}, + {-1/16, 0/16, -1/16, 1/16, 14/16, 1/16}, + {-1/16, 14/16, -4/16, 1/16, 16/16, 4/16}, + }, + }, + on_rightclick = on_rightclick, + paramtype2 = "facedir", + paramtype = "light", + use_texture_alpha = techage.CLIP, + sunlight_propagates = true, + is_ground_content = false, + groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2, wood = 1, not_in_creative_inventory = 1}, + sounds = default.node_sound_wood_defaults(), + drop = "techage:sluice_handle_closed", +}) + +minetest.register_craft({ + output = "techage:ta1_sluice_closed", + recipe = { + {"", "", ""}, + {"techage:ta1_board1_apple", "techage:ta1_board1_jungle", "techage:ta1_board1_apple"}, + {"", "techage:ta1_board1_apple", ""}, + }, +}) + +minetest.register_craft({ + output = "techage:ta1_sluice_handle_closed", + recipe = { + {"default:stick", "default:stick", "default:stick"}, + {"", "default:stick", ""}, + {"", "stairs:slab_wood", ""}, + }, +}) diff --git a/ta1_watermill/ta1_axle.lua b/ta1_watermill/ta1_axle.lua new file mode 100644 index 0000000..bd22a15 --- /dev/null +++ b/ta1_watermill/ta1_axle.lua @@ -0,0 +1,176 @@ +--[[ + + TechAge + ======= + + Copyright (C) 2019-2021 Joachim Stolberg + + AGPL v3 + See LICENSE.txt for more information + + TA1 Axles for the Watermill + +]]-- + +-- for lazy programmers +local P = minetest.string_to_pos +local M = minetest.get_meta +local S = techage.S + +local Axle = tubelib2.Tube:new({ + dirs_to_check = {1,2,3,4,5,6}, + max_tube_length = 5, + show_infotext = false, + tube_type = "axle1", + primary_node_names = {"techage:ta1_axle"}, + secondary_node_names = {"techage:ta1_mill_gear", "techage:ta1_axle_bearing1", "techage:ta1_axle_bearing2"}, + after_place_tube = function(pos, param2, tube_type, num_tubes, state) + minetest.swap_node(pos, {name = "techage:ta1_axle", param2 = param2}) + end, +}) + +Axle:set_valid_sides("techage:ta1_mill_gear", {"F", "B"}) +Axle:set_valid_sides("techage:ta1_axle_bearing1", {"F", "B"}) +Axle:set_valid_sides("techage:ta1_axle_bearing2", {"F", "B"}) + +minetest.register_node("techage:ta1_axle", { + description = S("TA1 Axle"), + tiles = { + "techage_axle_bearing.png^[transformR90", + "techage_axle_bearing.png^[transformR90", + "techage_axle_bearing.png", + "techage_axle_bearing.png", + "techage_axle_bearing.png", + "techage_axle_bearing.png", + }, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + {-1/8, -1/8, -4/8, 1/8, 1/8, 4/8}, + }, + }, + + after_place_node = function(pos, placer, itemstack, pointed_thing) + if not Axle:after_place_tube(pos, placer, pointed_thing) then + minetest.remove_node(pos) + return true + end + return false + end, + + after_dig_node = function(pos, oldnode, oldmetadata, digger) + Axle:after_dig_tube(pos, oldnode, oldmetadata) + end, + + paramtype2 = "facedir", -- important! + on_rotate = screwdriver.disallow, -- important! + paramtype = "light", + use_texture_alpha = techage.CLIP, + sunlight_propagates = true, + is_ground_content = false, + groups = {crumbly = 3, cracky = 3, snappy = 3}, + sounds = default.node_sound_wood_defaults(), +}) + +-- Bearings are defined as secondary nodes which forward received 'on_transfer' commands +minetest.register_node("techage:ta1_axle_bearing1", { + description = S("TA1 Axle Bearing"), + tiles = { + "default_stone_brick.png^techage_axle_bearing.png^[transformR90", + "default_stone_brick.png^techage_axle_bearing.png", + }, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + {-1/2, -1/2, -1/2, 1/2, -1/8, 1/2}, + {-1/8, -1/8, -1/2, 1/8, 1/8, 1/2}, + }, + }, + + after_place_node = function(pos, placer) + Axle:after_place_node(pos) + end, + + after_dig_node = function(pos, oldnode, oldmetadata, digger) + Axle:after_dig_node(pos) + end, + + paramtype2 = "facedir", + paramtype = "light", + use_texture_alpha = techage.CLIP, + sunlight_propagates = true, + is_ground_content = false, + groups = {cracky = 2, crumbly = 2, choppy = 2}, +}) + +minetest.register_node("techage:ta1_axle_bearing2", { + description = S("TA1 Axle Bearing"), + tiles = { + -- up, down, right, left, back, front + "default_stone_brick.png", + "default_stone_brick.png", + "default_stone_brick.png", + "default_stone_brick.png", + "default_stone_brick.png^techage_axle_bearing_front.png", + "default_stone_brick.png^techage_axle_bearing_front.png", + }, + + after_place_node = function(pos, placer) + Axle:after_place_node(pos) + end, + + after_dig_node = function(pos, oldnode, oldmetadata, digger) + Axle:after_dig_node(pos) + end, + + paramtype2 = "facedir", + paramtype = "light", + use_texture_alpha = techage.CLIP, + sunlight_propagates = true, + is_ground_content = false, + groups = {cracky = 2, crumbly = 2, choppy = 2}, +}) + +techage.register_node({"techage:ta1_axle_bearing1", "techage:ta1_axle_bearing2"}, { + on_transfer = function(pos, in_dir, topic, payload) + return techage.transfer( + pos, + in_dir, -- outdir + topic, + payload, + Axle, -- network + nil) -- valid nodes + end, +}) + + +minetest.register_craft({ + output = "techage:ta1_axle", + recipe = { + {"", "", ""}, + {"techage:iron_ingot", "dye:black", "techage:iron_ingot"}, + {"", "", ""}, + }, +}) + +minetest.register_craft({ + output = "techage:ta1_axle_bearing1", + recipe = { + {"", "", ""}, + {"", "techage:ta1_axle", ""}, + {"", "stairs:slab_stonebrick", ""}, + }, +}) + +minetest.register_craft({ + output = "techage:ta1_axle_bearing2", + recipe = { + {"", "", ""}, + {"", "techage:ta1_axle", ""}, + {"", "default:stonebrick", ""}, + }, +}) + +techage.TA1Axle = Axle diff --git a/ta1_watermill/water.lua b/ta1_watermill/water.lua new file mode 100644 index 0000000..64670ea --- /dev/null +++ b/ta1_watermill/water.lua @@ -0,0 +1,117 @@ +-- Based on and derived from minetest_game.default +-- License: LGPL v2.1 + +-- support for MT game translation. +local S = default.get_translator + +minetest.register_node("techage:water_flowing", { + description = S("Flowing Water"), + drawtype = "flowingliquid", + waving = 0, + tiles = {"default_water.png"}, + special_tiles = { + { + name = "default_water_flowing_animated.png", + backface_culling = false, + animation = { + type = "vertical_frames", + aspect_w = 16, + aspect_h = 16, + length = 0.5, + }, + }, + { + name = "default_water_flowing_animated.png", + backface_culling = true, + animation = { + type = "vertical_frames", + aspect_w = 16, + aspect_h = 16, + length = 0.5, + }, + }, + }, + use_texture_alpha = "blend", + paramtype = "light", + paramtype2 = "flowingliquid", + walkable = false, + pointable = false, + diggable = false, + buildable_to = true, + is_ground_content = false, + drop = "", + drowning = 1, + liquidtype = "flowing", + liquid_alternative_flowing = "techage:water_flowing", + liquid_alternative_source = "techage:water_source", + liquid_viscosity = 1, + post_effect_color = {a = 103, r = 30, g = 60, b = 90}, + groups = {water = 3, liquid = 3, cools_lava = 1, not_in_creative_inventory = 1}, + sounds = default.node_sound_water_defaults(), +}) + +minetest.register_node("techage:water_source", { + description = S("Water Source"), + drawtype = "flowingliquid", + waving = 0, + tiles = {"default_water.png"}, + special_tiles = { + { + name = "default_water_flowing_animated.png", + backface_culling = false, + animation = { + type = "vertical_frames", + aspect_w = 16, + aspect_h = 16, + length = 0.5, + }, + }, + { + name = "default_water_flowing_animated.png", + backface_culling = true, + animation = { + type = "vertical_frames", + aspect_w = 16, + aspect_h = 16, + length = 0.5, + }, + }, + }, + + use_texture_alpha = "blend", + paramtype = "light", + paramtype2 = "flowingliquid", + walkable = false, + pointable = false, + diggable = false, + buildable_to = true, + is_ground_content = false, + drop = "", + drowning = 1, + liquidtype = "source", + liquid_alternative_flowing = "techage:water_flowing", + liquid_alternative_source = "techage:water_source", + liquid_viscosity = 1, + post_effect_color = {a = 103, r = 30, g = 60, b = 90}, + groups = {water = 3, liquid = 3, cools_lava = 1, not_in_creative_inventory = 1}, + sounds = default.node_sound_water_defaults(), +}) + +minetest.register_node("techage:water_stop", { + description = "Water Stop", + drawtype = "glasslike_framed_optional", + tiles = {"techage_invisible.png"}, + inventory_image = 'techage_invisible_inv.png', + + use_texture_alpha = "blend", + paramtype = "light", + walkable = false, + pointable = false, + diggable = false, + buildable_to = true, + sunlight_propagates = true, + is_ground_content = false, + groups = {cracky = 3, oddly_breakable_by_hand = 3}, + sounds = default.node_sound_glass_defaults(), + drop = "", +}) diff --git a/ta1_watermill/watermill.lua b/ta1_watermill/watermill.lua new file mode 100644 index 0000000..644dfb1 --- /dev/null +++ b/ta1_watermill/watermill.lua @@ -0,0 +1,300 @@ +--[[ + + TechAge + ======= + + Copyright (C) 2021 Joachim Stolberg + + AGPL v3 + See LICENSE.txt for more information + + TA1 Watermill + +]]-- + +local M = minetest.get_meta +local S = techage.S + +local function calc_dir(dir, facedir) + if facedir == 1 then + return {x = dir.z, y = dir.y, z = -dir.x} + elseif facedir == 2 then + return {x = -dir.x, y = dir.y, z = -dir.z} + elseif facedir == 3 then + return {x = -dir.z, y = dir.y, z = dir.x} + end + return {x = dir.x, y = dir.y, z = dir.z} +end + +local function add_node(pos, dir, facedir, node_name) + local pos2 = vector.add(pos, calc_dir(dir, facedir)) + local node = minetest.get_node(pos2) + if techage.is_air_like(node.name) then + minetest.swap_node(pos2, {name = node_name}) + end +end + +local function remove_node(pos, dir, facedir, node_name) + local pos2 = vector.add(pos, calc_dir(dir, facedir)) + local node = minetest.get_node(pos2) + if node.name == node_name then + minetest.swap_node(pos2, {name = "air"}) + end +end + +local function water_flowing(pos, facedir, tRes) + facedir = ((facedir or 0) + 1) % 4 + local dir = minetest.facedir_to_dir(facedir) + + local pos2 = vector.add(pos, dir) + pos2.y = pos2.y + 1 + local node = minetest.get_node(pos2) + if node.name == "techage:water_flowing" then + tRes.backward = false + return true + end + + pos2 = vector.subtract(pos, dir) + pos2.y = pos2.y + 1 + node = minetest.get_node(pos2) + if node.name == "techage:water_flowing" then + tRes.backward = true + return true + end +end + +local function enough_space(pos, facedir) + local pos1 = vector.add(pos, calc_dir({x =-1, y =-1, z = 0}, facedir)) + local pos2 = vector.add(pos, calc_dir({x = 1, y = 1, z = 0}, facedir)) + local _, nodes = minetest.find_nodes_in_area(pos1, pos2, {"air"}) + return nodes["air"] and nodes["air"] == 8 +end + +local function remove_nodes(pos, facedir) + remove_node(pos, {x = 0, y = 1, z = 0}, facedir, "techage:water_stop") + remove_node(pos, {x =-1, y = 0, z = 0}, facedir, "techage:water_stop") + remove_node(pos, {x = 1, y = 0, z = 0}, facedir, "techage:water_stop") + remove_node(pos, {x =-1, y = 1, z =-1}, facedir, "techage:water_stop") + remove_node(pos, {x = 1, y = 1, z =-1}, facedir, "techage:water_stop") + remove_node(pos, {x =-1, y = 1, z = 1}, facedir, "techage:water_stop") + remove_node(pos, {x = 1, y = 1, z = 1}, facedir, "techage:water_stop") +end + +local function start_wheel(pos, facedir, backward) + local obj = minetest.add_entity(pos, "techage:ta1_watermill_entity") + local dir = minetest.facedir_to_dir(facedir) + local yaw = minetest.dir_to_yaw(dir) + if backward then + obj:set_rotation({x=-math.pi/2, y=yaw, z=0}) + else + obj:set_rotation({x=math.pi/2, y=yaw, z=0}) + end + local self = obj:get_luaentity() + self.facedir = facedir + + add_node(pos, {x = 0, y = 1, z = 0}, facedir, "techage:water_stop") + add_node(pos, {x =-1, y = 0, z = 0}, facedir, "techage:water_stop") + add_node(pos, {x = 1, y = 0, z = 0}, facedir, "techage:water_stop") + add_node(pos, {x =-1, y = 1, z =-1}, facedir, "techage:water_stop") + add_node(pos, {x = 1, y = 1, z =-1}, facedir, "techage:water_stop") + add_node(pos, {x =-1, y = 1, z = 1}, facedir, "techage:water_stop") + add_node(pos, {x = 1, y = 1, z = 1}, facedir, "techage:water_stop") + minetest.remove_node(pos) +end + +local function stop_wheel(pos, self) + self.facedir = self.facedir or 0 + if self.facedir == 0 or self.facedir == 2 then + minetest.swap_node(pos, {name = "techage:ta1_watermill", param2 = 4}) + M(pos):set_int("facedir", self.facedir) + minetest.get_node_timer(pos):start(2) + elseif self.facedir == 1 or self.facedir == 3 then + minetest.swap_node(pos, {name = "techage:ta1_watermill", param2 = 13}) + M(pos):set_int("facedir", self.facedir) + minetest.get_node_timer(pos):start(2) + end + + remove_nodes(pos, self.facedir) + self.object:remove() +end + +local function trigger_consumer(pos, facedir) + local outdir = facedir + 1 + local resp = techage.transfer( + pos, + outdir, -- outdir + "trigger", -- topic + nil, -- payload + techage.TA1Axle, -- network + nil) -- valid nodes + if not resp then + outdir = tubelib2.Turn180Deg[outdir] + resp = techage.transfer( + pos, + outdir, -- outdir + "trigger", -- topic + nil, -- payload + techage.TA1Axle, -- network + nil) -- valid nodes + end +end + +minetest.register_node("techage:ta1_watermill", { + description = S("TA1 Watermill"), + tiles = { + -- up, down, right, left, back, front + "default_wood.png", + "default_wood.png", + "default_wood.png", + "default_wood.png", + "default_wood.png", + "default_wood.png", + }, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + {-1/2, -1/2, -1/2, 1/2, 1/2, 1/2}, + + {-4.5/2, -1/2, 0.8/2, 4.5/2, 1/2, 1.0/2}, + {-4.5/2, -1/2, -1.0/2, 4.5/2, 1/2, -0.8/2}, + {-3.8/2, -1/2, 2.1/2, 3.8/2, 1/2, 2.3/2}, + {-3.8/2, -1/2, -2.3/2, 3.8/2, 1/2, -2.1/2}, + + { 0.8/2, -1/2, -4.5/2, 1.0/2, 1/2, 4.5/2}, + {-1.0/2, -1/2, -4.5/2, -0.8/2, 1/2, 4.5/2}, + { 2.1/2, -1/2, -3.8/2, 2.3/2, 1/2, 3.8/2}, + {-2.3/2, -1/2, -3.8/2, -2.1/2, 1/2, 3.8/2}, + }, + }, + on_rightclick = function(pos, node, clicker) + start_wheel(pos, M(pos):get_int("facedir")) + end, + + on_timer = function(pos, elapsed) + local tRes = {} + if water_flowing(pos, M(pos):get_int("facedir"), tRes) then + start_wheel(pos, M(pos):get_int("facedir"), tRes.backward) + end + return true + end, + + paramtype2 = "facedir", + paramtype = "light", + use_texture_alpha = techage.CLIP, + sunlight_propagates = true, + is_ground_content = false, + groups = {cracky = 2, crumbly = 2, choppy = 2, not_in_creative_inventory = 1}, + node_placement_prediction = "", + drop = "techage:ta1_watermill_inv", +}) + +-- A smaller one for the inventory +minetest.register_node("techage:ta1_watermill_inv", { + description = S("TA1 Watermill"), + --inventory_image = "techage_waterwheel_inv.png", + --wield_image = "techage_waterwheel_inv.png", + tiles = { + -- up, down, right, left, back, front + "default_wood.png", + "default_wood.png", + "default_wood.png", + "default_wood.png", + "default_wood.png", + "default_wood.png", + }, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + {-1/4, -1/4, -1/4, 1/4, 1/4, 1/4}, + + {-4.5/4, 0.8/4, -1/4, 4.5/4, 1.0/4, 1/4}, + {-4.5/4, -1.0/4, -1/4, 4.5/4, -0.8/4, 1/4}, + {-3.8/4, 2.1/4, -1/4, 3.8/4, 2.3/4, 1/4}, + {-3.8/4, -2.3/4, -1/4, 3.8/4, -2.1/4, 1/4}, + + { 0.8/4, -4.5/4, -1/4, 1.0/4, 4.5/4, 1/4}, + {-1.0/4, -4.5/4, -1/4, -0.8/4, 4.5/4, 1/4}, + { 2.1/4, -3.8/4, -1/4, 2.3/4, 3.8/4, 1/4}, + {-2.3/4, -3.8/4, -1/4, -2.1/4, 3.8/4, 1/4}, + }, + }, + + after_place_node = function(pos, placer) + local node = minetest.get_node(pos) + M(pos):set_int("facedir", node.param2) + remove_nodes(pos, node.param2) + if (node.param2 == 0 or node.param2 == 2) and enough_space(pos, node.param2) then + minetest.swap_node(pos, {name = "techage:ta1_watermill", param2 = 4}) + minetest.get_node_timer(pos):start(2) + elseif (node.param2 == 1 or node.param2 == 3) and enough_space(pos, node.param2) then + minetest.swap_node(pos, {name = "techage:ta1_watermill", param2 = 13}) + minetest.get_node_timer(pos):start(2) + else + minetest.remove_node(pos) + return true + end + end, + + paramtype2 = "facedir", + node_placement_prediction = "", + diggable = false, +}) + +techage.register_node({"techage:ta1_watermill"}, { + on_node_load = function(pos, node) + minetest.get_node_timer(pos):start(2) + end, +}) + + +minetest.register_entity("techage:ta1_watermill_entity", { + initial_properties = { + physical = true, + collisionbox = {-0.5, -1.5, -1.5, 0.5, 1.5, 1.5}, + visual = "wielditem", + wield_item = "techage:ta1_watermill", + visual_size = {x=0.67, y=0.67, z=0.67}, + static_save = true, + automatic_rotate = -math.pi * 0.2, + pointable = false, + }, + + on_step = function(self, dtime) + self.dtime = (self.dtime or 0) + dtime + + if self.dtime > 2 then + self.dtime = 0 + local pos = vector.round(self.object:get_pos()) + if not water_flowing(pos, self.facedir, {}) then + stop_wheel(pos, self) + end + trigger_consumer(pos, self.facedir) + minetest.sound_play("techage_watermill", {gain = 0.3, pos = pos, + max_hear_distance = 10}, true) + end + end, + + on_rightclick = function(self, clicker) + local pos = vector.round(self.object:get_pos()) + stop_wheel(pos, self) + end, + + on_activate = function(self, staticdata) + self.facedir = tonumber(staticdata) or 0 + end, + + get_staticdata = function(self) + return self.facedir + end, +}) + +minetest.register_craft({ + output = "techage:ta1_watermill_inv", + recipe = { + {"techage:ta1_board1_apple", "techage:ta1_board1_apple", "techage:ta1_board1_apple"}, + {"techage:ta1_board1_apple", "default:wood", "techage:ta1_board1_apple"}, + {"techage:ta1_board1_apple", "techage:ta1_board1_apple", "techage:ta1_board1_apple"}, + }, +}) diff --git a/textures/techage_axle_bearing.png b/textures/techage_axle_bearing.png new file mode 100644 index 0000000..61be451 Binary files /dev/null and b/textures/techage_axle_bearing.png differ diff --git a/textures/techage_axle_bearing_front.png b/textures/techage_axle_bearing_front.png new file mode 100644 index 0000000..175fb56 Binary files /dev/null and b/textures/techage_axle_bearing_front.png differ diff --git a/textures/techage_invisible.png b/textures/techage_invisible.png new file mode 100644 index 0000000..b550190 Binary files /dev/null and b/textures/techage_invisible.png differ diff --git a/textures/techage_invisible_inv.png b/textures/techage_invisible_inv.png new file mode 100644 index 0000000..9374d17 Binary files /dev/null and b/textures/techage_invisible_inv.png differ diff --git a/textures/techage_junglewood.png b/textures/techage_junglewood.png new file mode 100644 index 0000000..43c3733 Binary files /dev/null and b/textures/techage_junglewood.png differ diff --git a/textures/techage_junglewood_top.png b/textures/techage_junglewood_top.png new file mode 100644 index 0000000..746a870 Binary files /dev/null and b/textures/techage_junglewood_top.png differ diff --git a/textures/techage_mill_base.png b/textures/techage_mill_base.png new file mode 100644 index 0000000..50b5d33 Binary files /dev/null and b/textures/techage_mill_base.png differ diff --git a/textures/techage_mill_front.png b/textures/techage_mill_front.png new file mode 100644 index 0000000..97351d4 Binary files /dev/null and b/textures/techage_mill_front.png differ diff --git a/textures/techage_mill_inv.png b/textures/techage_mill_inv.png new file mode 100644 index 0000000..16ac43d Binary files /dev/null and b/textures/techage_mill_inv.png differ diff --git a/textures/techage_mill_side.png b/textures/techage_mill_side.png new file mode 100644 index 0000000..d7ee649 Binary files /dev/null and b/textures/techage_mill_side.png differ diff --git a/textures/techage_sluice1_inv.png b/textures/techage_sluice1_inv.png new file mode 100644 index 0000000..201f742 Binary files /dev/null and b/textures/techage_sluice1_inv.png differ diff --git a/textures/techage_sluice2_inv.png b/textures/techage_sluice2_inv.png new file mode 100644 index 0000000..80a4cb1 Binary files /dev/null and b/textures/techage_sluice2_inv.png differ diff --git a/textures/techage_water_flowing.png b/textures/techage_water_flowing.png new file mode 100644 index 0000000..718d334 Binary files /dev/null and b/textures/techage_water_flowing.png differ diff --git a/textures/techage_watermill1_inv.png b/textures/techage_watermill1_inv.png new file mode 100644 index 0000000..b7f26fc Binary files /dev/null and b/textures/techage_watermill1_inv.png differ diff --git a/textures/techage_watermill2_inv.png b/textures/techage_watermill2_inv.png new file mode 100644 index 0000000..9d917ac Binary files /dev/null and b/textures/techage_watermill2_inv.png differ diff --git a/textures/techage_watermill3_inv.png b/textures/techage_watermill3_inv.png new file mode 100644 index 0000000..e58e307 Binary files /dev/null and b/textures/techage_watermill3_inv.png differ diff --git a/textures/techage_watermill4_inv.png b/textures/techage_watermill4_inv.png new file mode 100644 index 0000000..8198c86 Binary files /dev/null and b/textures/techage_watermill4_inv.png differ diff --git a/textures/techage_wood50.png b/textures/techage_wood50.png new file mode 100644 index 0000000..18914f2 Binary files /dev/null and b/textures/techage_wood50.png differ