From b21c3d368077aa3a1c42ff1582cda6263c018585 Mon Sep 17 00:00:00 2001 From: Vanessa Dannenberg Date: Wed, 6 Mar 2019 17:01:02 -0500 Subject: updated cottages, areasprotector, bees, biome_lib, technic, facade, farming redo, homedecor, maptools, mesecons, moreblocks, moreores, pipeworks, quartz, travelnet, unified_inventory, unifieddyes, xban2 delete the playeranim mod, not 5.0.0 compatible. --- cottages/functions.lua | 42 +++++ cottages/init.lua | 25 +++ cottages/locale/de.txt | 27 +++ cottages/locale/template.txt | 36 +++- cottages/nodes_feldweg.lua | 108 +++++++++-- cottages/nodes_furniture.lua | 10 +- cottages/nodes_hay.lua | 135 +++++++++++++ cottages/nodes_historic.lua | 19 +- cottages/nodes_mining.lua | 4 +- cottages/nodes_pitchfork.lua | 114 +++++++++++ cottages/nodes_roof.lua | 24 ++- cottages/nodes_straw.lua | 79 ++++---- cottages/nodes_water.lua | 312 +++++++++++++++++++++++++++++++ cottages/textures/cottages_pitchfork.png | Bin 0 -> 1262 bytes 14 files changed, 854 insertions(+), 81 deletions(-) create mode 100644 cottages/functions.lua create mode 100644 cottages/nodes_hay.lua create mode 100644 cottages/nodes_pitchfork.lua create mode 100644 cottages/nodes_water.lua create mode 100644 cottages/textures/cottages_pitchfork.png (limited to 'cottages') diff --git a/cottages/functions.lua b/cottages/functions.lua new file mode 100644 index 0000000..81d88bc --- /dev/null +++ b/cottages/functions.lua @@ -0,0 +1,42 @@ + +local S = cottages.S + +--- if no owner is set, all players may use the node; else only the owner +cottages.player_can_use = function( meta, player ) + if( not( player) or not( meta )) then + return false; + end + local pname = player:get_player_name(); + local owner = meta:get_string('owner' ); + local public = meta:get_string('public') + if( not(owner) or owner=="" or owner==pname or public=="public") then + return true; + end + return false; +end + + +-- call this in on_receive_fields and add suitable buttons in order +-- to switch between public and private use +cottages.switch_public = function(pos, formname, fields, sender, name_of_the_thing) + -- switch between public and private + local meta = minetest.get_meta(pos) + local public = meta:get_string("public") + local owner = meta:get_string("owner") + if( sender and sender:get_player_name() == owner and fields.public) then + if( public ~= "public") then + meta:set_string("public", "public") + meta:set_string("infotext", + S("Public "..name_of_the_thing.." (owned by %s)"):format(owner)) + minetest.chat_send_player(owner, + S("Your "..name_of_the_thing.." can now be used by other players as well.")) + else + meta:set_string("public", "") + meta:set_string("infotext", + S("Private "..name_of_the_thing.." (owned by %s)"):format(owner)) + minetest.chat_send_player(owner, + S("Your "..name_of_the_thing.." can only be used by yourself.")) + end + return true + end +end diff --git a/cottages/init.lua b/cottages/init.lua index a2a4751..b6c412b 100644 --- a/cottages/init.lua +++ b/cottages/init.lua @@ -29,10 +29,30 @@ else cottages.S = function(s) return s end end +cottages.sounds = {} -- MineClone2 needs special treatment; default is only needed for -- crafting materials and sounds (less important) if( not( minetest.get_modpath("default"))) then default = {}; + cottages.sounds.wood = nil + cottages.sounds.dirt = nil + cottages.sounds.leaves = nil + cottages.sounds.stone = nil +else + cottages.sounds.wood = default.node_sound_wood_defaults() + cottages.sounds.dirt = default.node_sound_dirt_defaults() + cottages.sounds.stone = default.node_sound_stone_defaults() + cottages.sounds.leaves = default.node_sound_leaves_defaults() +end + +-- the straw from default comes with stairs as well and might replace +-- cottages:roof_connector_straw and cottages:roof_flat_straw +-- however, that does not look very good +if( false and minetest.registered_nodes["farming:straw"]) then + cottages.straw_texture = "farming_straw.png" + cottages.use_farming_straw_stairs = true +else + cottages.straw_texture = "cottages_darkage_straw.png" end --cottages.config_use_mesh_barrel = false; --cottages.config_use_mesh_handmill = true; @@ -57,18 +77,23 @@ cottages.handmill_product[ 'default:coal_lump'] = 'dye:black 6'; cottages.handmill_max_per_turn = 20; cottages.handmill_min_per_turn = 0; +dofile(minetest.get_modpath("cottages").."/functions.lua"); -- uncomment parts you do not want dofile(minetest.get_modpath("cottages").."/nodes_furniture.lua"); dofile(minetest.get_modpath("cottages").."/nodes_historic.lua"); dofile(minetest.get_modpath("cottages").."/nodes_feldweg.lua"); +-- allows to dig hay and straw fast +dofile(minetest.get_modpath("cottages").."/nodes_pitchfork.lua"); dofile(minetest.get_modpath("cottages").."/nodes_straw.lua"); +dofile(minetest.get_modpath("cottages").."/nodes_hay.lua"); dofile(minetest.get_modpath("cottages").."/nodes_anvil.lua"); dofile(minetest.get_modpath("cottages").."/nodes_doorlike.lua"); dofile(minetest.get_modpath("cottages").."/nodes_fences.lua"); dofile(minetest.get_modpath("cottages").."/nodes_roof.lua"); dofile(minetest.get_modpath("cottages").."/nodes_barrel.lua"); dofile(minetest.get_modpath("cottages").."/nodes_mining.lua"); +dofile(minetest.get_modpath("cottages").."/nodes_water.lua"); --dofile(minetest.get_modpath("cottages").."/nodes_chests.lua"); -- this is only required and useful if you run versions of the random_buildings mod where the nodes where defined inside that mod diff --git a/cottages/locale/de.txt b/cottages/locale/de.txt index 9677a3b..d8f8207 100644 --- a/cottages/locale/de.txt +++ b/cottages/locale/de.txt @@ -109,6 +109,8 @@ straw = Stroh threshing floor = Dreschboden Threshing floor = Dreschboden Threshing floor (owned by %s) = Dreschboden (gehoert %s) +Public threshing floor (owned by %s) = Öffentlicher Dreschboden (gehoert %s) +Private threshing floor (owned by %s) = Privater Dreschboden (gehoert %s) Harvested wheat: = Geernteter Weizen Straw: = Stroh Seeds: = Koerner @@ -120,6 +122,8 @@ You have threshed the last %s wheat. = Du hast die letzten %s Weizenaehren gedr mill, powered by punching = Muehle, durch Schlagen antreiben Mill, powered by punching = Muehle, durch Schlagen antreiben Mill, powered by punching (owned by %s) = Muehle, durch Schlagen antreiben (gehoert %s) +Public mill, powered by punching (owned by %s) = Öffentliche Muehle, durch Schlagen antreiben (gehoert %s) +Private mill, powered by punching (owned by %s) = Private Muehle, durch Schlagen antreiben (gehoert %s) Wheat seeds: = Weizenkoerner Flour: = Mehl Mill = Muehle @@ -128,3 +132,26 @@ Punch this hand-driven mill = Schlage auf diese handbetriebene Muehle to convert wheat seeds into flour. = um Weizenkoerner in Mehl umzuwandeln. You have grinded %s wheat seeds (%s are left). = Du hast %s Weizenkoerner gemahlen (%s bleiben uebrig). You have grinded the last %s wheat seeds. = Du hast die letzten %s Weizenkoerner gemahlen. + +Your threshing floor can now be used by other players as well. = Dein Dreschboden kann jetzt auch von anderen Spielern benutzt werden. +Your mill, powered by punching can now be used by other players as well. = Deine Mühle kann jetzt auch von anderen Spielern benutzt werden. + +Your threshing floor can only be used by yourself. = Dein Dreschboden kann jetzt nur noch von dir selbst benutzt werden. +Your mill, powered by punching can only be used by yourself. = Deine Mühle kann jetzt nur noch von dir selbst benutzt werden. + +Public? = Oeffentlich? + +Public tree trunk well = Oeffentlicher Baumstammbrunnen +Public tree trunk well (owned by %s) = Oeffentlicher Baumstammbrunnen (gehoert %s) +Private tree trunk well (owned by %s) = Privater Baumstammbrunnen (gehoert %s) +This tree trunk well is owned by %s. You can't use it. = Dieser Baumstammbrunnen gehoert %s. Du kannst ihn leider nicht benutzen. +Sorry. You have no room for the bucket. Please free some space in your inventory first! = Du hast leider keinen Platz mehr fuer den Eimer. Bitte schaffe erst ein wenig Platz! +Your tree trunk well can now be used by other players as well. = Dein Baumstammbrunnen kann jetzt auch von anderen Spielern benutzt werdn. +Your tree trunk well can only be used by yourself. = Dein Baumstammbrunnen kann jetzt nur noch von dir selbst benutzt werdn. + +pitchfork (dig dirt with grass to get hay, place with right-click) = Heugabel (grabe Erde mit Grass um Heu zu bekommen; Rechts-Klick zum Platzieren) +pitchfork (for hay and straw) = Heugabel (fuer Heu und Stroh) + +Some hay = Etwas Heu +Hay = Heu +Hay bale = Heuballen diff --git a/cottages/locale/template.txt b/cottages/locale/template.txt index cbc6990..40c24d3 100644 --- a/cottages/locale/template.txt +++ b/cottages/locale/template.txt @@ -105,9 +105,11 @@ Reet for thatching = layer of straw = straw bale = straw = -threshing floor = -Threshing floor = -Threshing floor (owned by %s) = +threshing floor = +Threshing floor = +Threshing floor (owned by %s) = +Public threshing floor (owned by %s) = +Private threshing floor (owned by %s) = Harvested wheat: = Straw: = Seeds: = @@ -117,8 +119,10 @@ to get straw and seeds from wheat. = You have threshed %s wheat (%s are left). = You have threshed the last %s wheat. = mill, powered by punching = -Mill, powered by punching = -Mill, powered by punching (owned by %s) = +Mill, powered by punching = +Mill, powered by punching (owned by %s) = +Public mill, powered by punching (owned by %s) = +Private mill, powered by punching (owned by %s) = Wheat seeds: = Flour: = Mill = @@ -127,3 +131,25 @@ Punch this hand-driven mill = to convert wheat seeds into flour. = You have grinded %s wheat seeds (%s are left). = You have grinded the last %s wheat seeds. = + +Your threshing floor can now be used by other players as well. = +Your mill, powered by punching can now be used by other players as well. = + +Your threshing floor can only be used by yourself. = +Your mill, powered by punching can only be used by yourself. = + +Public? = + +Public tree trunk well = +Public tree trunk well (owned by %s) = +This tree trunk well is owned by %s. You can't use it. = +Sorry. You have no room for the bucket. Please free some space in your inventory first! = +Your tree trunk well can now be used by other players as well. = +Your tree trunk well can only be used by yourself. = + +pitchfork (dig dirt with grass to get hay, place with right-click) = +pitchfork (for hay and straw) = + +Some hay = +Hay = +Hay bale = diff --git a/cottages/nodes_feldweg.lua b/cottages/nodes_feldweg.lua index bb21479..d81cc02 100644 --- a/cottages/nodes_feldweg.lua +++ b/cottages/nodes_feldweg.lua @@ -19,6 +19,47 @@ if( not( cottages_feldweg_mode )) then cottages_feldweg_mode = "mesh"; end +local function register_recipes(include_end) + + minetest.register_craft({ + output = "cottages:feldweg_crossing 5", + recipe = { + {"", "cottages:feldweg", "" }, + {"cottages:feldweg", "cottages:feldweg", "cottages:feldweg"}, + {"", "cottages:feldweg", "" }, + }, + }) + + minetest.register_craft({ + output = "cottages:feldweg_t_junction 5", + recipe = { + {"", "cottages:feldweg", "" }, + {"", "cottages:feldweg", "" }, + {"cottages:feldweg", "cottages:feldweg", "cottages:feldweg"} + + }, + }) + + minetest.register_craft({ + output = "cottages:feldweg_curve 5", + recipe = { + {"cottages:feldweg", "", "" }, + {"cottages:feldweg", "", ""}, + {"cottages:feldweg", "cottages:feldweg", "cottages:feldweg"} + }, + }) + + if include_end then + minetest.register_craft({ + output = "cottages:feldweg_end 5", + recipe = { + {"cottages:feldweg", "", "cottages:feldweg" }, + {"cottages:feldweg", "cottages:feldweg", "cottages:feldweg"} + }, + }) + end +end + --- a nice dirt road for small villages or paths to fields if( cottages_feldweg_mode == "simple" or cottages_feldweg_mode == "flat" ) then minetest.register_node("cottages:feldweg", { @@ -28,7 +69,7 @@ if( cottages_feldweg_mode == "simple" or cottages_feldweg_mode == "flat" ) then groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2}, legacy_facedir_simple = true, groups = {crumbly=3}, - sounds = default.node_sound_dirt_defaults, + sounds = cottages.sounds.dirt, is_ground_content = false, }) end @@ -47,7 +88,7 @@ if( cottages_feldweg_mode == "flat" ) then groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2}, legacy_facedir_simple = true, groups = {crumbly=3}, - sounds = default.node_sound_dirt_defaults, + sounds = cottages.sounds.dirt, is_ground_content = false, }) @@ -58,7 +99,7 @@ if( cottages_feldweg_mode == "flat" ) then groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2}, legacy_facedir_simple = true, groups = {crumbly=3}, - sounds = default.node_sound_dirt_defaults, + sounds = cottages.sounds.dirt, is_ground_content = false, }) @@ -69,10 +110,11 @@ if( cottages_feldweg_mode == "flat" ) then groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2}, legacy_facedir_simple = true, groups = {crumbly=3}, - sounds = default.node_sound_dirt_defaults, + sounds = cottages.sounds.dirt, is_ground_content = false, }) - + + register_recipes(false) -- -- cube-style nodebox version -- @@ -84,7 +126,7 @@ elseif( cottages_feldweg_mode == "nodebox" ) then roups = {snappy=2,choppy=2,oddly_breakable_by_hand=2}, legacy_facedir_simple = true, groups = {crumbly=3}, - sounds = default.node_sound_dirt_defaults, + sounds = cottages.sounds.dirt, is_ground_content = false, drawtype = "nodebox", -- top, bottom, side1, side2, inner, outer @@ -116,7 +158,7 @@ elseif( cottages_feldweg_mode == "nodebox" ) then groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2}, legacy_facedir_simple = true, groups = {crumbly=3}, - sounds = default.node_sound_dirt_defaults, + sounds = cottages.sounds.dirt, is_ground_content = false, drawtype = "nodebox", @@ -162,7 +204,7 @@ elseif( cottages_feldweg_mode == "nodebox" ) then groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2}, legacy_facedir_simple = true, groups = {crumbly=3}, - sounds = default.node_sound_dirt_defaults, + sounds = cottages.sounds.dirt, is_ground_content = false, drawtype = "nodebox", @@ -206,7 +248,7 @@ elseif( cottages_feldweg_mode == "nodebox" ) then groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2}, legacy_facedir_simple = true, groups = {crumbly=3}, - sounds = default.node_sound_dirt_defaults, + sounds = cottages.sounds.dirt, is_ground_content = false, drawtype = "nodebox", @@ -243,6 +285,8 @@ elseif( cottages_feldweg_mode == "nodebox" ) then }, }) + register_recipes(false) + -- -- the mesh version (rounded); provided and created by VanessaE @@ -256,7 +300,7 @@ elseif( cottages_feldweg_mode == "mesh" ) then groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2}, legacy_facedir_simple = true, groups = {crumbly=3}, - sounds = default.node_sound_dirt_defaults, + sounds = cottages.sounds.dirt, is_ground_content = false, tiles = {"cottages_feldweg_end.png","default_dirt.png^default_grass_side.png", "default_dirt.png", "default_grass.png", @@ -274,7 +318,7 @@ elseif( cottages_feldweg_mode == "mesh" ) then groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2}, legacy_facedir_simple = true, groups = {crumbly=3}, - sounds = default.node_sound_dirt_defaults, + sounds = cottages.sounds.dirt, is_ground_content = false, tiles = {"cottages_feldweg_end.png","default_dirt.png", "default_grass.png","cottages_feldweg_surface.png", @@ -284,13 +328,15 @@ elseif( cottages_feldweg_mode == "mesh" ) then mesh = "feldweg-crossing.obj", }) + + minetest.register_node("cottages:feldweg_t_junction", { description = S("dirt road t junction"), paramtype2 = "facedir", groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2}, legacy_facedir_simple = true, groups = {crumbly=3}, - sounds = default.node_sound_dirt_defaults, + sounds = cottages.sounds.dirt, is_ground_content = false, tiles = {"cottages_feldweg_end.png","default_dirt.png^default_grass_side.png", "default_dirt.png", "default_grass.png","cottages_feldweg_surface.png", @@ -299,6 +345,8 @@ elseif( cottages_feldweg_mode == "mesh" ) then drawtype = "mesh", mesh = "feldweg-T-junction.obj", }) + + minetest.register_node("cottages:feldweg_curve", { description = S("dirt road curve"), @@ -306,7 +354,7 @@ elseif( cottages_feldweg_mode == "mesh" ) then groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2}, legacy_facedir_simple = true, groups = {crumbly=3}, - sounds = default.node_sound_dirt_defaults, + sounds = cottages.sounds.dirt, is_ground_content = false, tiles = {"default_dirt.png^default_grass_side.png","default_grass.png", "default_dirt.png^default_grass_side.png","cottages_feldweg_surface.png", @@ -316,13 +364,15 @@ elseif( cottages_feldweg_mode == "mesh" ) then mesh = "feldweg-curve.obj", }) + + minetest.register_node("cottages:feldweg_end", { description = S("dirt road end"), paramtype2 = "facedir", groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2}, legacy_facedir_simple = true, groups = {crumbly=3}, - sounds = default.node_sound_dirt_defaults, + sounds = cottages.sounds.dirt, is_ground_content = false, tiles = {"cottages_feldweg_end.png","default_dirt.png^default_grass_side.png", "default_dirt.png", "default_grass.png", @@ -332,6 +382,11 @@ elseif( cottages_feldweg_mode == "mesh" ) then drawtype = "mesh", mesh = "feldweg_end.obj", }) + + + register_recipes(true) + + end @@ -342,7 +397,7 @@ if( minetest.get_modpath("stairs") and stairs and stairs.register_stair_and_slab {"cottages_feldweg.png","default_dirt.png", "default_grass.png","default_grass.png","cottages_feldweg.png","cottages_feldweg.png"}, S("Dirt Road Stairs"), S("Dirt Road, half height"), - default.node_sound_dirt_defaults) + cottages.sounds.dirt) end if( cottages_feldweg_mode == "nodebox" or cottages_feldweg_mode == "mesh" ) then @@ -371,7 +426,7 @@ if( cottages_feldweg_mode == "nodebox" or cottages_feldweg_mode == "mesh" ) then groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2}, legacy_facedir_simple = true, groups = {crumbly=3}, - sounds = default.node_sound_dirt_defaults, + sounds = cottages.sounds.dirt, is_ground_content = false, tiles = {"cottages_feldweg_end.png","default_dirt.png^default_grass_side.png", "default_dirt.png", "default_grass.png", @@ -385,13 +440,15 @@ if( cottages_feldweg_mode == "nodebox" or cottages_feldweg_mode == "mesh" ) then selection_box = box_slope, }) + + minetest.register_node("cottages:feldweg_slope_long", { description = S("dirt road slope long"), paramtype2 = "facedir", groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2}, legacy_facedir_simple = true, groups = {crumbly=3}, - sounds = default.node_sound_dirt_defaults, + sounds = cottages.sounds.dirt, is_ground_content = false, tiles = {"cottages_feldweg_end.png","default_dirt.png^default_grass_side.png", "default_dirt.png", "default_grass.png", @@ -403,4 +460,21 @@ if( cottages_feldweg_mode == "nodebox" or cottages_feldweg_mode == "mesh" ) then collision_box = box_slope_long, selection_box = box_slope_long, }) + + + minetest.register_craft({ + output = "cottages:feldweg_slope 3", + recipe = { + {"cottages:feldweg", "", "" }, + {"cottages:feldweg", "cottages:feldweg", ""} + }, + }) + + minetest.register_craft({ + output = "cottages:feldweg_slope_long 4", + recipe = { + {"cottages:feldweg", "", "" }, + {"cottages:feldweg", "cottages:feldweg", "cottages:feldweg"} + }, + }) end diff --git a/cottages/nodes_furniture.lua b/cottages/nodes_furniture.lua index 056c8d7..5705c76 100644 --- a/cottages/nodes_furniture.lua +++ b/cottages/nodes_furniture.lua @@ -23,7 +23,7 @@ minetest.register_node("cottages:bed_foot", { paramtype = "light", paramtype2 = "facedir", groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=3}, - sounds = default.node_sound_wood_defaults, + sounds = cottages.sounds.wood, node_box = { type = "fixed", fixed = { @@ -58,7 +58,7 @@ minetest.register_node("cottages:bed_head", { paramtype = "light", paramtype2 = "facedir", groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=3}, - sounds = default.node_sound_wood_defaults, + sounds = cottages.sounds.wood, node_box = { type = "fixed", fixed = { @@ -99,7 +99,7 @@ minetest.register_node("cottages:sleeping_mat", { paramtype2 = "facedir", walkable = false, groups = { snappy = 3 }, - sounds = default.node_sound_leaves_defaults, + sounds = cottages.sounds.leaves, selection_box = { type = "wallmounted", }, @@ -133,7 +133,7 @@ minetest.register_node("cottages:sleeping_mat_head", { paramtype = 'light', paramtype2 = "facedir", groups = { snappy = 3 }, - sounds = default.node_sound_leaves_defaults, + sounds = cottages.sounds.leaves, node_box = { type = "fixed", fixed = { @@ -162,7 +162,7 @@ minetest.register_node("cottages:bench", { paramtype = "light", paramtype2 = "facedir", groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=3}, - sounds = default.node_sound_wood_defaults, + sounds = cottages.sounds.wood, node_box = { type = "fixed", fixed = { diff --git a/cottages/nodes_hay.lua b/cottages/nodes_hay.lua new file mode 100644 index 0000000..3d1f8b0 --- /dev/null +++ b/cottages/nodes_hay.lua @@ -0,0 +1,135 @@ +-- contains hay_mat, hay and hay bale +-- (gives the pitchfork some work) +-- +local S = cottages.S + +-- If default:dirt_with_grass is digged while wielding a pitchfork, it will +-- turn into dirt and get some hay placed above it. +-- The hay will disappear (decay) after a couple of minutes. +if( minetest.registered_items["default:dirt_with_grass"] + and minetest.registered_tools["cottages:pitchfork"]) then + minetest.override_item("default:dirt_with_grass", { + after_dig_node = function(pos, oldnode, oldmetadata, digger) + if( not( pos ) or not( digger )) then + return + end + local wielded = digger:get_wielded_item() + if( not( wielded ) + or not( wielded:get_name() ) + or (wielded:get_name()~="cottages:pitchfork")) then + return + end + + local pos_above = {x=pos.x, y=pos.y+1, z=pos.z} + local node_above = minetest.get_node_or_nil( pos_above) + if( not(node_above) or not(node_above.name) or node_above.name ~= "air" ) then + return nil + end + minetest.swap_node( pos, {name="default:dirt"}) + minetest.add_node( pos_above, {name="cottages:hay_mat", param2=math.random(2,25)}) + -- start a node timer so that the hay will decay after some time + local timer = minetest.get_node_timer(pos_above) + if not timer:is_started() then + timer:start(math.random(60, 300)) + end + -- TODO: prevent dirt from beeing multiplied this way (that is: give no dirt!) + return + end, + }) +end + + + +-- more comparable to the straw mat than to a hay bale +-- (can be created by digging dirt with grass with the pitchfork) +minetest.register_node("cottages:hay_mat", { + drawtype = "nodebox", + paramtype2 = "leveled", + description = S("Some hay"), + tiles = {cottages.straw_texture.."^[multiply:#88BB88"}, + groups = {hay=3, snappy=2, oddly_breakable_by_hand=2, flammable=3}, + sounds = cottages.sounds.leaves, + -- the bale is slightly smaller than a full node + is_ground_content = false, + node_box = { + type = "leveled", --"fixed", + fixed = { + {-0.5,-0.5,-0.5, 0.5, 0.5, 0.5}, + } + }, + -- make sure a placed hay block looks halfway reasonable + after_place_node = function(pos, placer, itemstack, pointed_thing) + minetest.swap_node( pos, {name="cottages:hay_mat", param2=math.random(2,25)}) + end, + on_timer = function(pos, elapsed) + local node = minetest.get_node(pos) + if( node and node.name=="cottages:hay_mat") then + minetest.remove_node(pos) + minetest.check_for_falling(pos) + end + end, +}) + +-- hay block, similar to straw block +minetest.register_node("cottages:hay", { + description = S("Hay"), + tiles = {cottages.straw_texture.."^[multiply:#88BB88"}, + groups = {hay=3, snappy=2, oddly_breakable_by_hand=2, flammable=3}, + sounds = cottages.sounds.leaves, + is_ground_content = false, +}) + + +-- hay bales for hungry animals +minetest.register_node("cottages:hay_bale", { + drawtype = "nodebox", + description = S("Hay bale"), + tiles = {"cottages_darkage_straw_bale.png^[multiply:#88BB88"}, + paramtype = "light", + groups = {hay=3, snappy=2, oddly_breakable_by_hand=2, flammable=3}, + sounds = cottages.sounds.leaves, + -- the bale is slightly smaller than a full node + node_box = { + type = "fixed", + fixed = { + {-0.45, -0.5,-0.45, 0.45, 0.45, 0.45}, + } + }, + selection_box = { + type = "fixed", + fixed = { + {-0.45, -0.5,-0.45, 0.45, 0.45, 0.45}, + } + }, + is_ground_content = false, +}) + + +-- +-- craft recipes +-- +minetest.register_craft({ + output = "cottages:hay_mat 9", + recipe = { + {"cottages:hay"}, + }, +}) + +minetest.register_craft({ + output = "cottages:hay", + recipe = { + {"cottages:hay_mat", "cottages:hay_mat", "cottages:hay_mat"}, + {"cottages:hay_mat", "cottages:hay_mat", "cottages:hay_mat"}, + {"cottages:hay_mat", "cottages:hay_mat", "cottages:hay_mat"}, + }, +}) + +minetest.register_craft({ + output = "cottages:hay", + recipe = {{"cottages:hay_bale"}}, +}) + +minetest.register_craft({ + output = "cottages:hay_bale", + recipe = {{"cottages:hay"}}, +}) diff --git a/cottages/nodes_historic.lua b/cottages/nodes_historic.lua index 90e48c4..af8aa3a 100644 --- a/cottages/nodes_historic.lua +++ b/cottages/nodes_historic.lua @@ -27,7 +27,6 @@ minetest.register_node("cottages:wagon_wheel", { }, groups = {choppy=2,dig_immediate=2,attached_node=1}, legacy_wallmounted = true, - sounds = default.node_sound_defaults, is_ground_content = false, }) @@ -38,7 +37,7 @@ minetest.register_node("cottages:loam", { tiles = {"cottages_loam.png"}, groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2}, groups = {crumbly=3}, - sounds = default.node_sound_dirt_defaults, + sounds = cottages.sounds.dirt, is_ground_content = false, }) @@ -50,7 +49,7 @@ if( minetest.get_modpath("stairs") and stairs and stairs.register_stair_and_slab {"cottages_loam.png"}, S("Loam Stairs"), S("Loam Slab"), - default.node_sound_dirt_defaults) + cottages.sounds.dirt) if( minetest.registered_nodes["default:clay"]) then stairs.register_stair_and_slab("clay", "default:clay", @@ -58,7 +57,7 @@ if( minetest.get_modpath("stairs") and stairs and stairs.register_stair_and_slab {"cottages_clay.png"}, S("Clay Stairs"), S("Clay Slab"), - default.node_sound_dirt_defaults) + cottages.sounds.dirt) end end @@ -67,10 +66,10 @@ end -- right now, this block mostly serves as a placeholder minetest.register_node("cottages:straw_ground", { description = S("straw ground for animals"), - tiles = {"cottages_darkage_straw.png","cottages_loam.png","cottages_loam.png","cottages_loam.png","cottages_loam.png","cottages_loam.png"}, + tiles = {cottages.straw_texture,"cottages_loam.png","cottages_loam.png","cottages_loam.png","cottages_loam.png","cottages_loam.png"}, groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2}, groups = {crumbly=3}, - sounds = default.node_sound_dirt_defaults, + sounds = cottages.sounds.leaves, is_ground_content = false, }) @@ -179,12 +178,16 @@ minetest.register_node("cottages:wool_tent", { }) -- a fallback for cases in which there is no wool -minetest.register_node("cottages:wool", { +if( not( minetest.registered_nodes["wool:white"])) then + minetest.register_node("cottages:wool", { description = "Wool", tiles = {"cottages_wool.png"}, is_ground_content = false, groups = {snappy=2,choppy=2,oddly_breakable_by_hand=3,flammable=3,wool=1}, -}) + }) +else + minetest.register_alias("cottages:wool", "wool:white") +end --------------------------------------------------------------------------------------- diff --git a/cottages/nodes_mining.lua b/cottages/nodes_mining.lua index b33ec3d..2098afe 100644 --- a/cottages/nodes_mining.lua +++ b/cottages/nodes_mining.lua @@ -31,7 +31,7 @@ minetest.register_node("cottages:rope", { minetest.register_craft({ output = "cottages:rope", recipe = { - {"default:cotton","default:cotton","default:cotton"} + {"farming:cotton","farming:cotton","farming:cotton"} } }) @@ -54,7 +54,7 @@ minetest.register_node("cottages:ladder_with_rope_and_rail", { }, groups = {choppy=2,oddly_breakable_by_hand=3,rail=1,connect_to_raillike=1}, --connect_to_raillike=minetest.raillike_group("rail")}, legacy_wallmounted = true, - sounds = default.node_sound_wood_defaults, + sounds = cottages.sounds.wood, }) diff --git a/cottages/nodes_pitchfork.lua b/cottages/nodes_pitchfork.lua new file mode 100644 index 0000000..666393a --- /dev/null +++ b/cottages/nodes_pitchfork.lua @@ -0,0 +1,114 @@ + +local S = cottages.S + +-- fast tool for digging nodes with the group "hay"; +-- can also be placed as a node + +-- the straw node from default and similar nodes can be digged with the pitchfork as well +local add_hay_group = {"farming:straw", "dryplants:reed", "darkage:straw_bale"} +for i, v in ipairs(add_hay_group) do + if( minetest.registered_items[v]) then + new_groups = minetest.registered_items[v].groups + new_groups.hay = 3 + minetest.override_item(v, {groups = new_groups}) + end +end + +-- creates hay when digging dirt_with_grass (thanks to the override above); +-- useful for digging hay and straw +-- can be placed as a node +minetest.register_tool("cottages:pitchfork", { + description = S("pitchfork (dig dirt with grass to get hay, place with right-click)"), + groups = {}, + inventory_image = "cottages_pitchfork.png", + wield_image = "cottages_pitchfork.png^[transformFYR180", + wield_scale = {x=1.5,y=1.5,z=0.5}, + stack_max = 1, + liquids_pointable = false, + -- very useful for digging hay, straw and bales of those materials + tool_capabilities = { + full_punch_interval = 1.0, + max_drop_level=1, + groupcaps={ + fleshy={times={[2]=0.80, [3]=0.40}, maxwear=0.05, maxlevel=1, uses=40}, + snappy={times={[2]=0.80, [3]=0.40}, maxwear=0.05, maxlevel=1, uses=40}, + hay ={times={[2]=0.10, [3]=0.10}, maxwear=0.05, maxlevel=1, uses=40}, + }, + damage_groups = {fleshy=5}, -- slightly stronger than a stone sword + }, + sound = {breaks = "default_tool_breaks"}, + -- place the pitchfork somewhere + on_place = function(itemstack, placer, pointed_thing) + if( placer == nil or pointed_thing == nil or pointed_thing.type ~= "node") then + return nil + end + local pos = minetest.get_pointed_thing_position( pointed_thing, 1 ) + local node = minetest.get_node_or_nil( pos ) + if( node == nil or not(node.name) or node.name ~= "air") then + return nil + end + if minetest.is_protected(pos, placer:get_player_name()) then + return nil + end + minetest.rotate_and_place(ItemStack("cottages:pitchfork_placed"), placer, pointed_thing) + -- did the placing succeed? + local nnode = minetest.get_node(pos) + if( not(nnode) or not(nnode.name) or nnode.name ~= "cottages:pitchfork_placed") then + return nil + end + local meta = minetest.get_meta(pos) + meta:set_int( "wear", itemstack:get_wear()) + meta:set_string("infotext", S("pitchfork (for hay and straw)")) + -- the tool has been placed; consume it + return ItemStack("") + end, +}) + + +-- a ptichfork placed somewhere +minetest.register_node("cottages:pitchfork_placed", { + description = S("pitchfork (for hay and straw)"), + tiles = {"default_wood.png^[transformR90"}, --default_tree.png"}, + drawtype = "nodebox", + paramtype = "light", + paramtype2 = "facedir", + is_ground_content = false, + groups = {snappy = 2, dig_immediate = 3, falling_node = 1, attached_node = 1}, + sounds = cottages.sounds.wood, + node_box = { + type = "fixed", + fixed = { + -- handle (goes a bit into the ground) + { -(1/32), -(11/16), -(1/32), (1/32), 16/16, (1/32)}, + -- middle connection + { -(7/32), -(4/16), -(1/32), (7/32), -(2/16), (1/32)}, + -- thongs + { -(7/32), -(11/16), -(1/32), -(5/32), -(4/16), (1/32)}, + { (5/32), -(11/16), -(1/32), (7/32), -(4/16), (1/32)}, + }, + }, + selection_box = { + type = "fixed", + fixed = { -0.3, -0.5, -0.1, 0.3, 1.0, 0.1 } + }, + drop = "cottages:pitchfork", + -- perserve wear + preserve_metadata = function(pos, oldnode, oldmeta, drops) + if(oldmeta["wear"]) then + -- the first drop is the pitchfork + drops[1]:set_wear(oldmeta["wear"]) + end + end, +}) + +-- +-- craft recipes +-- +minetest.register_craft({ + output = 'cottages:pitchfork', + recipe = { + { 'default:stick','default:stick','default:stick' }, + { '','default:stick', '' }, + { '','default:stick','' }, + } +}) diff --git a/cottages/nodes_roof.lua b/cottages/nodes_roof.lua index 9503e86..240f94f 100644 --- a/cottages/nodes_roof.lua +++ b/cottages/nodes_roof.lua @@ -36,7 +36,8 @@ cottages.register_roof = function( name, tiles, basic_material, homedecor_altern }) -- a better roof than the normal stairs; this one is for usage directly on top of walls (it has the form of a stair) - minetest.register_node("cottages:roof_connector_"..name, { + if( name~="straw" or not(minetest.registered_nodes["stairs:stair_straw"]) or not(cottages.use_farming_straw_stairs)) then + minetest.register_node("cottages:roof_connector_"..name, { description = S("Roof connector "..name), drawtype = "nodebox", -- top, bottom, side1, side2, inner, outer @@ -60,9 +61,13 @@ cottages.register_roof = function( name, tiles, basic_material, homedecor_altern }, is_ground_content = false, }) + else + minetest.register_alias("cottages:roof_connector_straw", "stairs:stair_straw") + end -- this one is the slab version of the above roof - minetest.register_node("cottages:roof_flat_"..name, { + if( name~="straw" or not(minetest.registered_nodes["stairs:slab_straw"]) or not(cottages.use_farming_straw_stairs)) then + minetest.register_node("cottages:roof_flat_"..name, { description = S("Roof (flat) "..name), drawtype = "nodebox", -- top, bottom, side1, side2, inner, outer @@ -85,6 +90,9 @@ cottages.register_roof = function( name, tiles, basic_material, homedecor_altern }, is_ground_content = false, }) + else + minetest.register_alias("cottages:roof_flat_straw", "stairs:slab_straw") + end if( not( homedecor_alternative ) @@ -147,9 +155,9 @@ end -- of cottages.register_roof( name, tiles, basic_material ) -- add the diffrent roof types --------------------------------------------------------------------------------------- cottages.register_roof( 'straw', - {"cottages_darkage_straw.png","cottages_darkage_straw.png", - "cottages_darkage_straw.png","cottages_darkage_straw.png", - "cottages_darkage_straw.png","cottages_darkage_straw.png"}, + {cottages.straw_texture, cottages.straw_texture, + cottages.straw_texture, cottages.straw_texture, + cottages.straw_texture, cottages.straw_texture}, 'cottages:straw_mat', nil ); cottages.register_roof( 'reet', {"cottages_reet.png","cottages_reet.png", @@ -191,7 +199,7 @@ minetest.register_node("cottages:slate_vertical", { tiles = {"cottages_slate.png",cottages.texture_roof_sides,"cottages_slate.png","cottages_slate.png",cottages.texture_roof_sides,"cottages_slate.png"}, paramtype2 = "facedir", groups = {cracky=2, stone=1}, - sounds = default.node_sound_stone_defaults, + sounds = cottages.sounds.stone, is_ground_content = false, }) @@ -208,8 +216,8 @@ minetest.register_craft({ minetest.register_node("cottages:reet", { description = S("Reet for thatching"), tiles = {"cottages_reet.png"}, - groups = {snappy=3,choppy=3,oddly_breakable_by_hand=3,flammable=3}, - sounds = default.node_sound_wood_defaults, + groups = {hay = 3, snappy=3,choppy=3,oddly_breakable_by_hand=3,flammable=3}, + sounds = cottages.sounds.leaves, is_ground_content = false, }) diff --git a/cottages/nodes_straw.lua b/cottages/nodes_straw.lua index c19b869..d26f6b8 100644 --- a/cottages/nodes_straw.lua +++ b/cottages/nodes_straw.lua @@ -6,33 +6,21 @@ local S = cottages.S -local cottages_can_use = function( meta, player ) - if( not( player) or not( meta )) then - return false; - end - local pname = player:get_player_name(); - local owner = meta:get_string('owner' ); - if( not(owner) or owner=="" or owner==pname ) then - return true; - end - return false; -end - -- an even simpler from of bed - usually for animals -- it is a nodebox and not wallmounted because that makes it easier to replace beds with straw mats minetest.register_node("cottages:straw_mat", { description = S("layer of straw"), drawtype = 'nodebox', - tiles = { 'cottages_darkage_straw.png' }, -- done by VanessaE - wield_image = 'cottages_darkage_straw.png', - inventory_image = 'cottages_darkage_straw.png', + tiles = { cottages.straw_texture }, -- done by VanessaE + wield_image = cottages.straw_texture, + inventory_image = cottages.straw_texture, sunlight_propagates = true, paramtype = 'light', paramtype2 = "facedir", walkable = false, - groups = { snappy = 3 }, - sounds = default.node_sound_leaves_defaults, + groups = { hay = 3, snappy = 2, oddly_breakable_by_hand = 2, flammable=3 }, + sounds = cottages.sounds.leaves, node_box = { type = "fixed", fixed = { @@ -57,8 +45,8 @@ minetest.register_node("cottages:straw_bale", { description = S("straw bale"), tiles = {"cottages_darkage_straw_bale.png"}, paramtype = "light", - groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=3}, - sounds = default.node_sound_wood_defaults, + groups = { hay = 3, snappy = 2, oddly_breakable_by_hand = 2, flammable=3 }, + sounds = cottages.sounds.leaves, -- the bale is slightly smaller than a full node node_box = { type = "fixed", @@ -76,21 +64,26 @@ minetest.register_node("cottages:straw_bale", { }) -- just straw -minetest.register_node("cottages:straw", { +if( not(minetest.registered_nodes["farming:straw"])) then + minetest.register_node("cottages:straw", { drawtype = "normal", description = S("straw"), - tiles = {"cottages_darkage_straw.png"}, - groups = {snappy=3,choppy=3,oddly_breakable_by_hand=3,flammable=3}, - sounds = default.node_sound_wood_defaults, + tiles = {cottages.straw_texture}, + groups = { hay = 3, snappy = 2, oddly_breakable_by_hand = 2, flammable=3 }, + sounds = cottages.sounds.leaves, -- the bale is slightly smaller than a full node is_ground_content = false, -}) + }) +else + minetest.register_alias("cottages:straw", "farming:straw") +end local cottages_formspec_treshing_floor = "size[8,8]".. "image[1.5,0;1,1;"..cottages.texture_stick.."]".. "image[0,1;1,1;farming_wheat.png]".. + "button_exit[6.8,0.0;1.5,0.5;public;"..S("Public?").."]".. "list[current_name;harvest;1,1;2,1;]".. "list[current_name;straw;5,0;2,2;]".. "list[current_name;seeds;5,2;2,2;]".. @@ -109,7 +102,8 @@ minetest.register_node("cottages:threshing_floor", { tiles = {"cottages_junglewood.png^farming_wheat.png","cottages_junglewood.png","cottages_junglewood.png^"..cottages.texture_stick}, paramtype = "light", paramtype2 = "facedir", - groups = {cracky=2}, + -- can be digged with axe and pick + groups = {cracky=2, choppy=2}, is_ground_content = false, node_box = { type = "fixed", @@ -131,23 +125,29 @@ minetest.register_node("cottages:threshing_floor", { }, on_construct = function(pos) local meta = minetest.get_meta(pos); - meta:set_string("infotext", S("Threshing floor")); + meta:set_string("infotext", S("Public threshing floor")); local inv = meta:get_inventory(); inv:set_size("harvest", 2); inv:set_size("straw", 4); inv:set_size("seeds", 4); meta:set_string("formspec", cottages_formspec_treshing_floor ); + meta:set_string("public", "public") end, after_place_node = function(pos, placer) local meta = minetest.get_meta(pos); meta:set_string("owner", placer:get_player_name() or ""); - meta:set_string("infotext", S("Threshing floor (owned by %s)"):format(meta:get_string("owner") or "")); + meta:set_string("infotext", S("Private threshing floor (owned by %s)"):format(meta:get_string("owner") or "")); meta:set_string("formspec", cottages_formspec_treshing_floor.. "label[2.5,-0.5;"..S("Owner: %s"):format(meta:get_string("owner") or "").."]" ); + meta:set_string("public", "private") end, + on_receive_fields = function(pos, formname, fields, sender) + cottages.switch_public(pos, formname, fields, sender, 'threshing floor') + end, + can_dig = function(pos,player) local meta = minetest.get_meta(pos); @@ -167,7 +167,7 @@ minetest.register_node("cottages:threshing_floor", { allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) local meta = minetest.get_meta(pos) - if( not( cottages_can_use( meta, player ))) then + if( not( cottages.player_can_use( meta, player ))) then return 0 end return count; @@ -182,7 +182,7 @@ minetest.register_node("cottages:threshing_floor", { return 0; end - if( not( cottages_can_use( meta, player ))) then + if( not( cottages.player_can_use( meta, player ))) then return 0 end return stack:get_count() @@ -190,7 +190,7 @@ minetest.register_node("cottages:threshing_floor", { allow_metadata_inventory_take = function(pos, listname, index, stack, player) local meta = minetest.get_meta(pos) - if( not( cottages_can_use( meta, player ))) then + if( not( cottages.player_can_use( meta, player ))) then return 0 end return stack:get_count() @@ -243,7 +243,7 @@ minetest.register_node("cottages:threshing_floor", { end local overlay1 = "^farming_wheat.png"; - local overlay2 = "^cottages_darkage_straw.png"; + local overlay2 = "^"..cottages.straw_texture; local overlay3 = "^"..cottages.texture_wheat_seed; -- this can be enlarged by a multiplicator if desired @@ -348,6 +348,7 @@ minetest.register_node("cottages:threshing_floor", { local cottages_handmill_formspec = "size[8,8]".. "image[0,1;1,1;"..cottages.texture_wheat_seed.."]".. + "button_exit[6.0,0.0;1.5,0.5;public;"..S("Public?").."]".. "list[current_name;seeds;1,1;1,1;]".. "list[current_name;flour;5,1;2,2;]".. "label[0,0.5;"..S("Wheat seeds:").."]".. @@ -380,22 +381,28 @@ minetest.register_node("cottages:handmill", { }, on_construct = function(pos) local meta = minetest.get_meta(pos); - meta:set_string("infotext", S("Mill, powered by punching")); + meta:set_string("infotext", S("Public mill, powered by punching")); local inv = meta:get_inventory(); inv:set_size("seeds", 1); inv:set_size("flour", 4); meta:set_string("formspec", cottages_handmill_formspec ); + meta:set_string("public", "public") end, after_place_node = function(pos, placer) local meta = minetest.get_meta(pos); meta:set_string("owner", placer:get_player_name() or ""); - meta:set_string("infotext", S("Mill, powered by punching (owned by %s)"):format(meta:get_string("owner") or "")); + meta:set_string("infotext", S("Private mill, powered by punching (owned by %s)"):format(meta:get_string("owner") or "")); meta:set_string("formspec", cottages_handmill_formspec.. "label[2.5,-0.5;"..S("Owner: %s"):format(meta:get_string('owner') or "").."]" ); + meta:set_string("public", "private") end, + on_receive_fields = function(pos, formname, fields, sender) + cottages.switch_public(pos, formname, fields, sender, 'mill, powered by punching') + end, + can_dig = function(pos,player) local meta = minetest.get_meta(pos); @@ -414,7 +421,7 @@ minetest.register_node("cottages:handmill", { allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) local meta = minetest.get_meta(pos) - if( not( cottages_can_use( meta, player ))) then + if( not( cottages.player_can_use( meta, player ))) then return 0 end return count; @@ -428,7 +435,7 @@ minetest.register_node("cottages:handmill", { return 0; end - if( not( cottages_can_use( meta, player ))) then + if( not( cottages.player_can_use( meta, player ))) then return 0 end return stack:get_count() @@ -436,7 +443,7 @@ minetest.register_node("cottages:handmill", { allow_metadata_inventory_take = function(pos, listname, index, stack, player) local meta = minetest.get_meta(pos) - if( not( cottages_can_use( meta, player ))) then + if( not( cottages.player_can_use( meta, player ))) then return 0 end return stack:get_count() diff --git a/cottages/nodes_water.lua b/cottages/nodes_water.lua new file mode 100644 index 0000000..1cfe77d --- /dev/null +++ b/cottages/nodes_water.lua @@ -0,0 +1,312 @@ + +-- TODO: play sound while working +-- TODO: play sound when emptying a bucket +-- TODO: store correct bucket texture when loading the world anew +-- TODO: show particles when running? distinguish between running/idle state? (with punch?) + +-- well for getting water +-- * has some storage space for buckets (filled with water, river water or empty) +-- * only the owner can use the bucket store and the well +-- * the bucket will be added as an entity and slowly rotate; +-- once filled, the texture of the bucket is changed +-- * full (water or river water) buckets can be emptied +-- * by default public; but can also be made private + + +-- how many seconds does it take to fill a bucket? +cottages.water_fill_time = 10 + + +-- code taken from the itemframes mod in homedecor +-- (the relevant functions are sadly private there and thus cannot be reused) +local tmp = {} +minetest.register_entity("cottages:bucket_entity",{ + hp_max = 1, + visual="wielditem", + visual_size={x = 0.33, y = 0.33}, + collisionbox = {0, 0, 0, 0, 0, 0}, + physical = false, + textures = {"air"}, + on_activate = function(self, staticdata) + if tmp.nodename ~= nil and tmp.texture ~= nil then + self.nodename = tmp.nodename + tmp.nodename = nil + self.texture = tmp.texture + tmp.texture = nil + else + if staticdata ~= nil and staticdata ~= "" then + local data = staticdata:split(';') + if data and data[1] and data[2] then + self.nodename = data[1] + self.texture = data[2] + end + end + end + if self.texture ~= nil then + self.object:set_properties({textures = {self.texture}}) + end + self.object:set_properties({automatic_rotate = 1}) + if self.texture ~= nil and self.nodename ~= nil then + local entity_pos = vector.round(self.object:get_pos()) + local objs = minetest.get_objects_inside_radius(entity_pos, 0.5) + for _, obj in ipairs(objs) do + if obj ~= self.object and + obj:get_luaentity() and + obj:get_luaentity().name == "cottages:bucket_entity" and + obj:get_luaentity().nodename == self.nodename and + obj:get_properties() and + obj:get_properties().textures and + obj:get_properties().textures[1] == self.texture then + minetest.log("action","[cottages] Removing extra " .. + self.texture .. " found in " .. self.nodename .. " at " .. + minetest.pos_to_string(entity_pos)) + self.object:remove() + break + end + end + end + end, + get_staticdata = function(self) + if self.nodename ~= nil and self.texture ~= nil then + return self.nodename .. ';' .. self.texture + end + return "" + end, +}) + +cottages.water_gen_fill_bucket = function(pos) + if( not(pos)) then + return + end + local meta = minetest.get_meta(pos) + local bucket = meta:get_string("bucket") + -- nothing to do + if( not(bucket) or bucket ~= "bucket:bucket_empty") then + return + end + -- abort if the water has not been running long enough + -- (the player may have removed a bucket before it was full) + start = meta:get_string("fillstarttime") + if( (minetest.get_us_time()/1000000) - tonumber(start) < cottages.water_fill_time -2) then + return + end + + -- the bucket has been filled + meta:set_string("bucket", "bucket:bucket_river_water") + + -- change the texture of the bucket to that of one filled with river water + local objs = nil + objs = minetest.get_objects_inside_radius(pos, .5) + if objs then + for _, obj in ipairs(objs) do + if obj and obj:get_luaentity() and obj:get_luaentity().name == "cottages:bucket_entity" then + obj:set_properties( { textures = { "bucket:bucket_river_water" }}) + obj:get_luaentity().nodename = "bucket:bucket_river_water" + obj:get_luaentity().texture = "bucket:bucket_river_water" + end + end + end +end + + +minetest.register_node("cottages:water_gen", { + description = "Tree Trunk Well", + tiles = {"default_tree_top.png", "default_tree.png^[transformR90", "default_tree.png^[transformR90"}, + drawtype = "nodebox", + paramtype = "light", + paramtype2 = "facedir", + is_ground_content = false, + groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2}, + sounds = cottages.sounds.wood, + node_box = { + type = "fixed", + fixed = { + -- floor of water bassin + {-0.5, -0.5+(3/16), -0.5, 0.5, -0.5+(4/16), 0.5}, + -- walls + {-0.5, -0.5+(3/16), -0.5, 0.5, (4/16), -0.5+(2/16)}, + {-0.5, -0.5+(3/16), -0.5, -0.5+(2/16), (4/16), 0.5}, + { 0.5, -0.5+(3/16), 0.5, 0.5-(2/16), (4/16), -0.5}, + { 0.5, -0.5+(3/16), 0.5, -0.5+(2/16), (4/16), 0.5-(2/16)}, + -- feet + {-0.5+(3/16), -0.5, -0.5+(3/16), -0.5+(6/16), -0.5+(3/16), 0.5-(3/16)}, + { 0.5-(3/16), -0.5, -0.5+(3/16), 0.5-(6/16), -0.5+(3/16), 0.5-(3/16)}, + -- real pump + { 0.5-(4/16), -0.5, -(2/16), 0.5, 0.5+(4/16), (2/16)}, + -- water pipe inside wooden stem + { 0.5-(8/16), 0.5+(1/16), -(1/16), 0.5, 0.5+(3/16), (1/16)}, + -- where the water comes out + { 0.5-(15/32), 0.5, -(1/32), 0.5-(12/32), 0.5+(1/16), (1/32)}, + }, + }, + selection_box = { + type = "fixed", + fixed = { -0.5, -0.5, -0.5, 0.5, 0.5+(4/16), 0.5 } + }, + on_construct = function(pos) + local meta = minetest.get_meta(pos) + local spos = pos.x .. "," .. pos.y .. "," .. pos.z + meta:set_string("formspec", + "size[8,9]" .. + "label[3.0,0.0;Tree trunk well]".. + "label[1.5,0.7;Punch the well while wielding an empty bucket.]".. + "label[1.5,1.0;Your bucket will slowly be filled with river water.]".. + "label[1.5,1.3;Punch again to get the bucket back when it is full.]".. + "label[1.0,2.9;Internal bucket storage (passive storage only):]".. + "item_image[0.2,0.7;1.0,1.0;bucket:bucket_empty]".. + "item_image[0.2,1.7;1.0,1.0;bucket:bucket_river_water]".. + "label[1.5,1.9;Punch well with full water bucket in order to empty bucket.]".. + "button_exit[6.0,0.0;2,0.5;public;"..S("Public?").."]".. + "list[nodemeta:" .. spos .. ";main;1,3.3;8,1;]" .. + "list[current_player;main;0,4.85;8,1;]" .. + "list[current_player;main;0,6.08;8,3;8]" .. + "listring[nodemeta:" .. spos .. ";main]" .. + "listring[current_player;main]") + local inv = meta:get_inventory() + inv:set_size('main', 6) + meta:set_string("infotext", S("Public tree trunk well")) -- (punch with empty bucket to fill bucket)") + end, + after_place_node = function(pos, placer) + local meta = minetest.get_meta(pos) + meta:set_string("owner", placer:get_player_name() or "") + meta:set_string("infotext", S("Public tree trunk well (owned by %s)"):format(meta:get_string("owner"))) + -- no bucket loaded + meta:set_string("bucket", "") + meta:set_string("public", "public") + end, + can_dig = function(pos,player) + local meta = minetest.get_meta(pos); + local inv = meta:get_inventory() + return inv:is_empty("main") and + default.can_interact_with_node(player, pos) + end, + -- no inventory move allowed + allow_metadata_inventory_move = function(pos, from_list, from_index, + to_list, to_index, count, player) + return 0 + end, + allow_metadata_inventory_put = function(pos, listname, index, stack, player) + local meta = minetest.get_meta(pos) + if not(stack) or not cottages.player_can_use(meta, player) then + return 0 + end + local inv = meta:get_inventory() + -- only for buckets + local sname = stack:get_name() + if( sname ~= "bucket:bucket_empty" + and sname ~= "bucket:bucket_water" + and sname ~= "bucket:bucket_river_water") then + return 0 + end + return stack:get_count() + end, + allow_metadata_inventory_take = function(pos, listname, index, stack, player) + if not(cottages.player_can_use(meta:get_string(pos), player)) then + return 0 + end + return stack:get_count() + end, + on_blast = function() end, + on_receive_fields = function(pos, formname, fields, sender) + cottages.switch_public(pos, formname, fields, sender, 'tree trunk well') + end, + -- punch to place and retrieve bucket + on_punch = function(pos, node, puncher) + if( not( pos ) or not( node ) or not( puncher )) then + return + end + -- only the owner can use the well + local name = puncher:get_player_name() + local meta = minetest.get_meta(pos) + local owner = meta:get_string("owner") + local public = meta:get_string("public") + if( name ~= owner and public~="public") then + minetest.chat_send_player( name, S("This tree trunk well is owned by %s. You can't use it."):format(name)) + return + end + + -- we will either add or take from the players inventory + local pinv = puncher:get_inventory() + + -- is the well working on something? (either empty or full bucket) + local bucket = meta:get_string("bucket") + -- there is a bucket loaded - either empty or full + if( bucket and bucket~="") then + if( not(pinv:room_for_item("main", bucket))) then + minetest.chat_send_player( puncher:get_player_name(), + S("Sorry. You have no room for the bucket. Please free some ".. + "space in your inventory first!")) + return + end + end + + -- remove the old entity (either a bucket will be placed now or a bucket taken) + local objs = nil + objs = minetest.get_objects_inside_radius(pos, .5) + if objs then + for _, obj in ipairs(objs) do + if obj and obj:get_luaentity() and obj:get_luaentity().name == "cottages:bucket_entity" then + obj:remove() + end + end + end + + -- the player gets the bucket (either empty or full) into his inventory + if( bucket and bucket ~= "") then + pinv:add_item("main", bucket ) + meta:set_string("bucket", "") + -- we are done + return + end + + -- punching with empty bucket will put that bucket into the well (as an entity) + -- and will slowly fill it + local wielded = puncher:get_wielded_item() + if( wielded + and wielded:get_name() + and wielded:get_name() == "bucket:bucket_empty") then + -- remove the bucket from the players inventory + pinv:remove_item( "main", "bucket:bucket_empty") + -- remember that we got a bucket loaded + meta:set_string("bucket", "bucket:bucket_empty") + -- create the entity + tmp.nodename = "bucket:bucket_empty" + -- TODO: add a special texture with a handle for the bucket here + tmp.texture = "bucket:bucket_empty" + local e = minetest.add_entity({x=pos.x,y=pos.y+(4/16),z=pos.z},"cottages:bucket_entity") + -- fill the bucket with water + minetest.after(cottages.water_fill_time, cottages.water_gen_fill_bucket, pos) + -- the bucket will only be filled if the water ran long enough + meta:set_string("fillstarttime", tostring(minetest.get_us_time()/1000000)) + return; + end + -- buckets can also be emptied here + if( wielded + and wielded:get_name() + and (wielded:get_name() == "bucket:bucket_water" + or wielded:get_name() == "bucket:bucket_river_water") + and (pinv:room_for_item("main", "bucket:bucket_empty"))) then + -- remove the full bucket from the players inventory + pinv:remove_item( "main", wielded:get_name()) + -- add empty bucket + pinv:add_item("main", "bucket:bucket_empty") + -- TODO: play diffrent sound when pouring a bucket + return; + end + + -- else check if there is a bucket that can be retrieved + meta:set_string("bucket","") + end, +}) + + +-- a well (will fill water buckets) crafted from wooden materials +minetest.register_craft({ + output = 'cottages:water_gen', + recipe = { + {'default:stick', '', ''}, + {'default:tree', 'bucket:bucket_empty', 'bucket:bucket_empty'}, + {'default:tree', 'default:tree', 'default:tree'}, + } +}) + diff --git a/cottages/textures/cottages_pitchfork.png b/cottages/textures/cottages_pitchfork.png new file mode 100644 index 0000000..7253a7a Binary files /dev/null and b/cottages/textures/cottages_pitchfork.png differ -- cgit v1.2.3