Debug, refactor and tweak textures.

Anyone can add an item to a shared inbox, and anyone with edit access can take
items from the mailbox. A player with edit access can add an item by holding
the auxiliary button (default: 'e') when they right-click the mailbox.

Closes #3.
This commit is contained in:
Foz 2016-12-30 23:50:44 -05:00
parent 812c349944
commit c2cfd61a90
12 changed files with 134 additions and 386 deletions

11
.luacheckrc Normal file
View File

@ -0,0 +1,11 @@
unused_args = false
allow_defined_top = true
read_globals = {
'minetest', 'core',
'vector',
'default',
'fishing',
'moretrees',
'stairsplus',
}

View File

@ -1,5 +1,5 @@
whoison?
fire?
bucket?
inbox
inbox?
doors

View File

@ -16,7 +16,7 @@ dofile(path.."/protection.lua")
dofile(path.."/shared_door.lua")
dofile(path.."/chest.lua")
dofile(path.."/sign.lua")
dofile(path..'shared_inbox.lua')
dofile(path..'/shared_inbox.lua')
if ( landrush.config:get_bool("enableHud") ) then
dofile(path.."/hud.lua")

View File

@ -1,275 +0,0 @@
# Blender v2.73 (sub 0) OBJ File: 'mailbox.blend'
# www.blender.org
o Cylinder
v 0.312500 -0.500000 -0.500000
v 0.312500 -0.500000 0.500000
v -0.312500 -0.500000 0.500000
v -0.312500 -0.500000 -0.500000
v -0.230971 -0.082709 0.437500
v -0.250001 -0.178381 0.437500
v 0.250001 -0.178381 0.437500
v 0.230971 -0.082709 0.437500
v 0.000000 0.125000 0.500000
v -0.000000 0.125000 -0.500000
v -0.119589 0.101212 0.500000
v -0.119589 0.101212 -0.500000
v -0.220971 0.033471 0.500000
v -0.220971 0.033471 -0.500000
v -0.288712 -0.067911 0.500000
v -0.288712 -0.067911 -0.500000
v -0.312500 -0.187500 0.500000
v -0.312500 -0.187500 -0.500000
v 0.176777 -0.001603 0.437500
v 0.095671 0.052590 0.437500
v 0.095671 0.052590 -0.500000
v 0.176777 -0.001603 -0.500000
v 0.230971 -0.082709 -0.500000
v 0.250001 -0.178381 -0.500000
v -0.250001 -0.178381 -0.500000
v -0.230971 -0.082709 -0.500000
v -0.176778 -0.001603 -0.500000
v -0.095671 0.052590 -0.500000
v -0.000000 0.071621 -0.500000
v -0.250001 -0.437501 -0.500000
v 0.250001 -0.437501 -0.500000
v 0.000000 -0.067809 0.500000
v 0.312500 -0.187500 0.500000
v 0.312500 -0.187500 -0.500000
v 0.288712 -0.067911 0.500000
v 0.288712 -0.067911 -0.500000
v 0.220971 0.033471 0.500000
v 0.220971 0.033471 -0.500000
v 0.119588 0.101212 0.500000
v 0.119588 0.101212 -0.500000
v -0.176778 -0.001603 0.437500
v -0.095671 0.052590 0.437500
v 0.000000 0.071621 0.437500
v -0.250001 -0.437501 0.437500
v 0.250001 -0.437501 0.437500
v 0.000000 -0.082627 0.437500
v -0.312500 -0.250000 -0.375000
v -0.312500 -0.250000 -0.312500
v -0.343750 -0.250000 -0.312500
v -0.343750 -0.250000 -0.375000
v -0.312500 0.250000 -0.375000
v -0.312500 0.250000 -0.312500
v -0.343750 0.250000 -0.312500
v -0.343750 0.250000 -0.375000
v -0.320312 0.125000 -0.312500
v -0.320312 0.125000 -0.187500
v -0.335937 0.125000 -0.187500
v -0.335937 0.125000 -0.312500
v -0.320312 0.250000 -0.312500
v -0.320312 0.250000 -0.187500
v -0.335937 0.250000 -0.187500
v -0.335937 0.250000 -0.312500
vt 0.000000 0.000000
vt 0.181818 0.000000
vt 0.181818 1.000000
vt 0.000000 1.000000
vt 0.818182 0.000000
vt 0.909091 0.000000
vt 0.909091 1.000000
vt 0.818182 1.000000
vt 0.363637 1.000000
vt 0.363637 0.000000
vt 0.454545 0.000000
vt 0.454546 1.000000
vt 0.545455 0.500000
vt 0.545455 0.625000
vt 0.454546 0.625000
vt 0.454546 0.500000
vt 0.636364 0.500000
vt 0.636364 0.625000
vt 0.454546 0.250000
vt 0.818182 0.250000
vt 0.818182 0.500000
vt 0.954545 0.000000
vt 0.954545 0.250000
vt 0.909091 0.250000
vt 0.909091 0.500000
vt 0.954545 0.500000
vt 1.000000 0.000000
vt 1.000000 0.250000
vt 0.973553 0.716044
vt 0.933816 0.766735
vt 0.804196 0.716095
vt 0.437572 0.500000
vt 0.507722 0.511894
vt 0.493693 0.536205
vt 0.437572 0.526690
vt 0.987507 0.656250
vt 0.567193 0.545764
vt 0.606930 0.596456
vt 0.573059 0.603855
vt 0.541269 0.563301
vt 0.000000 0.500000
vt 0.366623 0.000000
vt 0.366623 0.500000
vt 0.874346 0.800606
vt 0.620884 0.656250
vt 0.634838 0.716044
vt 0.674575 0.766735
vt 0.734045 0.800606
vt 0.804196 0.812500
vt 0.987507 0.500000
vt 0.620884 0.500000
vt 0.584222 0.651690
vt 0.620884 0.812500
vt 0.584222 0.781251
vt 0.254261 0.812500
vt 0.254261 0.656250
vt 0.290922 0.651690
vt 0.290922 0.781251
vt 0.268214 0.596456
vt 0.302085 0.603855
vt 0.307951 0.545765
vt 0.333875 0.563302
vt 0.367422 0.511894
vt 0.381452 0.536205
vt 0.116656 0.500000
vt 0.116656 1.000000
vt 0.050576 1.000000
vt 0.050576 0.500000
vt 1.000000 0.500000
vt 0.936921 0.500000
vt 0.936921 0.000000
vt 0.865741 0.500000
vt 0.865741 0.000000
vt 0.683312 0.000000
vt 0.683312 0.500000
vt 0.549052 0.000000
vt 0.549052 0.500000
vt 0.620232 0.000000
vt 0.620233 0.500000
vt 0.188180 0.500000
vt 0.188180 1.000000
vt 0.254260 0.500000
vt 0.254261 1.000000
vt 0.000000 0.703643
vt 0.000000 0.414971
vt 0.648062 0.414971
vt 0.648062 0.703643
vt 0.820879 0.711328
vt 1.000000 0.711328
vt 1.000000 1.000000
vt 0.820879 1.000000
vt 0.648062 0.855664
vt 0.661216 0.800429
vt 0.754688 0.855664
vt 0.698678 0.753603
vt 0.754744 0.722315
vt 0.754745 0.989013
vt 0.698679 0.957725
vt 0.661216 0.910899
vt 0.000000 0.160377
vt 0.000000 0.108347
vt 0.648062 0.108347
vt 0.648062 0.160377
vt 0.648062 0.957694
vt 0.648061 1.000000
vt 0.000000 0.957694
vt 0.648062 0.904383
vt 0.000000 0.904383
vt 0.648062 0.848183
vt 0.000000 0.848183
vt 0.000000 0.309258
vt 0.648062 0.309258
vt 0.000000 0.365304
vt 0.648062 0.365304
vt 0.000000 0.052030
vt 0.648062 0.000000
vt 0.648062 0.052030
vn 1.000000 0.000000 0.000000
vn 0.000000 0.000000 1.000000
vn -1.000000 0.000000 0.000000
vn 0.000000 0.000000 -1.000000
vn 0.000000 -1.000000 0.000000
vn 0.000000 1.000000 0.000000
vn -0.382700 0.923900 -0.000000
vn -0.707100 0.707100 0.000000
vn -0.923900 0.382700 0.000000
vn -0.995200 0.098000 0.000000
vn 0.995200 0.098000 -0.000000
vn 0.923900 0.382700 -0.000000
vn 0.707100 0.707100 -0.000000
vn 0.382700 0.923900 -0.000000
vn 0.382700 -0.923900 -0.000000
vn 0.707100 -0.707100 -0.000000
vn 0.923900 -0.382700 -0.000000
vn 0.995200 -0.098000 -0.000000
vn -0.995200 -0.098000 0.000000
vn -0.923900 -0.382700 0.000000
vn -0.707100 -0.707100 0.000000
vn -0.382700 -0.923900 0.000000
g Cylinder_Cylinder_flag
s off
f 51/1/1 52/2/1 48/3/1 47/4/1
f 52/5/2 53/6/2 49/7/2 48/8/2
f 53/9/3 54/3/3 50/2/3 49/10/3
f 54/10/4 51/11/4 47/12/4 50/9/4
f 47/13/5 48/14/5 49/15/5 50/16/5
f 54/14/6 53/13/6 52/17/6 51/18/6
f 59/16/1 60/19/1 56/20/1 55/21/1
f 60/6/2 61/22/2 57/23/2 56/24/2
f 61/19/3 62/11/3 58/5/3 57/20/3
f 55/25/5 56/24/5 57/23/5 58/26/5
f 62/27/6 61/28/6 60/23/6 59/22/6
g Cylinder_Cylinder_outside
f 35/29/2 37/30/2 32/31/2
f 10/32/4 40/33/4 21/34/4 29/35/4
f 33/36/2 35/29/2 32/31/2
f 38/37/4 36/38/4 23/39/4 22/40/4
f 1/41/5 2/1/5 3/42/5 4/43/5
f 37/30/2 39/44/2 32/31/2
f 17/45/2 33/36/2 32/31/2
f 15/46/2 17/45/2 32/31/2
f 13/47/2 15/46/2 32/31/2
f 11/48/2 13/47/2 32/31/2
f 9/49/2 11/48/2 32/31/2
f 2/50/2 33/36/2 17/45/2 3/51/2
f 39/44/2 9/49/2 32/31/2
f 40/33/4 38/37/4 22/40/4 21/34/4
f 36/38/4 34/45/4 24/52/4 23/39/4
f 34/45/4 1/53/4 31/54/4 24/52/4
f 4/55/4 18/56/4 25/57/4 30/58/4
f 18/56/4 16/59/4 26/60/4 25/57/4
f 16/59/4 14/61/4 27/62/4 26/60/4
f 14/61/4 12/63/4 28/64/4 27/62/4
f 12/63/4 10/32/4 29/35/4 28/64/4
f 1/53/4 4/55/4 30/58/4 31/54/4
s 1
f 9/65/6 10/66/6 12/67/7 11/68/7
f 11/68/7 12/67/7 14/4/8 13/41/8
f 13/27/8 14/69/8 16/70/9 15/71/9
f 15/71/9 16/70/9 18/72/10 17/73/10
f 3/74/3 17/73/10 18/72/10 4/75/3
f 2/43/1 1/42/1 34/76/11 33/77/11
f 33/77/11 34/76/11 36/78/12 35/79/12
f 35/79/12 36/78/12 38/74/13 37/75/13
f 39/80/14 40/81/14 10/66/6 9/65/6
f 37/82/13 38/83/13 40/81/14 39/80/14
g Cylinder_Cylinder_inside
s off
f 31/84/6 30/85/6 44/86/6 45/87/6
f 7/88/4 45/89/4 44/90/4 6/91/4
f 43/92/4 20/93/4 46/94/4
f 20/93/4 19/95/4 46/94/4
f 19/95/4 8/96/4 46/94/4
f 8/96/4 7/88/4 46/94/4
f 7/88/4 6/91/4 46/94/4
f 6/91/4 5/97/4 46/94/4
f 5/97/4 41/98/4 46/94/4
f 41/98/4 42/99/4 46/94/4
f 42/99/4 43/92/4 46/94/4
s 1
f 28/100/15 29/101/5 43/102/5 42/103/15
f 27/104/16 28/105/15 42/4/15 41/106/16
f 26/107/17 27/104/16 41/106/16 5/108/17
f 25/109/18 26/107/17 5/108/17 6/110/18
f 30/87/1 25/109/18 6/110/18 44/84/1
f 24/111/19 31/100/3 45/103/3 7/112/19
f 23/113/20 24/111/19 7/112/19 8/114/20
f 22/85/21 23/113/20 8/114/20 19/86/21
f 21/115/22 22/1/21 19/116/21 20/117/22
f 29/101/5 21/115/22 20/117/22 43/102/5

View File

@ -1,119 +1,131 @@
-- 99.99 % code from homedcor modpack inbox
-- original code licensed under gpl version 3
-- original code by VanessaE
-- modified for use on fozland server by mootpoint license gpl version 3 for
-- all textures : CC-by-SA 3.0 or higher
-- original textures by VanessaE
local fozland = {}
screwdriver = screwdriver or {}
-- Adapted from homedcor modpack inbox licensed under gpl version 3 by VanessaE.
-- Modified by mootpoint and Foz license gpl version 3
-- textures: CC-by-SA 3.0 or higher
minetest.register_craft({
output ="fozland:shared_mailbox",
recipe = {
{"", "inbox:empty", ""},
{"", "inbox:empty", ""},
{"", "", ""}
if minetest.get_modpath('inbox') then
screwdriver = screwdriver or {}
local function take_fs(pos)
local spos = pos.x .. ',' .. pos.y .. ',' ..pos.z
local formspec =
'size[8,9]'..
default.gui_bg ..
default.gui_bg_img ..
default.gui_slots ..
'list[nodemeta:' .. spos .. ';main;0,0.3;8,4;]' ..
'list[current_player;main;0,4.85;8,1;]' ..
'list[current_player;main;0,6.08;8,3;8]' ..
'listring[nodemeta:' .. spos .. ';main]' ..
'listring[current_player;main]' ..
default.get_hotbar_bg(0,4.85)
return formspec
end
local function give_fs(pos)
local spos = pos.x .. ',' .. pos.y .. ',' ..pos.z
local formspec =
'size[8,9]'..
default.gui_bg ..
default.gui_bg_img ..
default.gui_slots ..
'list[nodemeta:'.. spos .. ';drop;3.5,2;1,1;]'..
'list[current_player;main;0,4.85;8,1;]' ..
'list[current_player;main;0,6.08;8,3;8]' ..
'listring[nodemeta:' .. spos .. ';drop]' ..
'listring[current_player;main]' ..
default.get_hotbar_bg(0,4.85)
return formspec
end
local mb_cbox = {
type = 'fixed',
fixed = { -5/16, -8/16, -8/16, 5/16, 2/16, 8/16 }
}
})
local mb_cbox = {
type = "fixed",
fixed = { -5/16, -8/16, -8/16, 5/16, 2/16, 8/16 }
}
minetest.register_node("fozland:shared_mailbox", {
paramtype = "light",
drawtype = "mesh",
mesh = "inbox_mailbox.obj",
description = "Shared Mailbox",
tiles = {
"shared_inbox_red_metal.png",
"shared_inbox_blue_metal.png",
"shared_inbox_grey_metal.png",
},
inventory_image = "shared_mailbox_inv.png",
selection_box = mb_cbox,
collision_box = mb_cbox,
paramtype2 = "facedir",
groups = {choppy=2,oddly_breakable_by_hand=2},
sounds = default.node_sound_wood_defaults(),
on_rotate = screwdriver.rotate_simple,
after_place_node = function(pos, placer, itemstack)
local meta = minetest.get_meta(pos)
local owner = placer:get_player_name()
meta:set_string("owner", owner)
meta:set_string("infotext", "Shared Mailbox")
local inv = meta:get_inventory()
inv:set_size("main", 8*4)
inv:set_size("drop", 1)
end,
on_rightclick = function(pos, node, clicker, itemstack)
local meta = minetest.get_meta(pos)
local player = clicker:get_player_name()
local owner = meta:get_string("owner")
local meta = minetest.get_meta(pos)
if owner == player or not minetest.is_protected(pos, player) then
minetest.show_formspec(
clicker:get_player_name(),
"default:chest_locked",
fozland.get_inbox_formspec(pos))
else
minetest.show_formspec(
clicker:get_player_name(),
"default:chest_locked",
fozland.get_inbox_insert_formspec(pos))
end
return itemstack
end,
can_dig = function(pos,player)
local meta = minetest.get_meta(pos);
local name = player and player:get_player_name()
local owner = meta:get_string("owner")
local inv = meta:get_inventory()
return name == owner and inv:is_empty("main")
end,
on_metadata_inventory_put = function(pos, listname, index, stack, player)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
if listname == "drop" and inv:room_for_item("main", stack) then
inv:remove_item("drop", stack)
inv:add_item("main", stack)
end
end,
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
if listname == "main" then
return 0
end
if listname == "drop" then
minetest.register_node(':landrush:shared_mailbox', {
paramtype = 'light',
drawtype = 'mesh',
mesh = 'inbox_mailbox.obj',
description = 'Shared Mailbox',
tiles = {
'landrush_shared_inbox_flag.png',
'landrush_shared_inbox_box.png',
'inbox_grey_metal.png',
},
inventory_image = 'landrush_shared_mailbox_inv.png',
selection_box = mb_cbox,
collision_box = mb_cbox,
paramtype2 = 'facedir',
groups = {choppy=2,oddly_breakable_by_hand=2},
sounds = default.node_sound_wood_defaults(),
on_rotate = screwdriver.rotate_simple,
after_place_node = function(pos, placer, itemstack)
local meta = minetest.get_meta(pos)
meta:set_string('infotext', 'Shared Mailbox')
local inv = meta:get_inventory()
if inv:room_for_item("main", stack) then
return -1
inv:set_size('main', 8*4)
inv:set_size('drop', 1)
end,
on_rightclick = function(pos, node, clicker, itemstack)
local name = clicker:get_player_name()
if clicker:get_player_control().aux1 or
minetest.is_protected(pos, name) then
minetest.show_formspec(name, 'landrush:shared_inbox', give_fs(pos))
else
minetest.show_formspec(name, 'landrush:shared_inbox', take_fs(pos))
end
return itemstack
end,
can_dig = function(pos,player)
local meta = minetest.get_meta(pos);
local inv = meta:get_inventory()
return inv:is_empty('main')
end,
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
if listname == 'drop' then
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
if inv:room_for_item('main', stack) then
return -1
end
end
return 0
end,
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
if minetest.is_protected(pos, player:get_player_name()) then
return 0
end
end
end,
})
return stack:get_count()
end,
on_metadata_inventory_put = function(pos, listname, index, stack, player)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
inv:remove_item('drop', stack)
inv:add_item('main', stack)
local name = player:get_player_name()
local stuff = stack:get_count()..' '..stack:get_name()
local action = ' puts '..stuff..' in shared inbox at '
local location = minetest.pos_to_string(pos)
minetest.log('action',name..action..location)
end,
on_metadata_inventory_take = function(pos, listname, index, stack, player)
local name = player:get_player_name()
local stuff = stack:get_count()..' '..stack:get_name()
local action = ' takes '..stuff..' from shared inbox at '
local location = minetest.pos_to_string(pos)
minetest.log('action',name..action..location)
end,
})
minetest.register_craft({
output ='landrush:shared_mailbox',
recipe = {
{'', 'inbox:empty', ''},
{'', 'inbox:empty', ''},
{'', '', ''}
}
})
function fozland.get_inbox_formspec(pos)
local spos = pos.x .. "," .. pos.y .. "," ..pos.z
local formspec =
"size[8,9]"..
"list[nodemeta:".. spos .. ";main;0,0;8,4;]"..
"list[current_player;main;0,5;8,4;]" ..
"listring[]"
return formspec
end
function fozland.get_inbox_insert_formspec(pos)
local spos = pos.x .. "," .. pos.y .. "," ..pos.z
local formspec =
"size[8,9]"..
"list[nodemeta:".. spos .. ";drop;3.5,2;1,1;]"..
"list[current_player;main;0,5;8,4;]"..
"listring[]"
return formspec
end

Binary file not shown.

After

Width:  |  Height:  |  Size: 196 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 196 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 215 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 152 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 319 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB