├── .gitignore ├── LICENSE ├── README.md ├── bags ├── depends.txt ├── init.lua ├── inventory_plus.lua ├── mod.conf ├── screenshot.png ├── sfinv.lua └── textures │ ├── bags_large.png │ ├── bags_medium.png │ └── bags_small.png ├── bower.json └── modpack.txt /.gitignore: -------------------------------------------------------------------------------- 1 | # Eclipse project files 2 | .project 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013, Brett O'Donnell http://cornernote.github.io 2 | All rights reserved. 3 | _____ _____ _____ _____ _____ _____ 4 | | |___| __ | | |___| __ | | |___|_ _|___ 5 | | --| . | -| | | | -_| -| | | | . | | | | -_| 6 | |_____|___|__|__|_|___|___|__|__|_|___|___| |_| |___| 7 | 8 | 9 | Redistribution and use in source and binary forms, with or without modification, 10 | are permitted provided that the following conditions are met: 11 | 12 | * Redistributions of source code must retain the above copyright notice, this 13 | list of conditions and the following disclaimer. 14 | 15 | * Redistributions in binary form must reproduce the above copyright notice, this 16 | list of conditions and the following disclaimer in the documentation and/or 17 | other materials provided with the distribution. 18 | 19 | * Neither the name of the organization nor the names of its 20 | contributors may be used to endorse or promote products derived from 21 | this software without specific prior written permission. 22 | 23 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 24 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 27 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 30 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 32 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Bags for Minetest 2 | 3 | [![home](https://img.shields.io/badge/bags-home-blue.svg?style=flat-square)](https://cornernote.github.io/minetest-bags/) 4 | [![download](https://img.shields.io/github/tag/cornernote/minetest-bags.svg?style=flat-square&label=release)](https://github.com/cornernote/minetest-bags/archive/master.zip) 5 | [![git](https://img.shields.io/badge/git-project-green.svg?style=flat-square)](https://github.com/cornernote/minetest-bags) 6 | [![forum](https://img.shields.io/badge/minetest-mod-green.svg?style=flat-square)](http://forum.minetest.net/viewtopic.php?f=11&t=3081) 7 | [![bower](https://img.shields.io/badge/bower-mod-green.svg?style=flat-square)](https://minetest-bower.herokuapp.com/mods/bags) 8 | 9 | ## Description 10 | 11 | Allows players to craft and attach bags to their inventory to increase player item storage capacity. 12 | 13 | ## Features 14 | 15 | - Bags are available in inventory. 16 | - Multiple sized bags. 17 | - Bags store items permanently with the player. 18 | 19 | 20 | ## Project Resources 21 | 22 | * [Home](https://cornernote.github.io/minetest-bags/) 23 | * [Download](https://github.com/cornernote/minetest-bags/archive/master.zip) 24 | * [Project](https://github.com/cornernote/minetest-bags) 25 | * [Forum](http://forum.minetest.net/viewtopic.php?f=11&t=3081) 26 | * [Bower](https://minetest-bower.herokuapp.com/mods/bags) 27 | 28 | 29 | ## Support 30 | 31 | - Does this README need improvement? Go ahead and [suggest a change](https://github.com/cornernote/minetest-bags/edit/master/README.md). 32 | - Found a bug, or need help using this project? Check the [open issues](https://github.com/cornernote/minetest-bags/issues) or [create an issue](https://github.com/cornernote/minetest-bags/issues/new). 33 | 34 | 35 | ## About 36 | 37 | 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. 38 | 39 | 40 | ## Credits 41 | 42 | - Tonyka - created the amazing bag textures 43 | 44 | 45 | ## License 46 | 47 | [BSD-3-Clause](https://raw.github.com/cornernote/minetest-bags/master/LICENSE), Copyright © 2013-2014 [Brett O'Donnell](http://cornernote.github.io/) 48 | -------------------------------------------------------------------------------- /bags/depends.txt: -------------------------------------------------------------------------------- 1 | default 2 | inventory_plus? 3 | sfinv? 4 | -------------------------------------------------------------------------------- /bags/init.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | 3 | Bags for Minetest 4 | 5 | Copyright (c) 2012 cornernote, Brett O'Donnell 6 | Source Code: https://github.com/cornernote/minetest-bags 7 | License: BSD-3-Clause https://raw.github.com/cornernote/minetest-bags/master/LICENSE 8 | 9 | ]]-- 10 | 11 | 12 | local use_sfinv = false 13 | if not core.global_exists("inventory_plus") and core.global_exists("sfinv") then 14 | use_sfinv = true 15 | else 16 | local use_sfinv = (core.global_exists("sfinv") and core.settings:get("inventory") == "sfinv") or false 17 | end 18 | 19 | -- register_on_joinplayer 20 | minetest.register_on_joinplayer(function(player) 21 | local player_inv = player:get_inventory() 22 | local bags_inv = minetest.create_detached_inventory(player:get_player_name().."_bags",{ 23 | on_put = function(inv, listname, index, stack, player) 24 | player:get_inventory():set_stack(listname, index, stack) 25 | player:get_inventory():set_size(listname.."contents", stack:get_definition().groups.bagslots) 26 | end, 27 | on_take = function(inv, listname, index, stack, player) 28 | player:get_inventory():set_stack(listname, index, nil) 29 | end, 30 | allow_put = function(inv, listname, index, stack, player) 31 | if stack:get_definition().groups.bagslots then 32 | return 1 33 | else 34 | return 0 35 | end 36 | end, 37 | allow_take = function(inv, listname, index, stack, player) 38 | if player:get_inventory():is_empty(listname.."contents")==true then 39 | return stack:get_count() 40 | else 41 | return 0 42 | end 43 | end, 44 | allow_move = function(inv, from_list, from_index, to_list, to_index, count, player) 45 | return 0 46 | end, 47 | }) 48 | for i=1,4 do 49 | local bag = "bag"..i 50 | player_inv:set_size(bag, 1) 51 | bags_inv:set_size(bag, 1) 52 | bags_inv:set_stack(bag,1,player_inv:get_stack(bag,1)) 53 | end 54 | end) 55 | 56 | 57 | -- register bag tools 58 | minetest.register_tool("bags:small", { 59 | description = "Small Bag", 60 | inventory_image = "bags_small.png", 61 | groups = {bagslots=8}, 62 | }) 63 | minetest.register_tool("bags:medium", { 64 | description = "Medium Bag", 65 | inventory_image = "bags_medium.png", 66 | groups = {bagslots=16}, 67 | }) 68 | minetest.register_tool("bags:large", { 69 | description = "Large Bag", 70 | inventory_image = "bags_large.png", 71 | groups = {bagslots=24}, 72 | }) 73 | 74 | -- register bag crafts 75 | minetest.register_craft({ 76 | output = "bags:small", 77 | recipe = { 78 | {"", "default:stick", ""}, 79 | {"default:wood", "default:wood", "default:wood"}, 80 | {"default:wood", "default:wood", "default:wood"}, 81 | }, 82 | }) 83 | minetest.register_craft({ 84 | output = "bags:medium", 85 | recipe = { 86 | {"bags:small", "bags:small"}, 87 | {"bags:small", "bags:small"}, 88 | }, 89 | }) 90 | minetest.register_craft({ 91 | output = "bags:large", 92 | recipe = { 93 | {"bags:medium", "bags:medium"}, 94 | {"bags:medium", "bags:medium"}, 95 | }, 96 | }) 97 | if use_sfinv then 98 | dofile(minetest.get_modpath(minetest.get_current_modname()) .. "/sfinv.lua") 99 | else 100 | dofile(minetest.get_modpath(minetest.get_current_modname()) .. "/inventory_plus.lua") 101 | end 102 | 103 | -- log that we started 104 | minetest.log("action", "[MOD]"..minetest.get_current_modname().." -- loaded from "..minetest.get_modpath(minetest.get_current_modname())) 105 | -------------------------------------------------------------------------------- /bags/inventory_plus.lua: -------------------------------------------------------------------------------- 1 | -- get_formspec 2 | local get_formspec = function(player,page) 3 | if page=="bags" then 4 | return "size[8,7.5]" 5 | .."list[current_player;main;0,3.5;8,4;]" 6 | .."button[0,0;2,0.5;main;Back]" 7 | .."button[0,2;2,0.5;bag1;Bag 1]" 8 | .."button[2,2;2,0.5;bag2;Bag 2]" 9 | .."button[4,2;2,0.5;bag3;Bag 3]" 10 | .."button[6,2;2,0.5;bag4;Bag 4]" 11 | .."list[detached:"..player:get_player_name().."_bags;bag1;0.5,1;1,1;]" 12 | .."list[detached:"..player:get_player_name().."_bags;bag2;2.5,1;1,1;]" 13 | .."list[detached:"..player:get_player_name().."_bags;bag3;4.5,1;1,1;]" 14 | .."list[detached:"..player:get_player_name().."_bags;bag4;6.5,1;1,1;]" 15 | end 16 | for i=1,4 do 17 | if page=="bag"..i then 18 | local image = player:get_inventory():get_stack("bag"..i, 1):get_definition().inventory_image 19 | return "size[8,8.5]" 20 | .."list[current_player;main;0,4.5;8,4;]" 21 | .."button[0,0;2,0.5;main;Main]" 22 | .."button[2,0;2,0.5;bags;Bags]" 23 | .."image[7,0;1,1;"..image.."]" 24 | .."list[current_player;bag"..i.."contents;0,1;8,3;]" 25 | .."listring[current_name;bag"..i.."contents]" 26 | .."listring[current_player;main]" 27 | end 28 | end 29 | end 30 | 31 | -- register_on_player_receive_fields 32 | minetest.register_on_player_receive_fields(function(player, formname, fields) 33 | if fields.bags then 34 | inventory_plus.set_inventory_formspec(player, get_formspec(player,"bags")) 35 | return 36 | end 37 | 38 | for i=1,4 do 39 | local page = "bag"..i 40 | if fields[page] then 41 | if player:get_inventory():get_stack(page, 1):get_definition().groups.bagslots==nil then 42 | page = "bags" 43 | end 44 | 45 | inventory_plus.set_inventory_formspec(player, get_formspec(player,page)) 46 | return 47 | end 48 | end 49 | end) 50 | 51 | -- register_on_joinplayer 52 | minetest.register_on_joinplayer(function(player) 53 | inventory_plus.register_button(player,"bags","Bags") 54 | end) 55 | 56 | -------------------------------------------------------------------------------- /bags/mod.conf: -------------------------------------------------------------------------------- 1 | name = bags 2 | description = Allows players to craft and attach bags to their inventory to increase player item storage capacity. 3 | version = 1.0.1 4 | depends = default 5 | optional_depends = inventory_plus, sfinv 6 | -------------------------------------------------------------------------------- /bags/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cornernote/minetest-bags/769685fceae66fc94b6c4e2548ab47eea897a94b/bags/screenshot.png -------------------------------------------------------------------------------- /bags/sfinv.lua: -------------------------------------------------------------------------------- 1 | sfinv.register_page("bags:bags", { 2 | title = "Bags", 3 | get = function(self, player, context) 4 | local bags_inv = "" 5 | if context.bags_page == nil or context.bags_page == "bags" then 6 | bags_inv = "button[0,2;2,0.5;bag1;Bag 1]" 7 | .."button[2,2;2,0.5;bag2;Bag 2]" 8 | .."button[4,2;2,0.5;bag3;Bag 3]" 9 | .."button[6,2;2,0.5;bag4;Bag 4]" 10 | .."list[detached:"..player:get_player_name().."_bags;bag1;0.5,1;1,1;]" 11 | .."list[detached:"..player:get_player_name().."_bags;bag2;2.5,1;1,1;]" 12 | .."list[detached:"..player:get_player_name().."_bags;bag3;4.5,1;1,1;]" 13 | .."list[detached:"..player:get_player_name().."_bags;bag4;6.5,1;1,1;]" 14 | else 15 | for i=1,4 do 16 | if context.bags_page=="bag"..i then 17 | local image = player:get_inventory():get_stack("bag"..i, 1):get_definition().inventory_image 18 | bags_inv = "button[2,0;2,0.5;bags_return;Return]" 19 | .."image[7,0;1,1;"..image.."]" 20 | .."list[current_player;bag"..i.."contents;0,1;8,3;]" 21 | .."listring[current_name;bag"..i.."contents]" 22 | .."listring[current_player;main]" 23 | end 24 | end 25 | end 26 | 27 | local formspec = sfinv.make_formspec(player, context, bags_inv, true) 28 | return formspec 29 | end, 30 | on_player_receive_fields = function(self, player, context, fields) 31 | if fields.bags_return then 32 | context.bags_page = "bags" 33 | sfinv.set_player_inventory_formspec(player) 34 | return true 35 | end 36 | 37 | for i=1,4 do 38 | local page = "bag"..i 39 | if fields[page] then 40 | if player:get_inventory():get_stack(page, 1):get_definition().groups.bagslots==nil then 41 | context.bags_page = "bags" 42 | else 43 | context.bags_page = page 44 | end 45 | sfinv.set_player_inventory_formspec(player) 46 | return true 47 | end 48 | end 49 | return false 50 | end 51 | }) 52 | -------------------------------------------------------------------------------- /bags/textures/bags_large.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cornernote/minetest-bags/769685fceae66fc94b6c4e2548ab47eea897a94b/bags/textures/bags_large.png -------------------------------------------------------------------------------- /bags/textures/bags_medium.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cornernote/minetest-bags/769685fceae66fc94b6c4e2548ab47eea897a94b/bags/textures/bags_medium.png -------------------------------------------------------------------------------- /bags/textures/bags_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cornernote/minetest-bags/769685fceae66fc94b6c4e2548ab47eea897a94b/bags/textures/bags_small.png -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "bags", 3 | "homepage": "https://cornernote.github.io/minetest-bags/", 4 | "description": "Attach bags to your inventory to increase item storage capacity.", 5 | "screenshots": [ 6 | "https://cornernote.github.io/minetest-bags/img/screenshot.png" 7 | ], 8 | "keywords": [ 9 | "bags", 10 | "inventory", 11 | "player", 12 | "formspec" 13 | ], 14 | "authors": [ 15 | "cornernote" 16 | ], 17 | "license": "BSD-3-Clause", 18 | "dependencies": { 19 | "inventory_plus": "~1.0.0" 20 | }, 21 | "ignore": [ 22 | "**/.*" 23 | ] 24 | } 25 | -------------------------------------------------------------------------------- /modpack.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cornernote/minetest-bags/769685fceae66fc94b6c4e2548ab47eea897a94b/modpack.txt --------------------------------------------------------------------------------