From c406094b7217e452dd8e6531518a6bada5cb59a9 Mon Sep 17 00:00:00 2001 From: Vanessa Ezekowitz Date: Fri, 18 Jul 2014 19:45:26 -0400 Subject: [PATCH] import bas080's inbox mod --- inbox/depends.txt | 1 + inbox/init.lua | 109 +++++++++++++++++++++++++ inbox/textures/inbox_back.png | Bin 0 -> 272 bytes inbox/textures/inbox_bottom.png | Bin 0 -> 297 bytes inbox/textures/inbox_east.png | Bin 0 -> 276 bytes inbox/textures/inbox_front.png | Bin 0 -> 319 bytes inbox/textures/inbox_side_and_back.png | Bin 0 -> 193 bytes inbox/textures/inbox_top.png | Bin 0 -> 268 bytes inbox/textures/inbox_west.png | Bin 0 -> 235 bytes 9 files changed, 110 insertions(+) create mode 100644 inbox/depends.txt create mode 100644 inbox/init.lua create mode 100644 inbox/textures/inbox_back.png create mode 100644 inbox/textures/inbox_bottom.png create mode 100644 inbox/textures/inbox_east.png create mode 100644 inbox/textures/inbox_front.png create mode 100644 inbox/textures/inbox_side_and_back.png create mode 100644 inbox/textures/inbox_top.png create mode 100644 inbox/textures/inbox_west.png diff --git a/inbox/depends.txt b/inbox/depends.txt new file mode 100644 index 00000000..4ad96d51 --- /dev/null +++ b/inbox/depends.txt @@ -0,0 +1 @@ +default diff --git a/inbox/init.lua b/inbox/init.lua new file mode 100644 index 00000000..7e334882 --- /dev/null +++ b/inbox/init.lua @@ -0,0 +1,109 @@ +local inbox = {} + +--[[ +TODO +* Different node_box and texture for empty mailbox +]] + +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"} + } +}) + +minetest.register_node("inbox:empty", { + paramtype = "light", + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + {-4/12, -6/12, -6/12, 4/12, 0/12, 6/12}, + {-3/12, 0/12, -6/12, 3/12, 2/12, 6/12}, + {3/12, 0/12, -4/12, 4/12, 5/12, -2/12}, + {3/12, 3/12, -2/12, 4/12, 5/12, 0/12} + } + }, + description = "Mailbox", + tiles = {"inbox_top.png", "inbox_bottom.png", "inbox_east.png", + "inbox_west.png", "inbox_back.png", "inbox_front.png"}, + paramtype2 = "facedir", + groups = {choppy=2,oddly_breakable_by_hand=2}, + sounds = default.node_sound_wood_defaults(), + 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 + +print("[Mod]Inbox Loaded!") diff --git a/inbox/textures/inbox_back.png b/inbox/textures/inbox_back.png new file mode 100644 index 0000000000000000000000000000000000000000..346aa922274b30df62cfce9ae916f539bf4a9da0 GIT binary patch literal 272 zcmeAS@N?(olHy`uVBq!ia0vp^JRr=$1|-8uW1a&kwj^(N7lx}0w;670bkDjC6yYrJ zh%9Dc;1&j9Muu5)B!GhKC7!;n>~}e&M2vW!`c-iQg(OQ{BTAg}b8}PkN*J7rQWHy3 zQxwWGOEMJPJ$(bh8~Mb6iYh!^978nD&z)e%)nFjvEdMBM#r4a=RZ7eIc15UnpDSEd zvn0sm^8XK$93J$$J(rjp+{>7;uT7kH(hR2+(khv8i>K{4`P=WalxgdN@WVpp3_-U% zGuaRPUU%n${Bhp&r?~}e&M2swt{Oa2W6p}1)jVN)>&&^HED`9XhN=+Cf`9p>c zC0Wbe?w$<@vgEk+VTs4d{yZ^N#+M$m%T^tD-OppayVYeb22er|4RUI~M9QEFmIYKlU6 zW=V#EyQgnJcq5-UP*IJii(`n!`Q!uzL4!jQ>6MlLjSUP8?)>`R-v|VXpI(Q%;+PR42K>*E$nG@LtLaA~=}d?3q(pAu3(e*Azi zQjWMl7#?4lA78z_{r_a4LY<>&kwYLrTOztEg!0BcPCEiEBiObAE1aYF-J0b5UwyNotBh zd1gt5g1e`0KzJjcI8f1YPZ!4!jq_V4Zsa;-AkenI%lU=lu9qq|6ob3Jl>Tbj=O;MF z>ekV+EQQaOrZ=Qm*z>LW-amfl|3JP}^x|p`hTZW`mn>Ly=eM0^igZAGVHD%N^LJ*k zDP%iGk z`(@{xHu`q$){X6oOIla0+yBqG=GyV%E2>Yntzopr0B;w0YybcN literal 0 HcmV?d00001 diff --git a/inbox/textures/inbox_side_and_back.png b/inbox/textures/inbox_side_and_back.png new file mode 100644 index 0000000000000000000000000000000000000000..343732bce048f35b7d0cb4aaf10f5dd1c25c24cb GIT binary patch literal 193 zcmeAS@N?(olHy`uVBq!ia0vp^JRr=$1|-8uW1a&kwj^(N7a$D;Kb?2i11Zh|kH}&M z25w;xW@MN(M*=9wUgGKN%6^waN`!}XRlrM-4#^VNh!W@g+}zZ>5(ej@)Wnk16ovB4 zk_-iRPv3y>Mm}+%B27;h#}JM4$q5oA4Ilplf#<~opPpRJo|KdD^UF)+OsO9~ez^a2 b;9y{IUnJi2S4ztWsENVT)z4*}Q$iB}+!{Fe literal 0 HcmV?d00001 diff --git a/inbox/textures/inbox_top.png b/inbox/textures/inbox_top.png new file mode 100644 index 0000000000000000000000000000000000000000..fcda957c6014d93d09f219f8ab2fdb2e214cf1dd GIT binary patch literal 268 zcmeAS@N?(olHy`uVBq!ia0vp^JRr=$1|-8uW1a&kwj^(N7l!2w+zi|c4xgI<6yYrJ zh%9Dc;1&j9Muu5)B!GhKC7!;n>~}e&M2uDTJ-@656p}1)jVN)>&&^HED`9XhN=+~}e&L=1&Zazs`Gg(OQ{BTAg}b8}PkN*J7rQWHy3 zQxwWGOEMJPJ$(bh8~Mb6ih?~|978nDCnqQf8a$d5aqjG2`I+)RziKNp1A*{Lvkia# z|Ce9?R=c9&pRs{~!GSA=c6C2r*?XGR{Q5G{ME&E(kCVl`{(r1sTFvVpw>M4VQ5^$A X+H3{;`*Y<%u4nLc^>bP0l+XkKVuwpV literal 0 HcmV?d00001