add inbox

This commit is contained in:
maikerumine 2016-01-30 00:58:42 -05:00
parent c9df5fac9c
commit d5cb36f346
7 changed files with 383 additions and 0 deletions

1
mods/inbox/depends.txt Normal file
View File

@ -0,0 +1 @@
default

107
mods/inbox/init.lua Normal file
View File

@ -0,0 +1,107 @@
local inbox = {}
screwdriver = screwdriver or {}
minetest.register_craft({
output ="inbox:empty",
recipe = {
{"","default:steel_ingot",""},
{"default:steel_ingot","","default:steel_ingot"},
{"default:steel_ingot","default:steel_ingot","default:steel_ingot"}
}
})
local mb_cbox = {
type = "fixed",
fixed = { -5/16, -8/16, -8/16, 5/16, 2/16, 8/16 }
}
minetest.register_node("inbox:empty", {
paramtype = "light",
drawtype = "mesh",
mesh = "inbox_mailbox.obj",
description = "Mailbox",
tiles = {
"inbox_red_metal.png",
"inbox_white_metal.png",
"inbox_grey_metal.png",
},
inventory_image = "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", owner.."'s 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 then
minetest.show_formspec(
clicker:get_player_name(),
"default:chest_locked",
inbox.get_inbox_formspec(pos))
else
minetest.show_formspec(
clicker:get_player_name(),
"default:chest_locked",
inbox.get_inbox_insert_formspec(pos))
end
end,
can_dig = function(pos,player)
local meta = minetest.get_meta(pos);
local owner = meta:get_string("owner")
local inv = meta:get_inventory()
return player:get_player_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
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
if inv:room_for_item("main", stack) then
return -1
else
return 0
end
end
end,
})
function inbox.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;]"
return formspec
end
function inbox.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;]"
return formspec
end

View File

@ -0,0 +1,275 @@
# 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

Binary file not shown.

After

Width:  |  Height:  |  Size: 152 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 319 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 156 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB