summaryrefslogtreecommitdiff
path: root/cottages/nodes_straw.lua
diff options
context:
space:
mode:
Diffstat (limited to 'cottages/nodes_straw.lua')
-rw-r--r--cottages/nodes_straw.lua79
1 files changed, 43 insertions, 36 deletions
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()