├── .gitignore ├── LICENSE ├── README.md ├── bower.json ├── inventory_plus ├── depends.txt ├── init.lua └── screenshot.png └── 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 | # Inventory Plus for Minetest 2 | 3 | [![home](https://img.shields.io/badge/inventory_plus-home-blue.svg?style=flat-square)](http://cornernote.github.io/minetest-inventory_plus/) 4 | [![download](https://img.shields.io/github/tag/cornernote/minetest-inventory_plus.svg?style=flat-square&label=release)](https://github.com/cornernote/minetest-inventory_plus/archive/master.zip) 5 | [![git](https://img.shields.io/badge/git-project-green.svg?style=flat-square)](https://github.com/cornernote/minetest-inventory_plus) 6 | [![forum](https://img.shields.io/badge/minetest-mod-green.svg?style=flat-square)](http://forum.minetest.net/viewtopic.php?t=6204) 7 | [![bower](https://img.shields.io/badge/bower-mod-green.svg?style=flat-square)](https://minetest-bower.herokuapp.com/mods/inventory_plus) 8 | 9 | 10 | ## Description 11 | 12 | Allows additional formspec buttons to be added to the player inventory. 13 | 14 | 15 | ## Features 16 | 17 | - Allows additional formspec buttons to be added to the player inventory screen. 18 | - These are processed by your own mod, they can show other formspec screens, or perform in game functionality. 19 | - Adds support for refill/trash to Creative Inventory. 20 | 21 | 22 | ## Project Resources 23 | 24 | * [Home](http://cornernote.github.io/minetest-inventory_plus/) 25 | * [Download](https://github.com/cornernote/minetest-inventory_plus/archive/master.zip) 26 | * [Project](https://github.com/cornernote/minetest-inventory_plus) 27 | * [Forum](http://forum.minetest.net/viewtopic.php?t=6204) 28 | * [Bower](https://minetest-bower.herokuapp.com/mods/inventory_plus) 29 | 30 | 31 | ## Support 32 | 33 | - Does this README need improvement? Go ahead and [suggest a change](https://github.com/cornernote/minetest-inventory_plus/edit/master/README.md). 34 | - Found a bug, or need help using this project? Check the [open issues](https://github.com/cornernote/minetest-inventory_plus/issues) or [create an issue](https://github.com/cornernote/minetest-inventory_plus/issues/new). 35 | 36 | 37 | ## About 38 | 39 | 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. 40 | 41 | 42 | ## License 43 | 44 | [BSD-3-Clause](https://raw.github.com/cornernote/minetest-inventory_plus/master/LICENSE), Copyright © 2013-2014 [Brett O'Donnell](http://cornernote.github.io/) 45 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "inventory_plus", 3 | "description": "Allows additional formspec buttons to be added to the player inventory screen.", 4 | "keywords": [ 5 | "inventory", 6 | "player", 7 | "formspec" 8 | ], 9 | "homepage": "http://cornernote.github.io/minetest-inventory_plus/", 10 | "forum": "http://forum.minetest.net/viewtopic.php?t=6204", 11 | "screenshots": [ 12 | "http://cornernote.github.io/minetest-inventory_plus/img/screenshot.png" 13 | ], 14 | "authors": [ 15 | "cornernote" 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /inventory_plus/depends.txt: -------------------------------------------------------------------------------- 1 | default 2 | creative 3 | -------------------------------------------------------------------------------- /inventory_plus/init.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | 3 | Inventory Plus for Minetest 4 | 5 | Copyright (c) 2012 cornernote, Brett O'Donnell 6 | Source Code: https://github.com/cornernote/minetest-inventory_plus 7 | License: BSD-3-Clause https://raw.github.com/cornernote/minetest-inventory_plus/master/LICENSE 8 | 9 | Edited by TenPlus1 (23rd March 2016) 10 | 11 | ]]-- 12 | 13 | -- expose api 14 | inventory_plus = {} 15 | 16 | -- define buttons 17 | inventory_plus.buttons = {} 18 | 19 | -- default inventory page 20 | inventory_plus.default = minetest.settings:get("inventory_default") or "craft" 21 | 22 | -- register_button 23 | inventory_plus.register_button = function(player, name, label) 24 | 25 | local player_name = player:get_player_name() 26 | 27 | if inventory_plus.buttons[player_name] == nil then 28 | inventory_plus.buttons[player_name] = {} 29 | end 30 | 31 | inventory_plus.buttons[player_name][name] = label 32 | end 33 | 34 | -- set_inventory_formspec 35 | inventory_plus.set_inventory_formspec = function(player, formspec) 36 | 37 | -- error checking 38 | if not formspec then 39 | return 40 | end 41 | 42 | if minetest.settings:get_bool("creative_mode") then 43 | 44 | -- if creative mode is on then wait a bit 45 | minetest.after(0.01,function() 46 | player:set_inventory_formspec(formspec) 47 | end) 48 | else 49 | player:set_inventory_formspec(formspec) 50 | end 51 | end 52 | 53 | -- create detached inventory for trashcan 54 | local trashInv = minetest.create_detached_inventory( 55 | "trash", { 56 | on_put = function(inv, toList, toIndex, stack, player) 57 | inv:set_stack(toList, toIndex, ItemStack(nil)) 58 | end 59 | }) 60 | 61 | trashInv:set_size("main", 1) 62 | 63 | -- get_formspec 64 | inventory_plus.get_formspec = function(player, page) 65 | 66 | if not player then 67 | return 68 | end 69 | 70 | -- default inventory page 71 | local formspec = "size[8,7.5]" 72 | .. default.gui_bg 73 | .. default.gui_bg_img 74 | .. default.gui_slots 75 | .. "list[current_player;main;0,3.5;8,4;]" 76 | 77 | -- craft page 78 | if page == "craft" then 79 | 80 | local inv = player:get_inventory() or nil 81 | 82 | if not inv then 83 | print ("NO INVENTORY FOUND") 84 | return 85 | end 86 | 87 | formspec = formspec 88 | .. "button[0,1;2,0.5;main;Back]" 89 | .. "list[current_player;craftpreview;7,1;1,1;]" 90 | .. "list[current_player;craft;3,0;3,3;]" 91 | .. "listring[current_name;craft]" 92 | .. "listring[current_player;main]" 93 | -- trash icon 94 | .. "list[detached:trash;main;1,2;1,1;]" 95 | .. "image[1.1,2.1;0.8,0.8;creative_trash_icon.png]" 96 | end 97 | 98 | -- creative page 99 | if page == "creative" then 100 | 101 | return player:get_inventory_formspec() 102 | .. "button[5.4,4.2;2.65,0.3;main;Back]" 103 | end 104 | 105 | -- main page 106 | if page == "main" then 107 | 108 | -- buttons 109 | local x, y = 0, 1 110 | 111 | for k, v in pairs(inventory_plus.buttons[player:get_player_name()]) do 112 | 113 | formspec = formspec .. "button[" .. x .. "," 114 | .. y .. ";2,0.5;" .. k .. ";" .. v .. "]" 115 | 116 | x = x + 2 117 | 118 | if x == 8 then 119 | x = 0 120 | y = y + 1 121 | end 122 | end 123 | end 124 | 125 | return formspec 126 | end 127 | 128 | -- register_on_joinplayer 129 | minetest.register_on_joinplayer(function(player) 130 | 131 | inventory_plus.register_button(player,"craft", "Craft") 132 | 133 | if minetest.settings:get_bool("creative_mode") then 134 | inventory_plus.register_button(player, "creative_prev", "Creative") 135 | end 136 | 137 | minetest.after(1, function() 138 | 139 | inventory_plus.set_inventory_formspec(player, 140 | inventory_plus.get_formspec(player, inventory_plus.default)) 141 | end) 142 | end) 143 | 144 | -- register_on_player_receive_fields 145 | minetest.register_on_player_receive_fields(function(player, formname, fields) 146 | 147 | -- main 148 | 149 | if fields.main then 150 | 151 | inventory_plus.set_inventory_formspec(player, 152 | inventory_plus.get_formspec(player, "main")) 153 | 154 | return 155 | end 156 | 157 | -- craft 158 | if fields.craft then 159 | 160 | inventory_plus.set_inventory_formspec(player, 161 | inventory_plus.get_formspec(player, "craft")) 162 | 163 | return 164 | end 165 | 166 | -- creative 167 | if fields.creative_prev 168 | or fields.creative_next then 169 | 170 | minetest.after(0.1, function() 171 | 172 | inventory_plus.set_inventory_formspec(player, 173 | inventory_plus.get_formspec(player, "creative")) 174 | end) 175 | 176 | return 177 | end 178 | end) 179 | -------------------------------------------------------------------------------- /inventory_plus/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cornernote/minetest-inventory_plus/fd71e3d42b425448297e480a4e0bbf29f9b78572/inventory_plus/screenshot.png -------------------------------------------------------------------------------- /modpack.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cornernote/minetest-inventory_plus/fd71e3d42b425448297e480a4e0bbf29f9b78572/modpack.txt --------------------------------------------------------------------------------