Merge https://github.com/Sokomine/cottages into HEAD
commit
876ff2de08
|
@ -9,6 +9,12 @@
|
||||||
|
|
||||||
local S = cottages.S
|
local S = cottages.S
|
||||||
|
|
||||||
|
-- disable repair with anvil by setting a message for the item in question
|
||||||
|
cottages.forbid_repair = {}
|
||||||
|
-- example for hammer no longer beeing able to repair the hammer
|
||||||
|
--cottages.forbid_repair["cottages:hammer"] = 'The hammer is too complex for repairing.'
|
||||||
|
|
||||||
|
|
||||||
-- the hammer for the anvil
|
-- the hammer for the anvil
|
||||||
minetest.register_tool("cottages:hammer", {
|
minetest.register_tool("cottages:hammer", {
|
||||||
description = S("Steel hammer for repairing tools on the anvil"),
|
description = S("Steel hammer for repairing tools on the anvil"),
|
||||||
|
@ -140,6 +146,12 @@ minetest.register_node("cottages:anvil", {
|
||||||
S('The workpiece slot is for damaged tools only.'));
|
S('The workpiece slot is for damaged tools only.'));
|
||||||
return 0;
|
return 0;
|
||||||
end
|
end
|
||||||
|
if( listname=='input'
|
||||||
|
and cottages.forbid_repair[ stack:get_name() ]) then
|
||||||
|
minetest.chat_send_player( player:get_player_name(),
|
||||||
|
S(cottages.forbid_repair[ stack:get_name() ]));
|
||||||
|
return 0;
|
||||||
|
end
|
||||||
return stack:get_count()
|
return stack:get_count()
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
@ -183,6 +195,14 @@ minetest.register_node("cottages:anvil", {
|
||||||
-- 65535 is max damage
|
-- 65535 is max damage
|
||||||
local damage_state = 40-math.floor(input:get_wear()/1638);
|
local damage_state = 40-math.floor(input:get_wear()/1638);
|
||||||
|
|
||||||
|
-- just to make sure that it really can't get repaired if it should not
|
||||||
|
-- (if the check of placing the item in the input slot failed somehow)
|
||||||
|
if( puncher and name and cottages.forbid_repair[ input:get_name() ]) then
|
||||||
|
minetest.chat_send_player( name,
|
||||||
|
S(cottages.forbid_repair[ input:get_name() ]));
|
||||||
|
return;
|
||||||
|
end
|
||||||
|
|
||||||
local tool_name = input:get_name();
|
local tool_name = input:get_name();
|
||||||
local hud_image = "";
|
local hud_image = "";
|
||||||
if( tool_name
|
if( tool_name
|
||||||
|
@ -231,9 +251,9 @@ minetest.register_node("cottages:anvil", {
|
||||||
end
|
end
|
||||||
minetest.after(2, function()
|
minetest.after(2, function()
|
||||||
if( puncher ) then
|
if( puncher ) then
|
||||||
puncher:hud_remove(hud1);
|
if(hud1) then puncher:hud_remove(hud1); end
|
||||||
puncher:hud_remove(hud2);
|
if(hud2) then puncher:hud_remove(hud2); end
|
||||||
puncher:hud_remove(hud3);
|
if(hud3) then puncher:hud_remove(hud3); end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
|
@ -264,10 +264,13 @@ minetest.register_node("cottages:shelf", {
|
||||||
|
|
||||||
local meta = minetest.get_meta(pos);
|
local meta = minetest.get_meta(pos);
|
||||||
|
|
||||||
|
local spos = pos.x .. "," .. pos.y .. "," .. pos.z
|
||||||
meta:set_string("formspec",
|
meta:set_string("formspec",
|
||||||
"size[8,8]"..
|
"size[8,8]"..
|
||||||
"list[current_name;main;0,0;8,3;]"..
|
"list[current_name;main;0,0;8,3;]"..
|
||||||
"list[current_player;main;0,4;8,4;]")
|
"list[current_player;main;0,4;8,4;]"..
|
||||||
|
"listring[nodemeta:" .. spos .. ";main]" ..
|
||||||
|
"listring[current_player;main]")
|
||||||
meta:set_string("infotext", S("open storage shelf"))
|
meta:set_string("infotext", S("open storage shelf"))
|
||||||
local inv = meta:get_inventory();
|
local inv = meta:get_inventory();
|
||||||
inv:set_size("main", 24);
|
inv:set_size("main", 24);
|
||||||
|
|
|
@ -333,13 +333,13 @@ minetest.register_node("cottages:threshing_floor", {
|
||||||
|
|
||||||
minetest.after(2, function()
|
minetest.after(2, function()
|
||||||
if( puncher ) then
|
if( puncher ) then
|
||||||
puncher:hud_remove(hud1);
|
if(hud1) then puncher:hud_remove(hud1); end
|
||||||
puncher:hud_remove(hud2);
|
if(hud2) then puncher:hud_remove(hud2); end
|
||||||
puncher:hud_remove(hud3);
|
if(hud3) then puncher:hud_remove(hud3); end
|
||||||
puncher:hud_remove(hud4);
|
if(hud4) then puncher:hud_remove(hud4); end
|
||||||
puncher:hud_remove(hud5);
|
if(hud5) then puncher:hud_remove(hud5); end
|
||||||
puncher:hud_remove(hud6);
|
if(hud6) then puncher:hud_remove(hud6); end
|
||||||
puncher:hud_remove(hud0);
|
if(hud0) then puncher:hud_remove(hud0); end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end,
|
end,
|
||||||
|
|
|
@ -117,7 +117,7 @@ minetest.register_node("cottages:water_gen", {
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2},
|
groups = {tree = 1, choppy = 2, cracky = 1, flammable = 2},
|
||||||
sounds = cottages.sounds.wood,
|
sounds = cottages.sounds.wood,
|
||||||
node_box = {
|
node_box = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
|
@ -178,8 +178,14 @@ minetest.register_node("cottages:water_gen", {
|
||||||
can_dig = function(pos,player)
|
can_dig = function(pos,player)
|
||||||
local meta = minetest.get_meta(pos);
|
local meta = minetest.get_meta(pos);
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
return inv:is_empty("main") and
|
local bucket = meta:get_string("bucket")
|
||||||
default.can_interact_with_node(player, pos)
|
local start = meta:get_string("fillstarttime")
|
||||||
|
return inv:is_empty("main")
|
||||||
|
and default.can_interact_with_node(player, pos)
|
||||||
|
and (not(bucket) or bucket == "")
|
||||||
|
and ((not(start) or start == "" or
|
||||||
|
(minetest.get_us_time()/1000000) - tonumber(start)
|
||||||
|
>= cottages.water_fill_time -2))
|
||||||
end,
|
end,
|
||||||
-- no inventory move allowed
|
-- no inventory move allowed
|
||||||
allow_metadata_inventory_move = function(pos, from_list, from_index,
|
allow_metadata_inventory_move = function(pos, from_list, from_index,
|
||||||
|
@ -213,7 +219,7 @@ minetest.register_node("cottages:water_gen", {
|
||||||
cottages.switch_public(pos, formname, fields, sender, 'tree trunk well')
|
cottages.switch_public(pos, formname, fields, sender, 'tree trunk well')
|
||||||
end,
|
end,
|
||||||
-- punch to place and retrieve bucket
|
-- punch to place and retrieve bucket
|
||||||
on_punch = function(pos, node, puncher)
|
on_punch = function(pos, node, puncher, pointed_thing)
|
||||||
if( not( pos ) or not( node ) or not( puncher )) then
|
if( not( pos ) or not( node ) or not( puncher )) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -223,7 +229,8 @@ minetest.register_node("cottages:water_gen", {
|
||||||
local owner = meta:get_string("owner")
|
local owner = meta:get_string("owner")
|
||||||
local public = meta:get_string("public")
|
local public = meta:get_string("public")
|
||||||
if( name ~= owner and public~="public") then
|
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))
|
minetest.chat_send_player( name,
|
||||||
|
S("This tree trunk well is owned by %s. You can't use it."):format(owner))
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -233,13 +240,18 @@ minetest.register_node("cottages:water_gen", {
|
||||||
-- is the well working on something? (either empty or full bucket)
|
-- is the well working on something? (either empty or full bucket)
|
||||||
local bucket = meta:get_string("bucket")
|
local bucket = meta:get_string("bucket")
|
||||||
-- there is a bucket loaded - either empty or full
|
-- there is a bucket loaded - either empty or full
|
||||||
if( bucket and bucket~="") then
|
if( bucket and bucket~="" and bucket ~= "bucket:bucket_empty") then
|
||||||
if( not(pinv:room_for_item("main", bucket))) then
|
if( not(pinv:room_for_item("main", bucket))) then
|
||||||
minetest.chat_send_player( puncher:get_player_name(),
|
minetest.chat_send_player( puncher:get_player_name(),
|
||||||
S("Sorry. You have no room for the bucket. Please free some "..
|
S("Sorry. You have no room for the bucket. Please free some "..
|
||||||
"space in your inventory first!"))
|
"space in your inventory first!"))
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
elseif( bucket and bucket == "bucket:bucket_empty") then
|
||||||
|
minetest.chat_send_player( puncher:get_player_name(),
|
||||||
|
S("Please wait until your bucket has been filled."))
|
||||||
|
-- do not give the empty bucket back immediately
|
||||||
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- remove the old entity (either a bucket will be placed now or a bucket taken)
|
-- remove the old entity (either a bucket will be placed now or a bucket taken)
|
||||||
|
@ -267,8 +279,6 @@ minetest.register_node("cottages:water_gen", {
|
||||||
if( wielded
|
if( wielded
|
||||||
and wielded:get_name()
|
and wielded:get_name()
|
||||||
and wielded:get_name() == "bucket:bucket_empty") then
|
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
|
-- remember that we got a bucket loaded
|
||||||
meta:set_string("bucket", "bucket:bucket_empty")
|
meta:set_string("bucket", "bucket:bucket_empty")
|
||||||
-- create the entity
|
-- create the entity
|
||||||
|
@ -280,6 +290,8 @@ minetest.register_node("cottages:water_gen", {
|
||||||
minetest.after(cottages.water_fill_time, cottages.water_gen_fill_bucket, pos)
|
minetest.after(cottages.water_fill_time, cottages.water_gen_fill_bucket, pos)
|
||||||
-- the bucket will only be filled if the water ran long enough
|
-- the bucket will only be filled if the water ran long enough
|
||||||
meta:set_string("fillstarttime", tostring(minetest.get_us_time()/1000000))
|
meta:set_string("fillstarttime", tostring(minetest.get_us_time()/1000000))
|
||||||
|
-- remove the bucket from the players inventory
|
||||||
|
pinv:remove_item( "main", "bucket:bucket_empty")
|
||||||
return;
|
return;
|
||||||
end
|
end
|
||||||
-- buckets can also be emptied here
|
-- buckets can also be emptied here
|
||||||
|
|
Loading…
Reference in New Issue