This is an automated email from the git hooks/post-receive script. jpuydt-guest pushed a commit to branch master in repository minetest-mod-infinite-chest.
commit 6a62b850301b81cdd1a627a43e4f462e6dcb589e Author: Julien Puydt <julien.pu...@laposte.net> Date: Mon Sep 11 00:57:41 2017 +0200 New upstream version 1.0.0 --- LICENSE | 32 ++++++++ README.md | 31 +++++++ infinite_chest/api.lua | 200 +++++++++++++++++++++++++++++++++++++++++++++ infinite_chest/depends.txt | 1 + infinite_chest/init.lua | 70 ++++++++++++++++ modpack.txt | 0 6 files changed, 334 insertions(+) diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..ef9ddd5 --- /dev/null +++ b/LICENSE @@ -0,0 +1,32 @@ +Copyright (c) 2013, Brett O'Donnell http://cornernote.github.io +All rights reserved. + _____ _____ _____ _____ _____ _____ +| |___| __ | | |___| __ | | |___|_ _|___ +| --| . | -| | | | -_| -| | | | . | | | | -_| +|_____|___|__|__|_|___|___|__|__|_|___|___| |_| |___| + + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, this + list of conditions and the following disclaimer in the documentation and/or + other materials provided with the distribution. + +* Neither the name of the organization nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..f1e371b --- /dev/null +++ b/README.md @@ -0,0 +1,31 @@ +# Infinite Chest for Minetest + +Chests with slots that never run out. + + +## Features + +- Name your chest slots so you can easily find your items. +- Last accessed slot appears at the top of the list. + + +## Resources + +- **[Documentation](http://cornernote.github.io/minetest-infinite_chest)** +- **[GitHub Project](https://github.com/cornernote/minetest-infinite_chest)** +- **[Minetest Forum](http://minetest.net/forum/viewtopic.php?id=3099)** + +## Support + +- Does this README need improvement? Go ahead and [suggest a change](https://github.com/cornernote/minetest-infinite_chest/edit/master/README.md). +- Found a bug, or need help using this project? Check the [open issues](https://github.com/cornernote/minetest-infinite_chest/issues) or [create an issue](https://github.com/cornernote/minetest-infinite_chest/issues/new). + + +## About + +This module is open source, so it's distributed freely. If you find it useful then I ask not for your wealth, but simply to spare your time to consider the world we share by watching [Earthlings](http://earthlings.com/), a multi-award winning film available to watch online for free. A must-see for anyone who wishes to make the world a better place. + + +## License + +[BSD-3-Clause](https://raw.github.com/cornernote/minetest-infinite_chest/master/LICENSE), Copyright © 2013-2014 [Brett O'Donnell](http://cornernote.github.io/) diff --git a/infinite_chest/api.lua b/infinite_chest/api.lua new file mode 100644 index 0000000..485b9fe --- /dev/null +++ b/infinite_chest/api.lua @@ -0,0 +1,200 @@ +--[[ + +Infinite Chest for Minetest + +Copyright (c) 2012 cornernote, Brett O'Donnell <cornern...@gmail.com> +Source Code: https://github.com/cornernote/minetest-infinite_chest +License: GPLv3 + +API + +]]-- + + +infinite_chest = {} + +infinite_chest.log = function(message) + minetest.log("action", message) +end + +infinite_chest.formspec = function(pos,page) + local formspec = "size[15,11]" + .."button[12,10;1,0.5;go;Go]" + if page=="main" then + local meta = minetest.env:get_meta(pos) + local pages = infinite_chest.get_pages(meta) + local x,y = 0,0 + local p + for i = #pages,1,-1 do + p = pages[i] + x = x+2 + if x == 16 then + y = y+1 + x = 2 + end + formspec = formspec .."button["..(x-1.5)..","..(y+1)..";1.5,0.5;jump;"..p.."]" + end + if #pages == 0 then + formspec = formspec + .."label[4,3; --== Infinite Chest ==--]" + .."label[4,4.5; Create as many inventory slots as you like!]" + .."label[4,5.0; Simply enter a name for your inventory slot]" + .."label[4,5.5; then click Go.]" + end + return formspec + .."field[10.5,10.1;2,1;page;;]" + .."label[0,0;Infinite Chest]" + end + return formspec + .."field[10.5,10.1;2,1;page;;"..page.."]" + .."label[0,0;Infinite Chest - page: " .. page .. "]" + .."button[13,10;2,0.5;back;Back]" + .."button[13,6.5;2,0.5;delete;Delete]" + .."list[current_name;"..page..";0,1;15,5;]" + .."list[current_player;main;0,7;8,4;]" +end + +infinite_chest.get_pages = function(meta) + local invs = meta:get_string("infinite_chest_list") + local pages = {} + for p in string.gmatch(invs, "[^%s]+") do + table.insert(pages,p) + end + return pages +end + +infinite_chest.add_page = function(pos,page) + local meta = minetest.env:get_meta(pos) + local invs = meta:get_string("infinite_chest_list") + local pages = {} + for p in string.gmatch(invs, "[^%s]+") do + if page ~= p then + table.insert(pages,p) + end + end + table.insert(pages,page) + invs = "" + for i,p in pairs(pages) do + invs = invs .." ".. p + end + meta:set_string("infinite_chest_list",invs) + meta:get_inventory():set_size(page, 15*5) +end + +infinite_chest.remove_page = function(pos,page) + local meta = minetest.env:get_meta(pos) + local invs = meta:get_string("infinite_chest_list") + local inv = meta:get_inventory() + if not inv:is_empty(page) then + return + end + local pages = {} + for p in string.gmatch(invs, "[^%s]+") do + if page ~= p then + table.insert(pages,p) + end + end + invs = "" + for i,p in pairs(pages) do + invs = invs .." ".. p + end + meta:set_string("infinite_chest_list",invs) + return true +end + +infinite_chest.on_receive_fields = function(pos, formname, fields, sender) + local meta = minetest.env:get_meta(pos) + local page + if fields.go ~= nil and fields.page ~= "" then + page = string.lower(string.gsub(fields.page, "%W", "_")) + end + if fields.jump ~= nil then + page = fields.jump + end + if page ~= nil then + infinite_chest.add_page(pos,page) + meta:set_string("formspec", infinite_chest.formspec(pos,page)) + return + end + if fields.delete ~= nil then + if not infinite_chest.remove_page(pos,fields.page) then + minetest.chat_send_player(sender:get_player_name(), "cannot delete \""..fields.page.."\" - page is not empty") + return + end + end + meta:set_string("formspec", infinite_chest.formspec(pos,"main")) +end + +infinite_chest.on_construct = function(pos) + local meta = minetest.env:get_meta(pos) + meta:set_string("formspec", infinite_chest.formspec(pos,"main")) + meta:set_string("infotext", "Infinite Chest") +end + +infinite_chest.can_dig = function(pos,player) + local meta = minetest.env:get_meta(pos); + local pages = infinite_chest.get_pages(meta) + local inv = meta:get_inventory() + for i,page in pairs(pages) do + if not inv:is_empty(page) then + minetest.chat_send_player(player:get_player_name(), "cannot dig - page \""..page.."\" is not empty") + return false + end + end + return true +end + +infinite_chest.after_place_node = function(pos, placer) + local meta = minetest.env:get_meta(pos) + meta:set_string("owner", placer:get_player_name() or "") + meta:set_string("infotext", "Locked Infinite Chest (owned by "..meta:get_string("owner")..")") +end + +infinite_chest.allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) + local meta = minetest.env:get_meta(pos) + if not infinite_chest.has_locked_chest_privilege(meta, player) then + infinite_chest.log(player:get_player_name().." tried to access a locked chest belonging to "..meta:get_string("owner").." at "..minetest.pos_to_string(pos)) + return 0 + end + return count +end + +infinite_chest.allow_metadata_inventory_put = function(pos, listname, index, stack, player) + local meta = minetest.env:get_meta(pos) + if not infinite_chest.has_locked_chest_privilege(meta, player) then + infinite_chest.log(player:get_player_name().." tried to access a locked chest belonging to "..meta:get_string("owner").." at "..minetest.pos_to_string(pos)) + return 0 + end + return stack:get_count() +end + +infinite_chest.allow_metadata_inventory_take = function(pos, listname, index, stack, player) + local meta = minetest.env:get_meta(pos) + if not infinite_chest.has_locked_chest_privilege(meta, player) then + infinite_chest.log(player:get_player_name().. + " tried to access a locked chest belonging to ".. + meta:get_string("owner").." at ".. + minetest.pos_to_string(pos)) + return 0 + end + return stack:get_count() +end + +infinite_chest.has_locked_chest_privilege = function(meta, player) + if meta:get_string("owner") ~= "" and player:get_player_name() ~= meta:get_string("owner") then + return false + end + return true +end + +infinite_chest.on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) + infinite_chest.log(player:get_player_name().." moves stuff in infinite chest at "..minetest.pos_to_string(pos)) +end + +infinite_chest.on_metadata_inventory_put = function(pos, listname, index, stack, player) + infinite_chest.log(player:get_player_name().." moves stuff to infinite chest at "..minetest.pos_to_string(pos)) +end + +infinite_chest.on_metadata_inventory_take = function(pos, listname, index, stack, player) + infinite_chest.log(player:get_player_name().." takes stuff from infinite chest at "..minetest.pos_to_string(pos)) +end diff --git a/infinite_chest/depends.txt b/infinite_chest/depends.txt new file mode 100644 index 0000000..331d858 --- /dev/null +++ b/infinite_chest/depends.txt @@ -0,0 +1 @@ +default \ No newline at end of file diff --git a/infinite_chest/init.lua b/infinite_chest/init.lua new file mode 100644 index 0000000..1183b9c --- /dev/null +++ b/infinite_chest/init.lua @@ -0,0 +1,70 @@ +--[[ + +Infinite Chest for Minetest + +Copyright (c) 2012 cornernote, Brett O'Donnell <cornern...@gmail.com> +Source Code: https://github.com/cornernote/minetest-infinite_chest +License: GPLv3 + +MAIN LOADER + +]]-- + + +-- load api +dofile(minetest.get_modpath("infinite_chest").."/api.lua") + +-- register nodes +minetest.register_node("infinite_chest:chest", { + description = "Infinite Chest", + tiles = {"default_chest_top.png", "default_chest_top.png", "default_chest_side.png", "default_chest_side.png", "default_chest_side.png", "default_chest_front.png"}, + paramtype2 = "facedir", + groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2}, + legacy_facedir_simple = true, + sounds = default.node_sound_wood_defaults(), + can_dig = infinite_chest.can_dig, + on_construct = infinite_chest.on_construct, + on_receive_fields = infinite_chest.on_receive_fields, + on_metadata_inventory_move = infinite_chest.on_metadata_inventory_move, + on_metadata_inventory_put = infinite_chest.on_metadata_inventory_put, + on_metadata_inventory_take = infinite_chest.on_metadata_inventory_take, +}) +minetest.register_node("infinite_chest:chest_locked", { + description = "Locked Infinite Chest", + tiles = {"default_chest_top.png", "default_chest_top.png", "default_chest_side.png", "default_chest_side.png", "default_chest_side.png", "default_chest_lock.png"}, + paramtype2 = "facedir", + groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2}, + legacy_facedir_simple = true, + sounds = default.node_sound_wood_defaults(), + on_construct = infinite_chest.on_construct, + on_receive_fields = infinite_chest.on_receive_fields, + can_dig = infinite_chest.can_dig, + after_place_node = infinite_chest.after_place_node, + allow_metadata_inventory_move = infinite_chest.allow_metadata_inventory_move, + allow_metadata_inventory_put = infinite_chest.allow_metadata_inventory_put, + allow_metadata_inventory_take = infinite_chest.allow_metadata_inventory_take, + on_metadata_inventory_move = infinite_chest.on_metadata_inventory_move, + on_metadata_inventory_put = infinite_chest.on_metadata_inventory_put, + on_metadata_inventory_take = infinite_chest.on_metadata_inventory_take, +}) + +-- register crafts +minetest.register_craft({ + output = 'infinite_chest:chest', + recipe = { + {'default:chest', 'default:chest', 'default:chest'}, + {'default:chest', '', 'default:chest'}, + {'default:chest', 'default:chest', 'default:chest'}, + } +}) +minetest.register_craft({ + output = 'infinite_chest:chest_locked', + recipe = { + {'default:chest_locked', 'default:chest_locked', 'default:chest_locked'}, + {'default:chest_locked', 'default:mese', 'default:chest_locked'}, + {'default:chest_locked', 'default:chest_locked', 'default:chest_locked'}, + } +}) + +-- log that we started +minetest.log("action", "[MOD]"..minetest.get_current_modname().." -- loaded from "..minetest.get_modpath(minetest.get_current_modname())) \ No newline at end of file diff --git a/modpack.txt b/modpack.txt new file mode 100644 index 0000000..e69de29 -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/minetest-mod-infinite-chest.git _______________________________________________ Pkg-games-commits mailing list Pkg-games-commits@lists.alioth.debian.org http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-games-commits