diff options
author | Vanessa Ezekowitz <vanessaezekowitz@gmail.com> | 2016-04-01 21:00:20 -0400 |
---|---|---|
committer | Vanessa Ezekowitz <vanessaezekowitz@gmail.com> | 2016-04-01 21:10:04 -0400 |
commit | 888b0ebfec8c2eff9015163549a7e47443cb8665 (patch) | |
tree | 915080159bfaa6ba6e226087c7ce0e8d5464b518 /inbox/init.lua | |
parent | da66780a569712c23ae4f2996cfb4608a9f9d69d (diff) | |
download | dreambuilder_modpack-888b0ebfec8c2eff9015163549a7e47443cb8665.tar dreambuilder_modpack-888b0ebfec8c2eff9015163549a7e47443cb8665.tar.gz dreambuilder_modpack-888b0ebfec8c2eff9015163549a7e47443cb8665.tar.bz2 dreambuilder_modpack-888b0ebfec8c2eff9015163549a7e47443cb8665.tar.xz dreambuilder_modpack-888b0ebfec8c2eff9015163549a7e47443cb8665.zip |
"explode" all modpacks into their individual components
(you can't have a modpack buried inside a modpack)
Diffstat (limited to 'inbox/init.lua')
-rw-r--r-- | inbox/init.lua | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/inbox/init.lua b/inbox/init.lua new file mode 100644 index 0000000..7e5867a --- /dev/null +++ b/inbox/init.lua @@ -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 |