mirror of
https://github.com/Sokomine/cottages.git
synced 2024-12-27 11:10:36 +01:00
added pitchfork and hay
This commit is contained in:
parent
6c0a48c7ad
commit
bd257ee16e
3
init.lua
3
init.lua
@ -63,7 +63,10 @@ dofile(minetest.get_modpath("cottages").."/functions.lua");
|
||||
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");
|
||||
|
@ -148,3 +148,10 @@ This tree trunk well is owned by %s. You can't use it. = Dieser Baumstammbrunnen
|
||||
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
|
||||
|
@ -146,3 +146,10 @@ 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 =
|
||||
|
133
nodes_hay.lua
Normal file
133
nodes_hay.lua
Normal file
@ -0,0 +1,133 @@
|
||||
-- contains hay_mat, hay and hay bale
|
||||
-- (gives the pitchfork some work)
|
||||
|
||||
-- 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_darkage_straw.png^[multiply:#88BB88"},
|
||||
groups = {hay=3, snappy=2, oddly_breakable_by_hand=2, flammable=3},
|
||||
sounds = default.node_sound_wood_defaults,
|
||||
-- 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_darkage_straw.png^[multiply:#88BB88"},
|
||||
groups = {hay=3, snappy=2, oddly_breakable_by_hand=2, flammable=3},
|
||||
sounds = default.node_sound_wood_defaults,
|
||||
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 = default.node_sound_wood_defaults,
|
||||
-- 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"}},
|
||||
})
|
112
nodes_pitchfork.lua
Normal file
112
nodes_pitchfork.lua
Normal file
@ -0,0 +1,112 @@
|
||||
|
||||
-- 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 = "default_wood.png", -- TODO
|
||||
wield_image = "",
|
||||
wield_scale = {x=1,y=1,z=1},
|
||||
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 = default.node_sound_wood_defaults(),
|
||||
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','' },
|
||||
}
|
||||
})
|
@ -19,7 +19,7 @@ minetest.register_node("cottages:straw_mat", {
|
||||
paramtype = 'light',
|
||||
paramtype2 = "facedir",
|
||||
walkable = false,
|
||||
groups = { snappy = 3 },
|
||||
groups = { hay = 3, snappy = 2, oddly_breakable_by_hand = 2, flammable=3 },
|
||||
sounds = default.node_sound_leaves_defaults,
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
@ -45,7 +45,7 @@ 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},
|
||||
groups = { hay = 3, snappy = 2, oddly_breakable_by_hand = 2, flammable=3 },
|
||||
sounds = default.node_sound_wood_defaults,
|
||||
-- the bale is slightly smaller than a full node
|
||||
node_box = {
|
||||
@ -68,7 +68,7 @@ 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},
|
||||
groups = { hay = 3, snappy = 2, oddly_breakable_by_hand = 2, flammable=3 },
|
||||
sounds = default.node_sound_wood_defaults,
|
||||
-- the bale is slightly smaller than a full node
|
||||
is_ground_content = false,
|
||||
|
Loading…
Reference in New Issue
Block a user