mirror of
https://github.com/Sokomine/cottages.git
synced 2025-02-21 13:40:27 +01:00
handmill, treshing place and anvil can now be used if they have no owner; the anvil can be used by all
This commit is contained in:
parent
af0787a420
commit
5ef4dc9794
@ -54,6 +54,11 @@ end
|
||||
cottages.texture_chest = {"default_chest_top.png", "default_chest_top.png", "default_chest_side.png",
|
||||
"default_chest_side.png", "default_chest_side.png", "default_chest_front.png"};
|
||||
|
||||
-- the treshing floor produces wheat seeds
|
||||
cottages.craftitem_seed_wheat = "farming:seed_wheat";
|
||||
cottages.texture_wheat_seed = "farming_wheat_seed.png";
|
||||
cottages.texture_stick = "default_stick.png";
|
||||
|
||||
-- texture for roofs where the tree bark is the main roof texture
|
||||
cottages.textures_roof_wood = "default_tree.png";
|
||||
if( not( minetest.registered_nodes["default:tree"])) then
|
||||
@ -78,6 +83,10 @@ if( not( minetest.registered_nodes["default:tree"])) then
|
||||
cottages.texture_chest = { "spruce_chest_top.png", "spruce_chest_top.png", "spruce_chest_side.png",
|
||||
"spruce_chest_side.png", "spruce_chest_side.png", "spruce_chest_front.png"};
|
||||
|
||||
-- wheat is called spelt in RealTest
|
||||
cottages.craftitem_seed_wheat = 'farming:seed_spelt';
|
||||
cottages.texture_wheat_seed = 'farming_spelt_seed.png';
|
||||
cottages.texture_stick = 'trees_maple_stick.png';
|
||||
else
|
||||
-- does not look so well in this case as it's no bark; but what else shall we do?
|
||||
cottages.textures_roof_wood = "cottages_minimal_wood.png";
|
||||
|
@ -27,6 +27,26 @@ minetest.register_tool("cottages:hammer", {
|
||||
})
|
||||
|
||||
|
||||
local cottages_anvil_formspec =
|
||||
"size[8,8]"..
|
||||
"image[7,3;1,1;glooptest_tool_steelhammer.png]"..
|
||||
-- "list[current_name;sample;0,0.5;1,1;]"..
|
||||
"list[current_name;input;2.5,1.5;1,1;]"..
|
||||
-- "list[current_name;material;5,0;3,3;]"..
|
||||
"list[current_name;hammer;5,3;1,1;]"..
|
||||
-- "label[0.0,0.0;Sample:]"..
|
||||
-- "label[0.0,1.0;(Receipe)]"..
|
||||
"label[2.5,1.0;"..S("Workpiece:").."]"..
|
||||
-- "label[6.0,-0.5;Materials:]"..
|
||||
"label[6.0,2.7;"..S("Optional").."]"..
|
||||
"label[6.0,3.0;"..S("storage for").."]"..
|
||||
"label[6.0,3.3;"..S("your hammer").."]"..
|
||||
|
||||
"label[0,-0.5;"..S("Anvil").."]"..
|
||||
"label[0,3.0;"..S("Punch anvil with hammer to").."]"..
|
||||
"label[0,3.3;"..S("repair tool in workpiece-slot.").."]"..
|
||||
"list[current_player;main;0,4;8,4;]";
|
||||
|
||||
|
||||
minetest.register_node("cottages:anvil", {
|
||||
drawtype = "nodebox",
|
||||
@ -63,6 +83,7 @@ minetest.register_node("cottages:anvil", {
|
||||
-- inv:set_size("material", 9);
|
||||
-- inv:set_size("sample", 1);
|
||||
inv:set_size("hammer", 1);
|
||||
meta:set_string("formspec", cottages_anvil_formspec );
|
||||
end,
|
||||
|
||||
after_place_node = function(pos, placer)
|
||||
@ -70,25 +91,8 @@ minetest.register_node("cottages:anvil", {
|
||||
meta:set_string("owner", placer:get_player_name() or "");
|
||||
meta:set_string("infotext", S("Anvil (owned by %s)"):format((meta:get_string("owner") or "")));
|
||||
meta:set_string("formspec",
|
||||
"size[8,8]"..
|
||||
"image[7,3;1,1;glooptest_tool_steelhammer.png]"..
|
||||
-- "list[current_name;sample;0,0.5;1,1;]"..
|
||||
"list[current_name;input;2.5,1.5;1,1;]"..
|
||||
-- "list[current_name;material;5,0;3,3;]"..
|
||||
"list[current_name;hammer;5,3;1,1;]"..
|
||||
-- "label[0.0,0.0;Sample:]"..
|
||||
-- "label[0.0,1.0;(Receipe)]"..
|
||||
"label[2.5,1.0;"..S("Workpiece:").."]"..
|
||||
-- "label[6.0,-0.5;Materials:]"..
|
||||
"label[6.0,2.7;"..S("Optional").."]"..
|
||||
"label[6.0,3.0;"..S("storage for").."]"..
|
||||
"label[6.0,3.3;"..S("your hammer").."]"..
|
||||
|
||||
"label[0,-0.5;"..S("Anvil").."]"..
|
||||
"label[2.5,-0.5;"..S("Owner: %s"):format(meta:get_string('owner') or "").."]"..
|
||||
"label[0,3.0;"..S("Punch anvil with hammer to").."]"..
|
||||
"label[0,3.3;"..S("repair tool in workpiece-slot.").."]"..
|
||||
"list[current_player;main;0,4;8,4;]");
|
||||
cottages_anvil_formspec,
|
||||
"label[2.5,-0.5;"..S("Owner: %s"):format(meta:get_string('owner') or "").."]");
|
||||
end,
|
||||
|
||||
can_dig = function(pos,player)
|
||||
@ -111,7 +115,7 @@ minetest.register_node("cottages:anvil", {
|
||||
|
||||
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if( player and player:get_player_name() ~= meta:get_string('owner' )) then
|
||||
if( player and player:get_player_name() ~= meta:get_string('owner' ) and from_list~="input") then
|
||||
return 0
|
||||
end
|
||||
return count;
|
||||
@ -119,7 +123,7 @@ minetest.register_node("cottages:anvil", {
|
||||
|
||||
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if( player and player:get_player_name() ~= meta:get_string('owner' )) then
|
||||
if( player and player:get_player_name() ~= meta:get_string('owner' ) and listname~="input") then
|
||||
return 0;
|
||||
end
|
||||
if( listname=='hammer' and stack and stack:get_name() ~= 'cottages:hammer') then
|
||||
@ -139,7 +143,7 @@ minetest.register_node("cottages:anvil", {
|
||||
|
||||
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if( player and player:get_player_name() ~= meta:get_string('owner' )) then
|
||||
if( player and player:get_player_name() ~= meta:get_string('owner' ) and listname~="input") then
|
||||
return 0
|
||||
end
|
||||
return stack:get_count()
|
||||
@ -167,6 +171,10 @@ minetest.register_node("cottages:anvil", {
|
||||
or input:is_empty()
|
||||
or input:get_name() == "technic:water_can"
|
||||
or input:get_name() == "technic:lava_can" ) then
|
||||
|
||||
meta:set_string("formspec",
|
||||
cottages_anvil_formspec,
|
||||
"label[2.5,-0.5;"..S("Owner: %s"):format(meta:get_string('owner') or "").."]");
|
||||
return;
|
||||
end
|
||||
|
||||
@ -243,10 +251,10 @@ minetest.register_node("cottages:anvil", {
|
||||
puncher:set_wielded_item( wielded );
|
||||
|
||||
-- do not spam too much
|
||||
if( math.random( 1,5 )==1 ) then
|
||||
minetest.chat_send_player( puncher:get_player_name(),
|
||||
S('Your workpiece improves.'));
|
||||
end
|
||||
-- if( math.random( 1,5 )==1 ) then
|
||||
-- minetest.chat_send_player( puncher:get_player_name(),
|
||||
-- S('Your workpiece improves.'));
|
||||
-- end
|
||||
end,
|
||||
is_ground_content = false,
|
||||
})
|
||||
|
110
nodes_straw.lua
110
nodes_straw.lua
@ -6,6 +6,19 @@
|
||||
|
||||
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", {
|
||||
@ -71,11 +84,26 @@ minetest.register_node("cottages:straw", {
|
||||
})
|
||||
|
||||
|
||||
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]"..
|
||||
"list[current_name;harvest;1,1;2,1;]"..
|
||||
"list[current_name;straw;5,0;2,2;]"..
|
||||
"list[current_name;seeds;5,2;2,2;]"..
|
||||
"label[1,0.5;"..S("Harvested wheat:").."]"..
|
||||
"label[4,0.0;"..S("Straw:").."]"..
|
||||
"label[4,2.0;"..S("Seeds:").."]"..
|
||||
"label[0,-0.5;"..S("Threshing floor").."]"..
|
||||
"label[0,2.5;"..S("Punch threshing floor with a stick").."]"..
|
||||
"label[0,3.0;"..S("to get straw and seeds from wheat.").."]"..
|
||||
"list[current_player;main;0,4;8,4;]";
|
||||
|
||||
minetest.register_node("cottages:threshing_floor", {
|
||||
drawtype = "nodebox",
|
||||
description = S("threshing floor"),
|
||||
-- TODO: stone also looks pretty well for this
|
||||
tiles = {"cottages_junglewood.png^farming_wheat.png","cottages_junglewood.png","cottages_junglewood.png^default_stick.png"},
|
||||
tiles = {"cottages_junglewood.png^farming_wheat.png","cottages_junglewood.png","cottages_junglewood.png^"..cottages.texture_stick},
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
groups = {cracky=2},
|
||||
@ -99,34 +127,22 @@ minetest.register_node("cottages:threshing_floor", {
|
||||
}
|
||||
},
|
||||
on_construct = function(pos)
|
||||
|
||||
local meta = minetest.get_meta(pos);
|
||||
meta:set_string("infotext", S("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 );
|
||||
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("formspec",
|
||||
"size[8,8]"..
|
||||
"image[1.5,0;1,1;default_stick.png]"..
|
||||
"image[0,1;1,1;farming_wheat.png]"..
|
||||
"list[current_name;harvest;1,1;2,1;]"..
|
||||
"list[current_name;straw;5,0;2,2;]"..
|
||||
"list[current_name;seeds;5,2;2,2;]"..
|
||||
"label[1,0.5;"..S("Harvested wheat:").."]"..
|
||||
"label[4,0.0;"..S("Straw:").."]"..
|
||||
"label[4,2.0;"..S("Seeds:").."]"..
|
||||
"label[0,-0.5;"..S("Threshing floor").."]"..
|
||||
"label[2.5,-0.5;"..S("Owner: %s"):format(meta:get_string("owner") or "").."]"..
|
||||
"label[0,2.5;"..S("Punch threshing floor with a stick").."]"..
|
||||
"label[0,3.0;"..S("to get straw and seeds from wheat.").."]"..
|
||||
"list[current_player;main;0,4;8,4;]");
|
||||
meta:set_string("formspec",
|
||||
cottages_formspec_treshing_floor..
|
||||
"label[2.5,-0.5;"..S("Owner: %s"):format(meta:get_string("owner") or "").."]" );
|
||||
end,
|
||||
|
||||
can_dig = function(pos,player)
|
||||
@ -148,7 +164,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( player and player:get_player_name() ~= meta:get_string('owner' )) then
|
||||
if( not( cottages_can_use( meta, player ))) then
|
||||
return 0
|
||||
end
|
||||
return count;
|
||||
@ -163,7 +179,7 @@ minetest.register_node("cottages:threshing_floor", {
|
||||
return 0;
|
||||
end
|
||||
|
||||
if( player and player:get_player_name() ~= meta:get_string('owner' )) then
|
||||
if( not( cottages_can_use( meta, player ))) then
|
||||
return 0
|
||||
end
|
||||
return stack:get_count()
|
||||
@ -171,7 +187,7 @@ minetest.register_node("cottages:threshing_floor", {
|
||||
|
||||
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if( player and player:get_player_name() ~= meta:get_string('owner' )) then
|
||||
if( not( cottages_can_use( meta, player ))) then
|
||||
return 0
|
||||
end
|
||||
return stack:get_count()
|
||||
@ -206,6 +222,10 @@ minetest.register_node("cottages:threshing_floor", {
|
||||
or( not( stack2:is_empty()) and stack2:get_name() ~= 'farming:wheat')) then
|
||||
|
||||
-- minetest.chat_send_player( name, 'One of the input slots contains something else than wheat, or there is no wheat at all.');
|
||||
-- update the formspec
|
||||
meta:set_string("formspec",
|
||||
cottages_formspec_treshing_floor..
|
||||
"label[2.5,-0.5;"..S("Owner: %s"):format(meta:get_string("owner") or "").."]" );
|
||||
return;
|
||||
end
|
||||
|
||||
@ -221,18 +241,18 @@ minetest.register_node("cottages:threshing_floor", {
|
||||
|
||||
local overlay1 = "^farming_wheat.png";
|
||||
local overlay2 = "^cottages_darkage_straw.png";
|
||||
local overlay3 = "^farming_wheat_seed.png";
|
||||
local overlay3 = "^"..cottages.texture_wheat_seed;
|
||||
|
||||
-- this can be enlarged by a multiplicator if desired
|
||||
local anz_straw = anz_wheat;
|
||||
local anz_seeds = anz_wheat;
|
||||
|
||||
if( inv:room_for_item('straw','cottages:straw_mat '..tostring( anz_straw ))
|
||||
and inv:room_for_item('seeds','farming:seed_wheat '..tostring( anz_seeds ))) then
|
||||
and inv:room_for_item('seeds',cottages.craftitem_seed_wheat..' '..tostring( anz_seeds ))) then
|
||||
|
||||
-- the player gets two kind of output
|
||||
inv:add_item("straw",'cottages:straw_mat '..tostring( anz_straw ));
|
||||
inv:add_item("seeds",'farming:seed_wheat '..tostring( anz_seeds ));
|
||||
inv:add_item("seeds",cottages.craftitem_seed_wheat..' '..tostring( anz_seeds ));
|
||||
-- consume the wheat
|
||||
inv:remove_item("harvest", 'farming:wheat '..tostring( anz_wheat ));
|
||||
|
||||
@ -323,6 +343,16 @@ minetest.register_node("cottages:threshing_floor", {
|
||||
})
|
||||
|
||||
|
||||
local cottages_handmill_formspec = "size[8,8]"..
|
||||
"image[0,1;1,1;"..cottages.texture_wheat_seed.."]"..
|
||||
"list[current_name;seeds;1,1;1,1;]"..
|
||||
"list[current_name;flour;5,1;2,2;]"..
|
||||
"label[0,0.5;"..S("Wheat seeds:").."]"..
|
||||
"label[4,0.5;"..S("Flour:").."]"..
|
||||
"label[0,-0.3;"..S("Mill").."]"..
|
||||
"label[0,2.5;"..S("Punch this hand-driven mill").."]"..
|
||||
"label[0,3.0;"..S("to convert wheat seeds into flour.").."]"..
|
||||
"list[current_player;main;0,4;8,4;]";
|
||||
|
||||
minetest.register_node("cottages:handmill", {
|
||||
description = S("mill, powered by punching"),
|
||||
@ -351,24 +381,16 @@ minetest.register_node("cottages:handmill", {
|
||||
local inv = meta:get_inventory();
|
||||
inv:set_size("seeds", 1);
|
||||
inv:set_size("flour", 4);
|
||||
meta:set_string("formspec", cottages_handmill_formspec );
|
||||
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("formspec",
|
||||
"size[8,8]"..
|
||||
"image[0,1;1,1;farming_wheat_seed.png]"..
|
||||
"list[current_name;seeds;1,1;1,1;]"..
|
||||
"list[current_name;flour;5,1;2,2;]"..
|
||||
"label[0,0.5;"..S("Wheat seeds:").."]"..
|
||||
"label[4,0.5;"..S("Flour:").."]"..
|
||||
"label[0,-0.5;"..S("Mill").."]"..
|
||||
"label[2.5,-0.5;"..S("Owner: %s"):format(meta:get_string('owner') or "").."]"..
|
||||
"label[0,2.5;"..S("Punch this hand-driven mill").."]"..
|
||||
"label[0,3.0;"..S("to convert wheat seeds into flour.").."]"..
|
||||
"list[current_player;main;0,4;8,4;]");
|
||||
meta:set_string("formspec",
|
||||
cottages_handmill_formspec..
|
||||
"label[2.5,-0.5;"..S("Owner: %s"):format(meta:get_string('owner') or "").."]" );
|
||||
end,
|
||||
|
||||
can_dig = function(pos,player)
|
||||
@ -389,7 +411,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( player and player:get_player_name() ~= meta:get_string('owner' )) then
|
||||
if( not( cottages_can_use( meta, player ))) then
|
||||
return 0
|
||||
end
|
||||
return count;
|
||||
@ -399,11 +421,11 @@ minetest.register_node("cottages:handmill", {
|
||||
local meta = minetest.get_meta(pos)
|
||||
-- only accept input the threshing floor can use/process
|
||||
if( listname=='flour'
|
||||
or (listname=='seeds' and stack and stack:get_name() ~= 'farming:seed_wheat' )) then
|
||||
or (listname=='seeds' and stack and stack:get_name() ~= cottages.craftitem_seed_wheat)) then
|
||||
return 0;
|
||||
end
|
||||
|
||||
if( player and player:get_player_name() ~= meta:get_string('owner' )) then
|
||||
if( not( cottages_can_use( meta, player ))) then
|
||||
return 0
|
||||
end
|
||||
return stack:get_count()
|
||||
@ -411,7 +433,7 @@ minetest.register_node("cottages:handmill", {
|
||||
|
||||
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if( player and player:get_player_name() ~= meta:get_string('owner' )) then
|
||||
if( not( cottages_can_use( meta, player ))) then
|
||||
return 0
|
||||
end
|
||||
return stack:get_count()
|
||||
@ -432,8 +454,12 @@ minetest.register_node("cottages:handmill", {
|
||||
local stack1 = inv:get_stack( 'seeds', 1);
|
||||
|
||||
if( ( stack1:is_empty())
|
||||
or( not( stack1:is_empty()) and stack1:get_name() ~= 'farming:seed_wheat')) then
|
||||
or( not( stack1:is_empty()) and stack1:get_name() ~= cottages.craftitem_seed_wheat)) then
|
||||
|
||||
-- update the formspec
|
||||
meta:set_string("formspec",
|
||||
cottages_handmill_formspec..
|
||||
"label[2.5,-0.5;"..S("Owner: %s"):format(meta:get_string('owner') or "").."]" );
|
||||
return;
|
||||
end
|
||||
|
||||
@ -451,7 +477,7 @@ minetest.register_node("cottages:handmill", {
|
||||
if( inv:room_for_item('flour','farming:flour '..tostring( anz ))) then
|
||||
|
||||
inv:add_item("flour",'farming:flour '..tostring( anz ));
|
||||
inv:remove_item("seeds", 'farming:seed_wheat '..tostring( anz ));
|
||||
inv:remove_item("seeds", cottages.craftitem_seed_wheat..' '..tostring( anz ));
|
||||
|
||||
local anz_left = found - anz;
|
||||
if( anz_left > 0 ) then
|
||||
@ -486,7 +512,7 @@ minetest.register_craft({
|
||||
{cottages.craftitem_stone,'',''},
|
||||
{"farming:wheat", "farming:wheat", "farming:wheat", },
|
||||
},
|
||||
replacements = {{ cottages.craftitem_stone, "farming:seed_wheat 3" }},
|
||||
replacements = {{ cottages.craftitem_stone, cottages.craftitem_seed_wheat.." 3" }},
|
||||
})
|
||||
|
||||
-- this is a better way to get straw mats
|
||||
|
Loading…
x
Reference in New Issue
Block a user