Add "bags" mod.

master
AntumDeluge 2016-08-05 16:53:02 -07:00
parent 36411cb39b
commit 7a008a9490
13 changed files with 420 additions and 0 deletions

View File

@ -29,6 +29,8 @@ The following mods are also included:
* [chatlog][] ([CC0](mods/chat/chatlog/Readme.txt))
* crafting/
* [craft_guide][] ([BSD 3-Clause](mods/crafting/craft_guide/LICENSE))
* display/
* [inventory_plus][] ([BSD 3-Clause](mods/display/inventory_plus/LICENSE))
* farming/
* [farming_plus][] ([WTFPL](mods/farming/farming_plus/README.txt))
* friendlies/
@ -89,6 +91,7 @@ The following mods are also included:
* [carts][] ([WTFPL/CC0](mods/transport/carts/README.txt))
* [helicopter][] ([GPL](mods/transport/helicopter/LICENSE) / [CC-BY-NC](mods/transport/helicopter/README.md))
* ui/
* [bags][] ([BSD 3-Clause](mods/display/bags/LICENSE))
* [compass][] (CC-BY-SA / WTFPL)
* weather/
* [lightning][] ([LGPL/CC-BY-SA](mods/weather/lightning/README.md))
@ -109,6 +112,7 @@ The following mods are also included:
[areas]: https://forum.minetest.net/viewtopic.php?t=7239
[awards]: https://forum.minetest.net/viewtopic.php?t=4870
[away]: https://forum.minetest.net/viewtopic.php?t=1211
[bags]:
[biome_lib]: https://forum.minetest.net/viewtopic.php?f=11&t=12999
[carts]: https://forum.minetest.net/viewtopic.php?t=2451
[character_creator]: https://forum.minetest.net/viewtopic.php?f=9&t=13138
@ -123,6 +127,7 @@ The following mods are also included:
[glow]: https://forum.minetest.net/viewtopic.php?t=6300
[helicopter]: https://forum.minetest.net/viewtopic.php?t=6183
[homedecor]: https://forum.minetest.net/viewtopic.php?t=2041
[inventory_plus]: https://forum.minetest.net/viewtopic.php?t=3100
[kpgmobs]: https://forum.minetest.net/viewtopic.php?t=8798
[lightning]: https://forum.minetest.net/viewtopic.php?t=13886
[mesecons]: https://forum.minetest.net/viewtopic.php?t=628

32
mods/display/bags/LICENSE Normal file
View File

@ -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.

View File

@ -0,0 +1,38 @@
# Bags for Minetest
Allows players to craft and attach bags to their inventory to increase player item storage capacity.
## Features
- Bags are available in inventory.
- Multiple sized bags.
- Bags store items permanently with the player.
## Resources
- **[Documentation](http://cornernote.github.io/minetest-bags)**
- **[GitHub Project](https://github.com/cornernote/minetest-bags)**
- **[Minetest Forum](https://forum.minetest.net/viewtopic.php?id=3081)**
## Support
- Does this README need improvement? Go ahead and [suggest a change](https://github.com/cornernote/minetest-bags/edit/master/README.md).
- 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).
## 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.
## Credits
- Tonyka - created the amazing bag textures
## License
[BSD-3-Clause](https://raw.github.com/cornernote/minetest-bags/master/LICENSE), Copyright © 2013-2014 [Brett O'Donnell](http://cornernote.github.io/)

View File

@ -0,0 +1,2 @@
default
inventory_plus

138
mods/display/bags/init.lua Normal file
View File

@ -0,0 +1,138 @@
--[[
Bags for Minetest
Copyright (c) 2012 cornernote, Brett O'Donnell <cornernote@gmail.com>
Source Code: https://github.com/cornernote/minetest-bags
License: BSD-3-Clause https://raw.github.com/cornernote/minetest-bags/master/LICENSE
]]--
-- get_formspec
local get_formspec = function(player,page)
if page=="bags" then
return "size[8,7.5]"
.."list[current_player;main;0,3.5;8,4;]"
.."button[0,0;2,0.5;main;Back]"
.."button[0,2;2,0.5;bag1;Bag 1]"
.."button[2,2;2,0.5;bag2;Bag 2]"
.."button[4,2;2,0.5;bag3;Bag 3]"
.."button[6,2;2,0.5;bag4;Bag 4]"
.."list[detached:"..player:get_player_name().."_bags;bag1;0.5,1;1,1;]"
.."list[detached:"..player:get_player_name().."_bags;bag2;2.5,1;1,1;]"
.."list[detached:"..player:get_player_name().."_bags;bag3;4.5,1;1,1;]"
.."list[detached:"..player:get_player_name().."_bags;bag4;6.5,1;1,1;]"
end
for i=1,4 do
if page=="bag"..i then
local image = player:get_inventory():get_stack("bag"..i, 1):get_definition().inventory_image
return "size[8,8.5]"
.."list[current_player;main;0,4.5;8,4;]"
.."button[0,0;2,0.5;main;Main]"
.."button[2,0;2,0.5;bags;Bags]"
.."image[7,0;1,1;"..image.."]"
.."list[current_player;bag"..i.."contents;0,1;8,3;]"
end
end
end
-- register_on_player_receive_fields
minetest.register_on_player_receive_fields(function(player, formname, fields)
if fields.bags then
inventory_plus.set_inventory_formspec(player, get_formspec(player,"bags"))
return
end
for i=1,4 do
local page = "bag"..i
if fields[page] then
if player:get_inventory():get_stack(page, 1):get_definition().groups.bagslots==nil then
page = "bags"
end
inventory_plus.set_inventory_formspec(player, get_formspec(player,page))
return
end
end
end)
-- register_on_joinplayer
minetest.register_on_joinplayer(function(player)
inventory_plus.register_button(player,"bags","Bags")
local player_inv = player:get_inventory()
local bags_inv = minetest.create_detached_inventory(player:get_player_name().."_bags",{
on_put = function(inv, listname, index, stack, player)
player:get_inventory():set_stack(listname, index, stack)
player:get_inventory():set_size(listname.."contents", stack:get_definition().groups.bagslots)
end,
on_take = function(inv, listname, index, stack, player)
player:get_inventory():set_stack(listname, index, nil)
end,
allow_put = function(inv, listname, index, stack, player)
if stack:get_definition().groups.bagslots then
return 1
else
return 0
end
end,
allow_take = function(inv, listname, index, stack, player)
if player:get_inventory():is_empty(listname.."contents")==true then
return stack:get_count()
else
return 0
end
end,
allow_move = function(inv, from_list, from_index, to_list, to_index, count, player)
return 0
end,
})
for i=1,4 do
local bag = "bag"..i
player_inv:set_size(bag, 1)
bags_inv:set_size(bag, 1)
bags_inv:set_stack(bag,1,player_inv:get_stack(bag,1))
end
end)
-- register bag tools
minetest.register_tool("bags:small", {
description = "Small Bag",
inventory_image = "bags_small.png",
groups = {bagslots=8},
})
minetest.register_tool("bags:medium", {
description = "Medium Bag",
inventory_image = "bags_medium.png",
groups = {bagslots=16},
})
minetest.register_tool("bags:large", {
description = "Large Bag",
inventory_image = "bags_large.png",
groups = {bagslots=24},
})
-- register bag crafts
minetest.register_craft({
output = "bags:small",
recipe = {
{"", "default:stick", ""},
{"default:wood", "default:wood", "default:wood"},
{"default:wood", "default:wood", "default:wood"},
},
})
minetest.register_craft({
output = "bags:medium",
recipe = {
{"bags:small", "bags:small"},
{"bags:small", "bags:small"},
},
})
minetest.register_craft({
output = "bags:large",
recipe = {
{"bags:medium", "bags:medium"},
{"bags:medium", "bags:medium"},
},
})
-- log that we started
minetest.log("action", "[MOD]"..minetest.get_current_modname().." -- loaded from "..minetest.get_modpath(minetest.get_current_modname()))

Binary file not shown.

After

Width:  |  Height:  |  Size: 229 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 572 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 797 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 572 B

View File

@ -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.

View File

@ -0,0 +1,44 @@
# Inventory Plus for Minetest
[![home](https://img.shields.io/badge/inventory_plus-home-blue.svg?style=flat-square)](http://cornernote.github.io/minetest-inventory_plus/)
[![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)
[![git](https://img.shields.io/badge/git-project-green.svg?style=flat-square)](https://github.com/cornernote/minetest-inventory_plus)
[![forum](https://img.shields.io/badge/minetest-mod-green.svg?style=flat-square)](http://forum.minetest.net/viewtopic.php?t=6204)
[![bower](https://img.shields.io/badge/bower-mod-green.svg?style=flat-square)](https://minetest-bower.herokuapp.com/mods/inventory_plus)
## Description
Allows additional formspec buttons to be added to the player inventory.
## Features
- Allows additional formspec buttons to be added to the player inventory screen.
- These are processed by your own mod, they can show other formspec screens, or perform in game functionality.
- Adds support for refill/trash to Creative Inventory.
## Project Resources
* [Home](http://cornernote.github.io/minetest-inventory_plus/)
* [Download](https://github.com/cornernote/minetest-inventory_plus/archive/master.zip)
* [Project](https://github.com/cornernote/minetest-inventory_plus)
* [Forum](http://forum.minetest.net/viewtopic.php?t=6204)
* [Bower](https://minetest-bower.herokuapp.com/mods/inventory_plus)
## Support
- Does this README need improvement? Go ahead and [suggest a change](https://github.com/cornernote/minetest-inventory_plus/edit/master/README.md).
- 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).
## 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-inventory_plus/master/LICENSE), Copyright © 2013-2014 [Brett O'Donnell](http://cornernote.github.io/)

View File

@ -0,0 +1,129 @@
--[[
Inventory Plus for Minetest
Copyright (c) 2012 cornernote, Brett O'Donnell <cornernote@gmail.com>
Source Code: https://github.com/cornernote/minetest-inventory_plus
License: BSD-3-Clause https://raw.github.com/cornernote/minetest-inventory_plus/master/LICENSE
]]--
-- expose api
inventory_plus = {}
-- define buttons
inventory_plus.buttons = {}
-- default inventory page
inventory_plus.default = minetest.setting_get("inventory_default") or "craft"
-- register_button
inventory_plus.register_button = function(player,name,label)
local player_name = player:get_player_name()
if inventory_plus.buttons[player_name] == nil then
inventory_plus.buttons[player_name] = {}
end
inventory_plus.buttons[player_name][name] = label
end
-- set_inventory_formspec
inventory_plus.set_inventory_formspec = function(player,formspec)
if minetest.setting_getbool("creative_mode") then
-- if creative mode is on then wait a bit
minetest.after(0.01,function()
player:set_inventory_formspec(formspec)
end)
else
player:set_inventory_formspec(formspec)
end
end
-- get_formspec
inventory_plus.get_formspec = function(player,page)
--if not player then
-- return
--end
local formspec = "size[8,7.5]"
-- player inventory
formspec = formspec .. "list[current_player;main;0,3.5;8,4;]"
-- craft page
if page=="craft" then
formspec = formspec
.."button[0,0;2,0.5;main;Back]"
.."list[current_player;craftpreview;7,1;1,1;]"
if minetest.setting_getbool("inventory_craft_small") then
formspec = formspec.."list[current_player;craft;3,0;2,2;]"
--player:get_inventory():set_width("craft", 2)
--player:get_inventory():set_size("craft", 2*2)
else
formspec = formspec.."list[current_player;craft;3,0;3,3;]"
--player:get_inventory():set_width("craft", 3)
--player:get_inventory():set_size("craft", 3*3)
end
end
-- creative page
if page=="creative" then
return player:get_inventory_formspec()
.."button[5,0;2,0.5;main;Back]"
end
-- main page
if page=="main" then
-- buttons
local x,y=0,0
for k,v in pairs(inventory_plus.buttons[player:get_player_name()]) do
formspec = formspec .. "button["..x..","..y..";2,0.5;"..k..";"..v.."]"
x=x+2
if x == 8 then
x=0
y=y+1
end
end
end
return formspec
end
-- register_on_joinplayer
minetest.register_on_joinplayer(function(player)
if minetest.setting_getbool("inventory_craft_small") then
player:get_inventory():set_width("craft", 2)
player:get_inventory():set_size("craft", 2*2)
else
player:get_inventory():set_width("craft", 3)
player:get_inventory():set_size("craft", 3*3)
end
inventory_plus.register_button(player,"craft","Craft")
if minetest.setting_getbool("creative_mode") then
inventory_plus.register_button(player,"creative_prev","Creative")
end
minetest.after(1,function()
inventory_plus.set_inventory_formspec(player,inventory_plus.get_formspec(player, inventory_plus.default))
end)
end)
-- register_on_player_receive_fields
minetest.register_on_player_receive_fields(function(player, formname, fields)
-- main
if fields.main then
inventory_plus.set_inventory_formspec(player, inventory_plus.get_formspec(player,"main"))
return
end
-- craft
if fields.craft then
inventory_plus.set_inventory_formspec(player, inventory_plus.get_formspec(player,"craft"))
return
end
-- creative
if fields.creative_prev or fields.creative_next then
minetest.after(0.1,function()
inventory_plus.set_inventory_formspec(player, inventory_plus.get_formspec(player,"creative"))
end)
return
end
end)

Binary file not shown.

After

Width:  |  Height:  |  Size: 188 KiB