123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454 |
- minetest.register_node('furniture:chest_small', {
- _doc_items_crafting = 'This is crafted in the Woodworking Station.',
- description = 'Small Chest',
- drawtype = 'mesh',
- mesh = 'furniture_chest_small.obj',
- tiles = {'furniture_chest_small.png'},
- overlay_tiles = {{name='furniture_chest_small_overlay.png', color='white'}},
- paramtype = 'light',
- paramtype2 = 'colorfacedir',
- palette = 'furniture_stain_palette.png',
- selection_box = {
- type = 'fixed',
- fixed = {-.4, -.5, -.3, .4, .2, .4},
- },
- collision_box = {
- type = 'fixed',
- fixed = {-.4, -.5, -.3, .4, .2, .4},
- },
- groups = {oddly_breakable_by_hand = 2, choppy=3, stainable=1},
- on_construct = function(pos)
- local meta = minetest.get_meta(pos)
- meta:set_string('formspec', furniture.storage_24_form(pos, ''))
- local inv = meta:get_inventory()
- inv:set_size('main', 24)
- end,
- can_dig = function(pos,player)
- local meta = minetest.get_meta(pos)
- local inv = meta:get_inventory()
- return inv:is_empty('main')
- end,
- on_receive_fields = function(pos, formname, fields, sender)
- local player_name = sender:get_player_name()
- if minetest.is_protected(pos, player_name) and not minetest.check_player_privs(sender, 'protection_bypass') then
- return
- end
- local meta = minetest.get_meta(pos)
- if fields ['save'] then
- meta:set_string('infotext', fields.description)
- meta:set_string('formspec', furniture.storage_24_form(pos, fields.description))
- elseif fields ['sort'] then
- furniture.sort_inventory(meta:get_inventory())
- end
- end,
- allow_metadata_inventory_put = furniture.inv_take_put,
- allow_metadata_inventory_take = furniture.inv_take_put,
- allow_metadata_inventory_move = furniture.inv_manipulate,
- })
- minetest.register_node('furniture:chest', {
- _doc_items_crafting = 'This is crafted in the Woodworking Station.',
- description = 'Chest',
- drawtype = 'mesh',
- mesh = 'furniture_chest.obj',
- tiles = {'furniture_chest.png'},
- overlay_tiles = {{name='furniture_chest_overlay.png', color='white'}},
- paramtype = 'light',
- paramtype2 = 'colorfacedir',
- palette = 'furniture_stain_palette.png',
- selection_box = {
- type = 'fixed',
- fixed = {-.45, -.5, -.4, .45, .4, .5},
- },
- collision_box = {
- type = 'fixed',
- fixed = {-.45, -.5, -.4, .45, .4, .5},
- },
- groups = {oddly_breakable_by_hand = 2, choppy=3, stainable=1},
- on_construct = function(pos)
- local meta = minetest.get_meta(pos)
- meta:set_string('formspec', furniture.storage_32_form(pos, ''))
- local inv = meta:get_inventory()
- inv:set_size('main', 32)
- end,
- can_dig = function(pos,player)
- local meta = minetest.get_meta(pos)
- local inv = meta:get_inventory()
- return inv:is_empty('main')
- end,
- on_receive_fields = function(pos, formname, fields, sender)
- local player_name = sender:get_player_name()
- if minetest.is_protected(pos, player_name) and not minetest.check_player_privs(sender, 'protection_bypass') then
- return
- end
- local meta = minetest.get_meta(pos)
- if fields ['save'] then
- meta:set_string('infotext', fields.description)
- meta:set_string('formspec', furniture.storage_32_form(pos, fields.description))
- elseif fields ['sort'] then
- furniture.sort_inventory(meta:get_inventory())
- end
- end,
- allow_metadata_inventory_put = furniture.inv_take_put,
- allow_metadata_inventory_take = furniture.inv_take_put,
- allow_metadata_inventory_move = furniture.inv_manipulate,
- })
- minetest.register_node('furniture:chest_large', {
- _doc_items_crafting = 'This is crafted in the Woodworking Station.',
- description = 'Large Chest',
- drawtype = 'mesh',
- mesh = 'furniture_chest_large.obj',
- tiles = {'furniture_chest_large.png'},
- overlay_tiles = {{name='furniture_chest_large_overlay.png', color='white'}},
- paramtype = 'light',
- paramtype2 = 'colorfacedir',
- palette = 'furniture_stain_palette.png',
- selection_box = {
- type = 'fixed',
- fixed = {-.5, -.5, -.4, 1.5, .3, .5},
- },
- collision_box = {
- type = 'fixed',
- fixed = {-.5, -.5, -.4, 1.5, .3, .5},
- },
- groups = {oddly_breakable_by_hand = 2, choppy=3, stainable=1},
- after_place_node = function(pos, placer, itemstack)
- if not epic.space_to_side(pos) then
- minetest.remove_node(pos)
- return itemstack
- end
- end,
- on_construct = function(pos)
- local meta = minetest.get_meta(pos)
- meta:set_string('formspec', furniture.storage_60_form(pos, ''))
- local inv = meta:get_inventory()
- inv:set_size('main', 60)
- end,
- after_dig_node = function(pos, oldnode, oldmetadata, digger)
- epic.remove_side_node(pos, oldnode)
- end,
- can_dig = function(pos,player)
- local meta = minetest.get_meta(pos)
- local inv = meta:get_inventory()
- return inv:is_empty('main')
- end,
- on_receive_fields = function(pos, formname, fields, sender)
- local player_name = sender:get_player_name()
- if minetest.is_protected(pos, player_name) and not minetest.check_player_privs(sender, 'protection_bypass') then
- return
- end
- local meta = minetest.get_meta(pos)
- if fields ['save'] then
- meta:set_string('infotext', fields.description)
- meta:set_string('formspec', furniture.storage_60_form(pos, fields.description))
- elseif fields ['sort'] then
- furniture.sort_inventory(meta:get_inventory())
- end
- end,
- on_rotate = function(pos, node)
- return false
- end,
- allow_metadata_inventory_put = furniture.inv_take_put,
- allow_metadata_inventory_take = furniture.inv_take_put,
- allow_metadata_inventory_move = furniture.inv_manipulate,
- })
- minetest.register_node('furniture:cabinet_wall', {
- _doc_items_crafting = 'This is crafted in the Woodworking Station.',
- description = 'Wall Mounted Cabinet',
- drawtype = 'mesh',
- mesh = 'furniture_cabinet_wall.obj',
- tiles = {'furniture_cabinet_wall.png'},
- paramtype = 'light',
- paramtype2 = 'colorfacedir',
- palette = 'furniture_stain_palette.png',
- selection_box = {
- type = 'fixed',
- fixed = {-.5, -.5, -.3, .5, .5, .5},
- },
- collision_box = {
- type = 'fixed',
- fixed = {-.5, -.5, -.3, .5, .5, .5},
- },
- groups = {oddly_breakable_by_hand = 2, choppy=3, stainable=1},
- on_construct = function(pos)
- local meta = minetest.get_meta(pos)
- meta:set_string('formspec', furniture.storage_24_form(pos, ''))
- local inv = meta:get_inventory()
- inv:set_size('main', 24)
- end,
- can_dig = function(pos,player)
- local meta = minetest.get_meta(pos)
- local inv = meta:get_inventory()
- return inv:is_empty('main')
- end,
- on_receive_fields = function(pos, formname, fields, sender)
- local player_name = sender:get_player_name()
- if minetest.is_protected(pos, player_name) and not minetest.check_player_privs(sender, 'protection_bypass') then
- return
- end
- local meta = minetest.get_meta(pos)
- if fields ['save'] then
- meta:set_string('infotext', fields.description)
- meta:set_string('formspec', furniture.storage_24_form(pos, fields.description))
- elseif fields ['sort'] then
- furniture.sort_inventory(meta:get_inventory())
- end
- end,
- allow_metadata_inventory_put = furniture.inv_take_put,
- allow_metadata_inventory_take = furniture.inv_take_put,
- allow_metadata_inventory_move = furniture.inv_manipulate,
- })
- minetest.register_node('furniture:cabinet_counter', {
- _doc_items_crafting = 'This is crafted in the Woodworking Station.',
- description = 'Cabinet with Countertop',
- drawtype = 'mesh',
- mesh = 'furniture_cabinet_counter.obj',
- tiles = {'furniture_cabinet_counter.png'},
- paramtype = 'light',
- paramtype2 = 'colorfacedir',
- palette = 'furniture_stain_palette.png',
- selection_box = {
- type = 'fixed',
- fixed = {-.5, -.5, -.5, .5, .5, .5},
- },
- collision_box = {
- type = 'fixed',
- fixed = {-.5, -.5, -.5, .5, .5, .5},
- },
- groups = {oddly_breakable_by_hand = 2, choppy=3, stainable=1},
- on_construct = function(pos)
- local meta = minetest.get_meta(pos)
- meta:set_string('formspec', furniture.storage_24_form(pos, ''))
- local inv = meta:get_inventory()
- inv:set_size('main', 24)
- end,
- can_dig = function(pos,player)
- local meta = minetest.get_meta(pos)
- local inv = meta:get_inventory()
- return inv:is_empty('main')
- end,
- on_receive_fields = function(pos, formname, fields, sender)
- local player_name = sender:get_player_name()
- if minetest.is_protected(pos, player_name) and not minetest.check_player_privs(sender, 'protection_bypass') then
- return
- end
- local meta = minetest.get_meta(pos)
- if fields ['save'] then
- meta:set_string('infotext', fields.description)
- meta:set_string('formspec', furniture.storage_24_form(pos, fields.description))
- elseif fields ['sort'] then
- furniture.sort_inventory(meta:get_inventory())
- end
- end,
- allow_metadata_inventory_put = furniture.inv_take_put,
- allow_metadata_inventory_take = furniture.inv_take_put,
- allow_metadata_inventory_move = furniture.inv_manipulate,
- })
- local bookshelf_formspec =
- "size[8,7;]" ..
- "list[context;books;0,0.3;8,2;]" ..
- "list[current_player;main;0,2.85;8,1;]" ..
- "list[current_player;main;0,4.08;8,3;8]" ..
- "listring[context;books]" ..
- "listring[current_player;main]" ..
- default.get_hotbar_bg(0,2.85)
- local function update_bookshelf(pos)
- local meta = minetest.get_meta(pos)
- local inv = meta:get_inventory()
- local invlist = inv:get_list("books")
- local formspec = bookshelf_formspec
- -- Inventory slots overlay
- local bx, by = 0, 0.3
- local n_written, n_empty = 0, 0
- for i = 1, 16 do
- if i == 9 then
- bx = 0
- by = by + 1
- end
- local stack = invlist[i]
- if stack:is_empty() then
- formspec = formspec ..
- "image[" .. bx .. "," .. by .. ";1,1;default_bookshelf_slot.png]"
- else
- local metatable = stack:get_meta():to_table() or {}
- if metatable.fields and metatable.fields.text then
- n_written = n_written + stack:get_count()
- else
- n_empty = n_empty + stack:get_count()
- end
- end
- bx = bx + 1
- end
- meta:set_string("formspec", formspec)
- if n_written + n_empty == 0 then
- meta:set_string("infotext", "Empty Locked Bookshelf")
- else
- meta:set_string("infotext", "Locked Bookshelf ("..n_written.." written, "..n_empty.." empty books)")
- end
- end
- minetest.register_node("furniture:bookshelf_locked", {
- description = 'Locked Bookshelf',
- tiles = {"default_wood.png", "default_wood.png", "default_wood.png",
- "default_wood.png", "default_bookshelf.png", "default_bookshelf.png"},
- paramtype2 = "facedir",
- is_ground_content = false,
- groups = {choppy = 3, oddly_breakable_by_hand = 2, flammable = 3},
- sounds = default.node_sound_wood_defaults(),
- on_construct = function(pos)
- local meta = minetest.get_meta(pos)
- local inv = meta:get_inventory()
- inv:set_size("books", 8 * 2)
- update_bookshelf(pos)
- end,
- can_dig = function(pos,player)
- local inv = minetest.get_meta(pos):get_inventory()
- return inv:is_empty("books")
- end,
- allow_metadata_inventory_put = function(pos, listname, index, stack, player)
- local player_name = player:get_player_name()
- if minetest.is_protected(pos, player_name) and not minetest.check_player_privs(player, 'protection_bypass') then
- return 0
- else
- if minetest.get_item_group(stack:get_name(), "book") ~= 0 then
- return stack:get_count()
- else
- return 0
- end
- end
- end,
- allow_metadata_inventory_take = furniture.inv_take_put,
- allow_metadata_inventory_move = furniture.inv_manipulate,
- on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
- minetest.log("action", player:get_player_name() ..
- " moves stuff in bookshelf at " .. minetest.pos_to_string(pos))
- update_bookshelf(pos)
- end,
- on_metadata_inventory_put = function(pos, listname, index, stack, player)
- minetest.log("action", player:get_player_name() ..
- " puts stuff to bookshelf at " .. minetest.pos_to_string(pos))
- update_bookshelf(pos)
- end,
- on_metadata_inventory_take = function(pos, listname, index, stack, player)
- minetest.log("action", player:get_player_name() ..
- " takes stuff from bookshelf at " .. minetest.pos_to_string(pos))
- update_bookshelf(pos)
- end,
- on_blast = function(pos)
- local drops = {}
- default.get_inventory_drops(pos, "books", drops)
- drops[#drops+1] = "furniture:bookshelf_locked"
- minetest.remove_node(pos)
- return drops
- end,
- })
- local vessels_shelf_formspec =
- "size[8,7;]" ..
- "list[context;vessels;0,0.3;8,2;]" ..
- "list[current_player;main;0,2.85;8,1;]" ..
- "list[current_player;main;0,4.08;8,3;8]" ..
- "listring[context;vessels]" ..
- "listring[current_player;main]" ..
- default.get_hotbar_bg(0, 2.85)
- local function update_vessels_shelf(pos)
- local meta = minetest.get_meta(pos)
- local inv = meta:get_inventory()
- local invlist = inv:get_list("vessels")
- local formspec = vessels_shelf_formspec
- -- Inventory slots overlay
- local vx, vy = 0, 0.3
- local n_items = 0
- for i = 1, 16 do
- if i == 9 then
- vx = 0
- vy = vy + 1
- end
- if not invlist or invlist[i]:is_empty() then
- formspec = formspec ..
- "image[" .. vx .. "," .. vy .. ";1,1;vessels_shelf_slot.png]"
- else
- local stack = invlist[i]
- if not stack:is_empty() then
- n_items = n_items + stack:get_count()
- end
- end
- vx = vx + 1
- end
- meta:set_string("formspec", formspec)
- if n_items == 0 then
- meta:set_string("infotext", "Empty Locked Vessels Shelf")
- else
- meta:set_string("infotext", "Locked Vessels Shelf ("..n_items.." items)")
- end
- end
- minetest.register_node("furniture:shelf_vessel_locked", {
- description = "Locked Vessels Shelf",
- tiles = {"default_wood.png", "default_wood.png", "default_wood.png",
- "default_wood.png", "vessels_shelf.png", "vessels_shelf.png"},
- paramtype2 = "facedir",
- is_ground_content = false,
- groups = {choppy = 3, oddly_breakable_by_hand = 2, flammable = 3},
- sounds = default.node_sound_wood_defaults(),
- on_construct = function(pos)
- local meta = minetest.get_meta(pos)
- update_vessels_shelf(pos)
- local inv = meta:get_inventory()
- inv:set_size("vessels", 8 * 2)
- end,
- can_dig = function(pos,player)
- local inv = minetest.get_meta(pos):get_inventory()
- return inv:is_empty("vessels")
- end,
- allow_metadata_inventory_take = furniture.inv_take_put,
- allow_metadata_inventory_move = furniture.inv_manipulate,
- allow_metadata_inventory_put = function(pos, listname, index, stack, player)
- local player_name = player:get_player_name()
- if minetest.is_protected(pos, player_name) and not minetest.check_player_privs(player, 'protection_bypass') then
- return 0
- else
- if minetest.get_item_group(stack:get_name(), "vessel") ~= 0 then
- return stack:get_count()
- else
- return 0
- end
- end
- end,
- on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
- minetest.log("action", player:get_player_name() ..
- " moves stuff in vessels shelf at ".. minetest.pos_to_string(pos))
- update_vessels_shelf(pos)
- end,
- on_metadata_inventory_put = function(pos, listname, index, stack, player)
- minetest.log("action", player:get_player_name() ..
- " moves stuff to vessels shelf at ".. minetest.pos_to_string(pos))
- update_vessels_shelf(pos)
- end,
- on_metadata_inventory_take = function(pos, listname, index, stack, player)
- minetest.log("action", player:get_player_name() ..
- " takes stuff from vessels shelf at ".. minetest.pos_to_string(pos))
- update_vessels_shelf(pos)
- end,
- on_blast = function(pos)
- local drops = {}
- default.get_inventory_drops(pos, "vessels", drops)
- drops[#drops + 1] = "vessels:shelf"
- minetest.remove_node(pos)
- return drops
- end,
- })
|