added option to make machines public
parent
739f3a7ac4
commit
3197c4a6bc
|
@ -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
|
1
init.lua
1
init.lua
|
@ -57,6 +57,7 @@ cottages.handmill_product[ 'default:coal_lump'] = 'dye:black 6';
|
||||||
cottages.handmill_max_per_turn = 20;
|
cottages.handmill_max_per_turn = 20;
|
||||||
cottages.handmill_min_per_turn = 0;
|
cottages.handmill_min_per_turn = 0;
|
||||||
|
|
||||||
|
dofile(minetest.get_modpath("cottages").."/functions.lua");
|
||||||
|
|
||||||
-- uncomment parts you do not want
|
-- uncomment parts you do not want
|
||||||
dofile(minetest.get_modpath("cottages").."/nodes_furniture.lua");
|
dofile(minetest.get_modpath("cottages").."/nodes_furniture.lua");
|
||||||
|
|
|
@ -109,6 +109,8 @@ straw = Stroh
|
||||||
threshing floor = Dreschboden
|
threshing floor = Dreschboden
|
||||||
Threshing floor = Dreschboden
|
Threshing floor = Dreschboden
|
||||||
Threshing floor (owned by %s) = Dreschboden (gehoert %s)
|
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
|
Harvested wheat: = Geernteter Weizen
|
||||||
Straw: = Stroh
|
Straw: = Stroh
|
||||||
Seeds: = Koerner
|
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 = 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)
|
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
|
Wheat seeds: = Weizenkoerner
|
||||||
Flour: = Mehl
|
Flour: = Mehl
|
||||||
Mill = Muehle
|
Mill = Muehle
|
||||||
|
@ -128,3 +132,11 @@ Punch this hand-driven mill = Schlage auf diese handbetriebene Muehle
|
||||||
to convert wheat seeds into flour. = um Weizenkoerner in Mehl umzuwandeln.
|
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 %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.
|
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 nur noch von dir benutzt werden.
|
||||||
|
Your mill, powered by punching can only be used by yourself. = Deine Mühle kann nur noch von dir benutzt werden.
|
||||||
|
|
||||||
|
Public? = Öffentlich?
|
||||||
|
|
|
@ -108,6 +108,8 @@ straw =
|
||||||
threshing floor =
|
threshing floor =
|
||||||
Threshing floor =
|
Threshing floor =
|
||||||
Threshing floor (owned by %s) =
|
Threshing floor (owned by %s) =
|
||||||
|
Public threshing floor (owned by %s) =
|
||||||
|
Private threshing floor (owned by %s) =
|
||||||
Harvested wheat: =
|
Harvested wheat: =
|
||||||
Straw: =
|
Straw: =
|
||||||
Seeds: =
|
Seeds: =
|
||||||
|
@ -119,6 +121,8 @@ You have threshed the last %s wheat. =
|
||||||
mill, powered by punching =
|
mill, powered by punching =
|
||||||
Mill, powered by punching =
|
Mill, powered by punching =
|
||||||
Mill, powered by punching (owned by %s) =
|
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: =
|
Wheat seeds: =
|
||||||
Flour: =
|
Flour: =
|
||||||
Mill =
|
Mill =
|
||||||
|
@ -127,3 +131,11 @@ Punch this hand-driven mill =
|
||||||
to convert wheat seeds into flour. =
|
to convert wheat seeds into flour. =
|
||||||
You have grinded %s wheat seeds (%s are left). =
|
You have grinded %s wheat seeds (%s are left). =
|
||||||
You have grinded the last %s wheat seeds. =
|
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? =
|
||||||
|
|
|
@ -6,18 +6,6 @@
|
||||||
|
|
||||||
local S = cottages.S
|
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
|
-- 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
|
-- it is a nodebox and not wallmounted because that makes it easier to replace beds with straw mats
|
||||||
|
@ -91,6 +79,7 @@ local cottages_formspec_treshing_floor =
|
||||||
"size[8,8]"..
|
"size[8,8]"..
|
||||||
"image[1.5,0;1,1;"..cottages.texture_stick.."]"..
|
"image[1.5,0;1,1;"..cottages.texture_stick.."]"..
|
||||||
"image[0,1;1,1;farming_wheat.png]"..
|
"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;harvest;1,1;2,1;]"..
|
||||||
"list[current_name;straw;5,0;2,2;]"..
|
"list[current_name;straw;5,0;2,2;]"..
|
||||||
"list[current_name;seeds;5,2;2,2;]"..
|
"list[current_name;seeds;5,2;2,2;]"..
|
||||||
|
@ -109,7 +98,8 @@ minetest.register_node("cottages:threshing_floor", {
|
||||||
tiles = {"cottages_junglewood.png^farming_wheat.png","cottages_junglewood.png","cottages_junglewood.png^"..cottages.texture_stick},
|
tiles = {"cottages_junglewood.png^farming_wheat.png","cottages_junglewood.png","cottages_junglewood.png^"..cottages.texture_stick},
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
groups = {cracky=2},
|
-- can be digged with axe and pick
|
||||||
|
groups = {cracky=2, choppy=2},
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
node_box = {
|
node_box = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
|
@ -131,21 +121,27 @@ minetest.register_node("cottages:threshing_floor", {
|
||||||
},
|
},
|
||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
local meta = minetest.get_meta(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();
|
local inv = meta:get_inventory();
|
||||||
inv:set_size("harvest", 2);
|
inv:set_size("harvest", 2);
|
||||||
inv:set_size("straw", 4);
|
inv:set_size("straw", 4);
|
||||||
inv:set_size("seeds", 4);
|
inv:set_size("seeds", 4);
|
||||||
meta:set_string("formspec", cottages_formspec_treshing_floor );
|
meta:set_string("formspec", cottages_formspec_treshing_floor );
|
||||||
|
meta:set_string("public", "public")
|
||||||
end,
|
end,
|
||||||
|
|
||||||
after_place_node = function(pos, placer)
|
after_place_node = function(pos, placer)
|
||||||
local meta = minetest.get_meta(pos);
|
local meta = minetest.get_meta(pos);
|
||||||
meta:set_string("owner", placer:get_player_name() or "");
|
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",
|
meta:set_string("formspec",
|
||||||
cottages_formspec_treshing_floor..
|
cottages_formspec_treshing_floor..
|
||||||
"label[2.5,-0.5;"..S("Owner: %s"):format(meta:get_string("owner") or "").."]" );
|
"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,
|
end,
|
||||||
|
|
||||||
can_dig = function(pos,player)
|
can_dig = function(pos,player)
|
||||||
|
@ -167,7 +163,7 @@ minetest.register_node("cottages:threshing_floor", {
|
||||||
|
|
||||||
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
|
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
|
||||||
local meta = minetest.get_meta(pos)
|
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
|
return 0
|
||||||
end
|
end
|
||||||
return count;
|
return count;
|
||||||
|
@ -182,7 +178,7 @@ minetest.register_node("cottages:threshing_floor", {
|
||||||
return 0;
|
return 0;
|
||||||
end
|
end
|
||||||
|
|
||||||
if( not( cottages_can_use( meta, player ))) then
|
if( not( cottages.player_can_use( meta, player ))) then
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
return stack:get_count()
|
return stack:get_count()
|
||||||
|
@ -190,7 +186,7 @@ minetest.register_node("cottages:threshing_floor", {
|
||||||
|
|
||||||
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
|
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||||
local meta = minetest.get_meta(pos)
|
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
|
return 0
|
||||||
end
|
end
|
||||||
return stack:get_count()
|
return stack:get_count()
|
||||||
|
@ -348,6 +344,7 @@ minetest.register_node("cottages:threshing_floor", {
|
||||||
|
|
||||||
local cottages_handmill_formspec = "size[8,8]"..
|
local cottages_handmill_formspec = "size[8,8]"..
|
||||||
"image[0,1;1,1;"..cottages.texture_wheat_seed.."]"..
|
"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;seeds;1,1;1,1;]"..
|
||||||
"list[current_name;flour;5,1;2,2;]"..
|
"list[current_name;flour;5,1;2,2;]"..
|
||||||
"label[0,0.5;"..S("Wheat seeds:").."]"..
|
"label[0,0.5;"..S("Wheat seeds:").."]"..
|
||||||
|
@ -380,20 +377,26 @@ minetest.register_node("cottages:handmill", {
|
||||||
},
|
},
|
||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
local meta = minetest.get_meta(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();
|
local inv = meta:get_inventory();
|
||||||
inv:set_size("seeds", 1);
|
inv:set_size("seeds", 1);
|
||||||
inv:set_size("flour", 4);
|
inv:set_size("flour", 4);
|
||||||
meta:set_string("formspec", cottages_handmill_formspec );
|
meta:set_string("formspec", cottages_handmill_formspec );
|
||||||
|
meta:set_string("public", "public")
|
||||||
end,
|
end,
|
||||||
|
|
||||||
after_place_node = function(pos, placer)
|
after_place_node = function(pos, placer)
|
||||||
local meta = minetest.get_meta(pos);
|
local meta = minetest.get_meta(pos);
|
||||||
meta:set_string("owner", placer:get_player_name() or "");
|
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",
|
meta:set_string("formspec",
|
||||||
cottages_handmill_formspec..
|
cottages_handmill_formspec..
|
||||||
"label[2.5,-0.5;"..S("Owner: %s"):format(meta:get_string('owner') or "").."]" );
|
"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,
|
end,
|
||||||
|
|
||||||
can_dig = function(pos,player)
|
can_dig = function(pos,player)
|
||||||
|
@ -414,7 +417,7 @@ minetest.register_node("cottages:handmill", {
|
||||||
|
|
||||||
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
|
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
|
||||||
local meta = minetest.get_meta(pos)
|
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
|
return 0
|
||||||
end
|
end
|
||||||
return count;
|
return count;
|
||||||
|
@ -428,7 +431,7 @@ minetest.register_node("cottages:handmill", {
|
||||||
return 0;
|
return 0;
|
||||||
end
|
end
|
||||||
|
|
||||||
if( not( cottages_can_use( meta, player ))) then
|
if( not( cottages.player_can_use( meta, player ))) then
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
return stack:get_count()
|
return stack:get_count()
|
||||||
|
@ -436,7 +439,7 @@ minetest.register_node("cottages:handmill", {
|
||||||
|
|
||||||
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
|
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||||
local meta = minetest.get_meta(pos)
|
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
|
return 0
|
||||||
end
|
end
|
||||||
return stack:get_count()
|
return stack:get_count()
|
||||||
|
|
Loading…
Reference in New Issue