[drawers] Update to Git commit 7063e2b & patch a77f809:
Commit: https://github.com/minetest-mods/drawers/tree/7063e2b Patch: https://github.com/AntumDeluge/mtmod-drawers/tree/a77f809
@ -92,7 +92,7 @@ The game includes the mods from the default [minetest_game](https://github.com/m
|
||||
* [adv_spawning][animals] (part of "animals" modpack) ([WTFPL][lic.wtfpl]) -- version: [0.0.13 ec41aa9 Git][ver.adv_spawning] *2015-12-28* ([patched][patch.adv_spawning])
|
||||
* [spawneggs][] ([WTFPL][lic.spawneggs]) -- version [4650370 Git][ver.spawneggs] *2013-09-09* ([patched][patch.spawneggs])
|
||||
* storage/
|
||||
* [drawers][] () -- version: [7b9a384 Git][ver.drawers] *2017-04-23* ([patched][patch.drawers])
|
||||
* [drawers][] () -- version: [0.4.3 (7063e2b Git)][ver.drawers] *2017-06-04* ([patched][patch.drawers])
|
||||
* [more_chests][] ([GPL][lic.gpl2.0]) -- version [c597779 Git][ver.more_chests] *2017-02-27*
|
||||
* tools/
|
||||
* [compassgps][] ([WTFPL][lic.wtfpl] / [CC0][lic.cc0] / [CC BY-SA][lic.ccbysa]) -- version: [96892a0 Git][ver.compassgps] *2015-07-31* ([patched][patch.compassgps])
|
||||
@ -423,7 +423,7 @@ The game includes the mods from the default [minetest_game](https://github.com/m
|
||||
[ver.currency]: https://github.com/minetest-mods/currency/tree/3ee673d
|
||||
[ver.deploy_nodes]: https://github.com/cornernote/minetest-deploy_nodes/tree/eb3d68c
|
||||
[ver.desert_life]: https://github.com/NathanSalapat/desert_life/tree/d448fa3
|
||||
[ver.drawers]: https://github.com/minetest-mods/drawers/tree/7b9a384
|
||||
[ver.drawers]: https://github.com/minetest-mods/drawers/tree/7063e2b
|
||||
[ver.enchanting]: https://github.com/minetest-mods/enchanting/tree/13ea31c
|
||||
[ver.ethereal]: https://github.com/tenplus1/ethereal/tree/2c24961
|
||||
[ver.farming_plus]: https://github.com/PilzAdam/farming_plus/tree/7e0d976
|
||||
@ -515,7 +515,7 @@ The game includes the mods from the default [minetest_game](https://github.com/m
|
||||
[patch.crops]: https://github.com/AntumDeluge/mtmod-crops/tree/0c5c649
|
||||
[patch.currency]: https://github.com/AntumDeluge/mtmod-currency/tree/9e9b1be
|
||||
[patch.deploy_nodes]: https://github.com/AntumDeluge/mtmp-deploy_nodes/tree/3ea67b7
|
||||
[patch.drawers]: https://github.com/AntumDeluge/mtmod-drawers/tree/3887c5b
|
||||
[patch.drawers]: https://github.com/AntumDeluge/mtmod-drawers/tree/a77f809
|
||||
[patch.ethereal]: https://github.com/AntumDeluge/mtmod-ethereal/tree/9f50d6e
|
||||
[patch.farming_plus]: https://github.com/AntumDeluge/mtmod-farming_plus/tree/454a443
|
||||
[patch.hbarmor]: https://github.com/AntumDeluge/mtmod-hbarmor/tree/d1168bb
|
||||
|
@ -1,6 +1,6 @@
|
||||
Minetest Mod Storage Drawers
|
||||
============================
|
||||
Version 0.4.2
|
||||
Version 0.4.3
|
||||
|
||||
License of source code:
|
||||
-----------------------
|
||||
@ -28,8 +28,41 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
|
||||
License of translations:
|
||||
------------------------
|
||||
CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
|
||||
|
||||
No Copyright
|
||||
Minetest Mod Storage Drawers Translators
|
||||
|
||||
The person who associated a work with this deed has dedicated the work to the public
|
||||
domain by waiving all of his or her rights to the work worldwide under copyright law,
|
||||
including all related and neighboring rights, to the extent allowed by law.
|
||||
|
||||
You can copy, modify, distribute and perform the work, even for commercial purposes, all
|
||||
without asking permission. See Other Information below.
|
||||
|
||||
Other Information
|
||||
|
||||
In no way are the patent or trademark rights of any person affected by CC0, nor are the
|
||||
rights that other persons may have in the work or in how the work is used, such as
|
||||
publicity or privacy rights.
|
||||
Unless expressly stated otherwise, the person who associated a work with this deed makes
|
||||
no warranties about the work, and disclaims liability for all uses of the work, to the
|
||||
fullest extent permitted by applicable law.
|
||||
When using or citing the work, you should not imply endorsement by the author or the
|
||||
affirmer.
|
||||
|
||||
For more details:
|
||||
https://creativecommons.org/publicdomain/zero/1.0/
|
||||
|
||||
|
||||
License of media:
|
||||
-----------------
|
||||
Copyright (C) 2012 ultradust (https://www.freesound.org/people/ultradust/) (CC BY 3.0):
|
||||
sounds/drawers_interact.1.ogg (edited by tacotexmex)
|
||||
sounds/drawers_interact.2.ogg (edited by tacotexmex)
|
||||
|
||||
Copyright (C) 2014 Justin Aquadro (MIT):
|
||||
textures/drawers_acacia_wood_mcl_front_1.png
|
||||
textures/drawers_acacia_wood_mcl_front_2.png
|
||||
@ -63,6 +96,14 @@ Copyright (C) 2014 Justin Aquadro (MIT):
|
||||
textures/drawers_spruce_wood_front_2.png
|
||||
textures/drawers_spruce_wood_front_4.png
|
||||
textures/drawers_spruce_wood.png
|
||||
textures/drawers_upgrade_diamond.png
|
||||
textures/drawers_upgrade_emerald.png
|
||||
textures/drawers_upgrade_gold.png
|
||||
textures/drawers_upgrade_iron.png
|
||||
textures/drawers_upgrade_obsidian.png
|
||||
textures/drawers_upgrade_steel.png
|
||||
textures/drawers_upgrade_slot_bg.png (extracted from gui/drawers_1.png by LNJ <git@lnj.li>)
|
||||
textures/drawers_upgrade_template.png
|
||||
textures/drawers_wood_front_1.png
|
||||
textures/drawers_wood_front_2.png
|
||||
textures/drawers_wood_front_4.png
|
||||
|
@ -1,5 +1,5 @@
|
||||
# Minetest Mod Storage Drawers
|
||||
Version 0.4.2, Status: alpha, License: MIT
|
||||
Version 0.4.3, Status: alpha, License: MIT
|
||||
|
||||
## Description
|
||||
This mod adds simple item storages showing the item's inventory image in the
|
||||
@ -38,4 +38,6 @@ alternatively you can also [email](mailto:git@lnj.li) me.
|
||||
|
||||
## Links
|
||||
* [Minetest Forums](https://forum.minetest.net/viewtopic.php?f=9&t=17134)
|
||||
* [Weblate](https://hosted.weblate.org/projects/minetest/mod-storage-drawers/)
|
||||
* [GitHub](http://github.com/lnj2/drawers/)
|
||||
|
||||
|
@ -3,4 +3,3 @@ mcl_core?
|
||||
screwdriver?
|
||||
pipeworks?
|
||||
intllib?
|
||||
craft_guide?
|
||||
|
@ -47,12 +47,21 @@ else
|
||||
end
|
||||
|
||||
|
||||
drawers.enable_1x1 = not core.setting_getbool("drawers_disable_1x1")
|
||||
drawers.enable_1x2 = not core.setting_getbool("drawers_disable_1x2")
|
||||
drawers.enable_2x2 = not core.setting_getbool("drawers_disable_2x2")
|
||||
drawers.enable_1x1 = not core.settings:get_bool("drawers_disable_1x1")
|
||||
drawers.enable_1x2 = not core.settings:get_bool("drawers_disable_1x2")
|
||||
drawers.enable_2x2 = not core.settings:get_bool("drawers_disable_2x2")
|
||||
|
||||
|
||||
--
|
||||
-- Load files
|
||||
-- GUI
|
||||
--
|
||||
|
||||
drawers.gui_bg = "bgcolor[#080808BB;true]"
|
||||
drawers.gui_bg_img = "background[5,5;1,1;gui_formbg.png;true]"
|
||||
drawers.gui_slots = "listcolors[#00000069;#5A5A5A;#141318;#30434C;#FFF]"
|
||||
|
||||
--
|
||||
-- Load API
|
||||
--
|
||||
|
||||
dofile(MP .. "/lua/helpers.lua")
|
||||
@ -75,7 +84,7 @@ if core.get_modpath("default") and default then
|
||||
"drawers_wood.png"),
|
||||
groups = {choppy = 3, oddly_breakable_by_hand = 2},
|
||||
sounds = drawers.WOOD_SOUNDS,
|
||||
drawer_stack_max_factor = 3 * 8, -- normal chest size
|
||||
drawer_stack_max_factor = 4 * 8, -- normal chest size
|
||||
material = drawers.WOOD_ITEMSTRING
|
||||
})
|
||||
drawers.register_drawer("drawers:acacia_wood", {
|
||||
@ -88,7 +97,7 @@ if core.get_modpath("default") and default then
|
||||
"drawers_acacia_wood.png"),
|
||||
groups = {choppy = 3, oddly_breakable_by_hand = 2},
|
||||
sounds = drawers.WOOD_SOUNDS,
|
||||
drawer_stack_max_factor = 3 * 8, -- normal mcl chest size
|
||||
drawer_stack_max_factor = 4 * 8, -- normal mcl chest size
|
||||
material = "default:acacia_wood"
|
||||
})
|
||||
drawers.register_drawer("drawers:aspen_wood", {
|
||||
@ -101,7 +110,7 @@ if core.get_modpath("default") and default then
|
||||
"drawers_aspen_wood.png"),
|
||||
groups = {choppy = 3, oddly_breakable_by_hand = 2},
|
||||
sounds = drawers.WOOD_SOUNDS,
|
||||
drawer_stack_max_factor = 3 * 8, -- normal chest size
|
||||
drawer_stack_max_factor = 4 * 8, -- normal chest size
|
||||
material = "default:aspen_wood"
|
||||
})
|
||||
drawers.register_drawer("drawers:junglewood", {
|
||||
@ -114,7 +123,7 @@ if core.get_modpath("default") and default then
|
||||
"drawers_junglewood.png"),
|
||||
groups = {choppy = 3, oddly_breakable_by_hand = 2},
|
||||
sounds = drawers.WOOD_SOUNDS,
|
||||
drawer_stack_max_factor = 3 * 8, -- normal mcl chest size
|
||||
drawer_stack_max_factor = 4 * 8, -- normal mcl chest size
|
||||
material = "default:junglewood"
|
||||
})
|
||||
drawers.register_drawer("drawers:pine_wood", {
|
||||
@ -127,7 +136,7 @@ if core.get_modpath("default") and default then
|
||||
"drawers_pine_wood.png"),
|
||||
groups = {choppy = 3, oddly_breakable_by_hand = 2},
|
||||
sounds = drawers.WOOD_SOUNDS,
|
||||
drawer_stack_max_factor = 3 * 8, -- normal chest size
|
||||
drawer_stack_max_factor = 4 * 8, -- normal chest size
|
||||
material = "default:pine_wood"
|
||||
})
|
||||
elseif core.get_modpath("mcl_core") and mcl_core then
|
||||
@ -141,7 +150,7 @@ elseif core.get_modpath("mcl_core") and mcl_core then
|
||||
"drawers_oak_wood.png"),
|
||||
groups = {choppy = 3, oddly_breakable_by_hand = 2},
|
||||
sounds = drawers.WOOD_SOUNDS,
|
||||
drawer_stack_max_factor = 3 * 9, -- normal mcl chest size
|
||||
drawer_stack_max_factor = 4 * 9, -- normal mcl chest size
|
||||
material = drawers.WOOD_ITEMSTRING
|
||||
})
|
||||
drawers.register_drawer("drawers:acaciawood", {
|
||||
@ -154,7 +163,7 @@ elseif core.get_modpath("mcl_core") and mcl_core then
|
||||
"drawers_acacia_wood_mcl.png"),
|
||||
groups = {choppy = 3, oddly_breakable_by_hand = 2},
|
||||
sounds = drawers.WOOD_SOUNDS,
|
||||
drawer_stack_max_factor = 3 * 9, -- normal mcl chest size
|
||||
drawer_stack_max_factor = 4 * 9, -- normal mcl chest size
|
||||
material = "mcl_core:acaciawood"
|
||||
})
|
||||
drawers.register_drawer("drawers:birchwood", {
|
||||
@ -167,7 +176,7 @@ elseif core.get_modpath("mcl_core") and mcl_core then
|
||||
"drawers_birch_wood.png"),
|
||||
groups = {choppy = 3, oddly_breakable_by_hand = 2},
|
||||
sounds = drawers.WOOD_SOUNDS,
|
||||
drawer_stack_max_factor = 3 * 9, -- normal mcl chest size
|
||||
drawer_stack_max_factor = 4 * 9, -- normal mcl chest size
|
||||
material = "mcl_core:birchwood"
|
||||
})
|
||||
drawers.register_drawer("drawers:darkwood", {
|
||||
@ -180,7 +189,7 @@ elseif core.get_modpath("mcl_core") and mcl_core then
|
||||
"drawers_dark_oak_wood.png"),
|
||||
groups = {choppy = 3, oddly_breakable_by_hand = 2},
|
||||
sounds = drawers.WOOD_SOUNDS,
|
||||
drawer_stack_max_factor = 3 * 9, -- normal mcl chest size
|
||||
drawer_stack_max_factor = 4 * 9, -- normal mcl chest size
|
||||
material = "mcl_core:darkwood"
|
||||
})
|
||||
drawers.register_drawer("drawers:junglewood", {
|
||||
@ -193,7 +202,7 @@ elseif core.get_modpath("mcl_core") and mcl_core then
|
||||
"drawers_junglewood_mcl.png"),
|
||||
groups = {choppy = 3, oddly_breakable_by_hand = 2},
|
||||
sounds = drawers.WOOD_SOUNDS,
|
||||
drawer_stack_max_factor = 3 * 9, -- normal mcl chest size
|
||||
drawer_stack_max_factor = 4 * 9, -- normal mcl chest size
|
||||
material = "mcl_core:junglewood"
|
||||
})
|
||||
drawers.register_drawer("drawers:sprucewood", {
|
||||
@ -206,7 +215,7 @@ elseif core.get_modpath("mcl_core") and mcl_core then
|
||||
"drawers_spruce_wood.png"),
|
||||
groups = {choppy = 3, oddly_breakable_by_hand = 2},
|
||||
sounds = drawers.WOOD_SOUNDS,
|
||||
drawer_stack_max_factor = 3 * 9, -- normal mcl chest size
|
||||
drawer_stack_max_factor = 4 * 9, -- normal mcl chest size
|
||||
material = "mcl_core:sprucewood"
|
||||
})
|
||||
|
||||
@ -225,8 +234,96 @@ else
|
||||
"drawers_wood.png"),
|
||||
groups = {choppy = 3, oddly_breakable_by_hand = 2},
|
||||
sounds = drawers.WOOD_SOUNDS,
|
||||
drawer_stack_max_factor = 3 * 8, -- normal chest size
|
||||
drawer_stack_max_factor = 4 * 8, -- normal chest size
|
||||
material = drawers.WOOD_ITEMSTRING
|
||||
})
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Register drawer upgrades
|
||||
--
|
||||
|
||||
if core.get_modpath("default") and default then
|
||||
drawers.register_drawer_upgrade("drawers:upgrade_steel", {
|
||||
description = S("Steel Drawer Upgrade (x2)"),
|
||||
inventory_image = "drawers_upgrade_steel.png",
|
||||
groups = {drawer_upgrade = 100},
|
||||
recipe_item = "default:steel_ingot"
|
||||
})
|
||||
|
||||
drawers.register_drawer_upgrade("drawers:upgrade_gold", {
|
||||
description = S("Gold Drawer Upgrade (x3)"),
|
||||
inventory_image = "drawers_upgrade_gold.png",
|
||||
groups = {drawer_upgrade = 200},
|
||||
recipe_item = "default:gold_ingot"
|
||||
})
|
||||
|
||||
drawers.register_drawer_upgrade("drawers:upgrade_obsidian", {
|
||||
description = S("Obsidian Drawer Upgrade (x5)"),
|
||||
inventory_image = "drawers_upgrade_obsidian.png",
|
||||
groups = {drawer_upgrade = 400},
|
||||
recipe_item = "default:obsidian"
|
||||
})
|
||||
|
||||
drawers.register_drawer_upgrade("drawers:upgrade_diamond", {
|
||||
description = S("Diamond Drawer Upgrade (x8)"),
|
||||
inventory_image = "drawers_upgrade_diamond.png",
|
||||
groups = {drawer_upgrade = 700},
|
||||
recipe_item = "default:diamond"
|
||||
})
|
||||
elseif core.get_modpath("mcl_core") and mcl_core then
|
||||
drawers.register_drawer_upgrade("drawers:upgrade_iron", {
|
||||
description = S("Iron Drawer Upgrade (x2)"),
|
||||
inventory_image = "drawers_upgrade_iron.png",
|
||||
groups = {drawer_upgrade = 100},
|
||||
recipe_item = "mcl_core:iron_ingot"
|
||||
})
|
||||
|
||||
drawers.register_drawer_upgrade("drawers:upgrade_gold", {
|
||||
description = S("Gold Drawer Upgrade (x3)"),
|
||||
inventory_image = "drawers_upgrade_gold.png",
|
||||
groups = {drawer_upgrade = 200},
|
||||
recipe_item = "mcl_core:gold_ingot"
|
||||
})
|
||||
|
||||
drawers.register_drawer_upgrade("drawers:upgrade_obsidian", {
|
||||
description = S("Obsidian Drawer Upgrade (x5)"),
|
||||
inventory_image = "drawers_upgrade_obsidian.png",
|
||||
groups = {drawer_upgrade = 400},
|
||||
recipe_item = "mcl_core:obsidian"
|
||||
})
|
||||
|
||||
drawers.register_drawer_upgrade("drawers:upgrade_diamond", {
|
||||
description = S("Diamond Drawer Upgrade (x8)"),
|
||||
inventory_image = "drawers_upgrade_diamond.png",
|
||||
groups = {drawer_upgrade = 700},
|
||||
recipe_item = "mcl_core:diamond"
|
||||
})
|
||||
|
||||
drawers.register_drawer_upgrade("drawers:upgrade_emerald", {
|
||||
description = S("Emerald Drawer Upgrade (x13)"),
|
||||
inventory_image = "drawers_upgrade_emerald.png",
|
||||
groups = {drawer_upgrade = 1200},
|
||||
recipe_item = "mcl_core:emerald"
|
||||
})
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Register drawer upgrade template
|
||||
--
|
||||
|
||||
core.register_craftitem("drawers:upgrade_template", {
|
||||
description = S("Drawer Upgrade Template"),
|
||||
inventory_image = "drawers_upgrade_template.png"
|
||||
})
|
||||
|
||||
core.register_craft({
|
||||
output = "drawers:upgrade_template 4",
|
||||
recipe = {
|
||||
{"group:stick", "group:stick", "group:stick"},
|
||||
{"group:stick", "group:drawer", "group:stick"},
|
||||
{"group:stick", "group:stick", "group:stick"}
|
||||
}
|
||||
})
|
||||
|
@ -37,6 +37,14 @@ drawers.node_box_simple = {
|
||||
{-0.4375, -0.5, -0.5, 0.4375, -0.4375, -0.4375},
|
||||
}
|
||||
|
||||
drawers.drawer_formspec = "size[9,7]" ..
|
||||
"list[context;upgrades;2,0.5;5,1;]" ..
|
||||
"list[current_player;main;0,3;9,4;]" ..
|
||||
drawers.gui_bg ..
|
||||
drawers.gui_bg_img ..
|
||||
drawers.gui_slots ..
|
||||
drawers.get_upgrade_slots_bg(2, 0.5)
|
||||
|
||||
-- construct drawer
|
||||
function drawers.drawer_on_construct(pos)
|
||||
local node = core.get_node(pos)
|
||||
@ -66,7 +74,14 @@ function drawers.drawer_on_construct(pos)
|
||||
i = i + 1
|
||||
end
|
||||
|
||||
-- spawn all visuals
|
||||
drawers.spawn_visuals(pos)
|
||||
|
||||
-- create drawer upgrade inventory
|
||||
meta:get_inventory():set_size("upgrades", 5)
|
||||
|
||||
-- set the formspec
|
||||
meta:set_string("formspec", drawers.drawer_formspec)
|
||||
end
|
||||
|
||||
-- destruct drawer
|
||||
@ -113,17 +128,55 @@ function drawers.drawer_on_dig(pos, node, player)
|
||||
k = k + 1
|
||||
end
|
||||
|
||||
-- drop all drawer upgrades
|
||||
local upgrades = meta:get_inventory():get_list("upgrades")
|
||||
if upgrades then
|
||||
for _,itemStack in pairs(upgrades) do
|
||||
if itemStack:get_count() > 0 then
|
||||
local rndpos = drawers.randomize_pos(pos)
|
||||
core.add_item(rndpos, itemStack:get_name())
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- remove node
|
||||
core.node_dig(pos, node, player)
|
||||
end
|
||||
|
||||
function drawers.drawer_allow_metadata_inventory_put(pos, listname, index, stack, player)
|
||||
if listname ~= "upgrades" then
|
||||
return 0
|
||||
end
|
||||
if stack:get_count() > 1 then
|
||||
return 0
|
||||
end
|
||||
if core.get_item_group(stack:get_name(), "drawer_upgrade") < 1 then
|
||||
return 0
|
||||
end
|
||||
return 1
|
||||
end
|
||||
|
||||
function drawers.add_drawer_upgrade(pos, listname, index, stack, player)
|
||||
-- only do anything if adding to upgrades
|
||||
if listname ~= "upgrades" then return end
|
||||
|
||||
drawers.update_drawer_upgrades(pos)
|
||||
end
|
||||
|
||||
function drawers.remove_drawer_upgrade(pos, listname, index, stack, player)
|
||||
-- only do anything if adding to upgrades
|
||||
if listname ~= "upgrades" then return end
|
||||
|
||||
drawers.update_drawer_upgrades(pos)
|
||||
end
|
||||
|
||||
function drawers.drawer_insert_object(pos, node, stack, direction)
|
||||
local drawer_visuals = drawers.drawer_visuals[core.serialize(pos)]
|
||||
if not drawer_visuals then return stack end
|
||||
|
||||
local leftover = stack
|
||||
for _, visual in pairs(drawer_visuals) do
|
||||
leftover = visual.try_insert_stack(visual, leftover, true)
|
||||
leftover = visual:try_insert_stack(leftover, true)
|
||||
end
|
||||
return leftover
|
||||
end
|
||||
@ -144,6 +197,9 @@ function drawers.register_drawer(name, def)
|
||||
def.on_construct = drawers.drawer_on_construct
|
||||
def.on_destruct = drawers.drawer_on_destruct
|
||||
def.on_dig = drawers.drawer_on_dig
|
||||
def.allow_metadata_inventory_put = drawers.drawer_allow_metadata_inventory_put
|
||||
def.on_metadata_inventory_put = drawers.add_drawer_upgrade
|
||||
def.on_metadata_inventory_take = drawers.remove_drawer_upgrade
|
||||
|
||||
if minetest.get_modpath("screwdriver") and screwdriver then
|
||||
def.on_rotate = def.on_rotate or screwdriver.disallow
|
||||
@ -231,3 +287,26 @@ function drawers.register_drawer(name, def)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function drawers.register_drawer_upgrade(name, def)
|
||||
def.groups = def.groups or {}
|
||||
def.groups.drawer_upgrade = def.groups.drawer_upgrade or 100
|
||||
def.inventory_image = def.inventory_image or "drawers_upgrade_template.png"
|
||||
def.stack_max = 1
|
||||
|
||||
local recipe_item = def.recipe_item or "air"
|
||||
def.recipe_item = nil
|
||||
|
||||
core.register_craftitem(name, def)
|
||||
|
||||
if not def.no_craft then
|
||||
core.register_craft({
|
||||
output = name,
|
||||
recipe = {
|
||||
{recipe_item, "group:stick", recipe_item},
|
||||
{"group:stick", "drawers:upgrade_template", "group:stick"},
|
||||
{recipe_item, "group:stick", recipe_item}
|
||||
}
|
||||
})
|
||||
end
|
||||
end
|
||||
|
@ -29,6 +29,15 @@ SOFTWARE.
|
||||
local MP = core.get_modpath(core.get_current_modname())
|
||||
local S, NS = dofile(MP.."/intllib.lua")
|
||||
|
||||
-- GUI
|
||||
function drawers.get_upgrade_slots_bg(x,y)
|
||||
local out = ""
|
||||
for i = 0, 4, 1 do
|
||||
out = out .."image["..x+i..","..y..";1,1;drawers_upgrade_slot_bg.png]"
|
||||
end
|
||||
return out
|
||||
end
|
||||
|
||||
function drawers.gen_info_text(basename, count, factor, stack_max)
|
||||
local maxCount = stack_max * factor
|
||||
local percent = count / maxCount * 100
|
||||
@ -199,6 +208,41 @@ function drawers.remove_visuals(pos)
|
||||
end
|
||||
end
|
||||
|
||||
function drawers.update_drawer_upgrades(pos)
|
||||
local node = core.get_node(pos)
|
||||
local ndef = core.registered_nodes[node.name]
|
||||
local drawerType = ndef.groups.drawer
|
||||
|
||||
-- default number of slots/stacks
|
||||
local stackMaxFactor = ndef.drawer_stack_max_factor
|
||||
|
||||
-- storage percent with all upgrades
|
||||
local storagePercent = 100
|
||||
|
||||
-- get info of all upgrades
|
||||
local inventory = core.get_meta(pos):get_inventory():get_list("upgrades")
|
||||
for _,itemStack in pairs(inventory) do
|
||||
local iname = itemStack:get_name()
|
||||
local idef = core.registered_items[iname]
|
||||
local addPercent = idef.groups.drawer_upgrade or 0
|
||||
|
||||
storagePercent = storagePercent + addPercent
|
||||
end
|
||||
|
||||
-- i.e.: 150% / 100 => 1.50
|
||||
stackMaxFactor = math.floor(stackMaxFactor * (storagePercent / 100))
|
||||
-- calculate stack_max factor for a single drawer
|
||||
stackMaxFactor = stackMaxFactor / drawerType
|
||||
|
||||
-- set the new stack max factor in all visuals
|
||||
local drawer_visuals = drawers.drawer_visuals[core.serialize(pos)]
|
||||
if not drawer_visuals then return end
|
||||
|
||||
for _,visual in pairs(drawer_visuals) do
|
||||
visual:setStackMaxFactor(stackMaxFactor)
|
||||
end
|
||||
end
|
||||
|
||||
function drawers.randomize_pos(pos)
|
||||
local rndpos = table.copy(pos)
|
||||
local x = math.random(-50, 50) * 0.01
|
||||
|
@ -90,10 +90,11 @@ core.register_entity("drawers:visual", {
|
||||
drawers.drawer_visuals[posstr][vId] = self
|
||||
end
|
||||
|
||||
|
||||
local node = core.get_node(self.drawer_pos)
|
||||
-- get meta
|
||||
self.meta = core.get_meta(self.drawer_pos)
|
||||
|
||||
-- collisionbox
|
||||
local node = core.get_node(self.drawer_pos)
|
||||
local colbox
|
||||
if self.drawerType ~= 2 then
|
||||
if node.param2 == 1 or node.param2 == 3 then
|
||||
@ -123,17 +124,16 @@ core.register_entity("drawers:visual", {
|
||||
|
||||
|
||||
-- drawer values
|
||||
local meta = core.get_meta(self.drawer_pos)
|
||||
local vid = self.visualId
|
||||
self.count = meta:get_int("count"..vid)
|
||||
self.itemName = meta:get_string("name"..vid)
|
||||
self.maxCount = meta:get_int("max_count"..vid)
|
||||
self.itemStackMax = meta:get_int("base_stack_max"..vid)
|
||||
self.stackMaxFactor = meta:get_int("stack_max_factor"..vid)
|
||||
self.count = self.meta:get_int("count"..vid)
|
||||
self.itemName = self.meta:get_string("name"..vid)
|
||||
self.maxCount = self.meta:get_int("max_count"..vid)
|
||||
self.itemStackMax = self.meta:get_int("base_stack_max"..vid)
|
||||
self.stackMaxFactor = self.meta:get_int("stack_max_factor"..vid)
|
||||
|
||||
|
||||
-- infotext
|
||||
local infotext = meta:get_string("entity_infotext"..vid) .. "\n\n\n\n\n"
|
||||
local infotext = self.meta:get_string("entity_infotext"..vid) .. "\n\n\n\n\n"
|
||||
|
||||
self.object:set_properties({
|
||||
collisionbox = colbox,
|
||||
@ -150,10 +150,37 @@ core.register_entity("drawers:visual", {
|
||||
local leftover = self.try_insert_stack(self, clicker:get_wielded_item(),
|
||||
not clicker:get_player_control().sneak)
|
||||
|
||||
-- if smth. was added play the interact sound
|
||||
if clicker:get_wielded_item():get_count() > leftover:get_count() then
|
||||
self:play_interact_sound()
|
||||
end
|
||||
-- set the leftover as new wielded item for the player
|
||||
clicker:set_wielded_item(leftover)
|
||||
end,
|
||||
|
||||
on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir)
|
||||
local add_stack = not puncher:get_player_control().sneak
|
||||
|
||||
local inv = puncher:get_inventory()
|
||||
local spaceChecker = ItemStack(self.itemName)
|
||||
if add_stack then
|
||||
spaceChecker:set_count(spaceChecker:get_stack_max())
|
||||
end
|
||||
if not inv:room_for_item("main", spaceChecker) then
|
||||
return
|
||||
end
|
||||
|
||||
stack = self:take_items(add_stack)
|
||||
if stack ~= nil then
|
||||
-- add removed stack to player's inventory
|
||||
inv:add_item("main", stack)
|
||||
|
||||
-- play the interact sound
|
||||
self:play_interact_sound()
|
||||
end
|
||||
end,
|
||||
|
||||
take_items = function(self, take_stack)
|
||||
local meta = core.get_meta(self.drawer_pos)
|
||||
|
||||
if self.count <= 0 then
|
||||
@ -161,44 +188,25 @@ core.register_entity("drawers:visual", {
|
||||
end
|
||||
|
||||
local removeCount = 1
|
||||
if not puncher:get_player_control().sneak then
|
||||
if take_stack then
|
||||
removeCount = ItemStack(self.itemName):get_stack_max()
|
||||
end
|
||||
if removeCount > self.count then removeCount = self.count end
|
||||
if removeCount > self.count then
|
||||
removeCount = self.count
|
||||
end
|
||||
|
||||
local stack = ItemStack(self.itemName)
|
||||
stack:set_count(removeCount)
|
||||
|
||||
local inv = puncher:get_inventory()
|
||||
if not inv:room_for_item("main", stack) then
|
||||
return
|
||||
end
|
||||
|
||||
inv:add_item("main", stack)
|
||||
-- update the drawer count
|
||||
self.count = self.count - removeCount
|
||||
meta:set_int("count"..self.visualId, self.count)
|
||||
|
||||
-- update infotext
|
||||
local itemDescription = ""
|
||||
if core.registered_items[self.itemName] then
|
||||
itemDescription = core.registered_items[self.itemName].description
|
||||
end
|
||||
self:updateInfotext()
|
||||
self:updateTexture()
|
||||
self:saveMetaData()
|
||||
|
||||
if self.count <= 0 then
|
||||
self.itemName = ""
|
||||
meta:set_string("name"..self.visualId, self.itemName)
|
||||
self.texture = "blank.png"
|
||||
itemDescription = S("Empty")
|
||||
end
|
||||
|
||||
local infotext = drawers.gen_info_text(itemDescription,
|
||||
self.count, self.stackMaxFactor, self.itemStackMax)
|
||||
meta:set_string("entity_infotext"..self.visualId, infotext)
|
||||
|
||||
self.object:set_properties({
|
||||
infotext = infotext .. "\n\n\n\n\n",
|
||||
textures = {self.texture}
|
||||
})
|
||||
-- return the stack that was removed from the drawer
|
||||
return stack
|
||||
end,
|
||||
|
||||
try_insert_stack = function(self, itemstack, insert_stack)
|
||||
@ -244,40 +252,109 @@ core.register_entity("drawers:visual", {
|
||||
itemstack:set_count(itemstack:get_count() - stackCount)
|
||||
end
|
||||
|
||||
-- get meta
|
||||
local meta = core.get_meta(self.drawer_pos)
|
||||
-- update infotext, texture
|
||||
self:updateInfotext()
|
||||
self:updateTexture()
|
||||
|
||||
-- update infotext
|
||||
local itemDescription
|
||||
if core.registered_items[self.itemName] then
|
||||
itemDescription = core.registered_items[self.itemName].description
|
||||
else
|
||||
itemDescription = S("Empty")
|
||||
end
|
||||
local infotext = drawers.gen_info_text(itemDescription,
|
||||
self.count, self.stackMaxFactor, self.itemStackMax)
|
||||
meta:set_string("entity_infotext"..self.visualId, infotext)
|
||||
|
||||
-- texture
|
||||
self.texture = drawers.get_inv_image(self.itemName)
|
||||
|
||||
self.object:set_properties({
|
||||
infotext = infotext .. "\n\n\n\n\n",
|
||||
textures = {self.texture}
|
||||
})
|
||||
|
||||
self.saveMetaData(self, meta)
|
||||
self:saveMetaData()
|
||||
|
||||
if itemstack:get_count() == 0 then itemstack = ItemStack("") end
|
||||
return itemstack
|
||||
end,
|
||||
|
||||
updateInfotext = function(self)
|
||||
local itemDescription = ""
|
||||
if core.registered_items[self.itemName] then
|
||||
itemDescription = core.registered_items[self.itemName].description
|
||||
end
|
||||
|
||||
if self.count <= 0 then
|
||||
self.itemName = ""
|
||||
self.meta:set_string("name"..self.visualId, self.itemName)
|
||||
self.texture = "blank.png"
|
||||
itemDescription = S("Empty")
|
||||
end
|
||||
|
||||
local infotext = drawers.gen_info_text(itemDescription,
|
||||
self.count, self.stackMaxFactor, self.itemStackMax)
|
||||
self.meta:set_string("entity_infotext"..self.visualId, infotext)
|
||||
|
||||
self.object:set_properties({
|
||||
infotext = infotext .. "\n\n\n\n\n"
|
||||
})
|
||||
end,
|
||||
|
||||
updateTexture = function(self)
|
||||
-- texture
|
||||
self.texture = drawers.get_inv_image(self.itemName)
|
||||
|
||||
self.object:set_properties({
|
||||
textures = {self.texture}
|
||||
})
|
||||
end,
|
||||
|
||||
dropStack = function(self, itemStack)
|
||||
-- print warning if dropping higher stack counts than allowed
|
||||
if itemStack:get_count() > itemStack:get_stack_max() then
|
||||
core.log("warning", "[drawers] Dropping item stack with higher count than allowed")
|
||||
end
|
||||
-- find a position containing air
|
||||
local dropPos = core.find_node_near(self.drawer_pos, 1, {"air"}, false)
|
||||
-- if no pos found then drop on the top of the drawer
|
||||
if not dropPos then
|
||||
dropPos = self.pos
|
||||
dropPos.y = dropPos.y + 1
|
||||
end
|
||||
-- drop the item stack
|
||||
core.item_drop(itemStack, nil, dropPos)
|
||||
end,
|
||||
|
||||
dropItemOverload = function(self)
|
||||
-- drop stacks until there are no more items than allowed
|
||||
while self.count > self.maxCount do
|
||||
-- remove the overflow
|
||||
local removeCount = self.count - self.maxCount
|
||||
-- if this is too much for a single stack, only take the
|
||||
-- stack limit
|
||||
if removeCount > self.itemStackMax then
|
||||
removeCount = self.itemStackMax
|
||||
end
|
||||
-- remove this count from the drawer
|
||||
self.count = self.count - removeCount
|
||||
-- create a new item stack having the size of the remove
|
||||
-- count
|
||||
local stack = ItemStack(self.itemName)
|
||||
stack:set_count(removeCount)
|
||||
print(stack:to_string())
|
||||
-- drop the stack
|
||||
self:dropStack(stack)
|
||||
end
|
||||
end,
|
||||
|
||||
setStackMaxFactor = function(self, stackMaxFactor)
|
||||
self.stackMaxFactor = stackMaxFactor
|
||||
self.maxCount = self.stackMaxFactor * self.itemStackMax
|
||||
|
||||
-- will drop possible overflowing items
|
||||
self:dropItemOverload()
|
||||
self:updateInfotext()
|
||||
self:saveMetaData()
|
||||
end,
|
||||
|
||||
play_interact_sound = function(self)
|
||||
core.sound_play("drawers_interact", {
|
||||
pos = self.pos,
|
||||
max_hear_distance = 6,
|
||||
gain = 2.0
|
||||
})
|
||||
end,
|
||||
|
||||
saveMetaData = function(self, meta)
|
||||
meta:set_int("count"..self.visualId, self.count)
|
||||
meta:set_string("name"..self.visualId, self.itemName)
|
||||
meta:set_int("max_count"..self.visualId, self.maxCount)
|
||||
meta:set_int("base_stack_max"..self.visualId, self.itemStackMax)
|
||||
meta:set_int("stack_max_factor"..self.visualId, self.stackMaxFactor)
|
||||
self.meta:set_int("count"..self.visualId, self.count)
|
||||
self.meta:set_string("name"..self.visualId, self.itemName)
|
||||
self.meta:set_int("max_count"..self.visualId, self.maxCount)
|
||||
self.meta:set_int("base_stack_max"..self.visualId, self.itemStackMax)
|
||||
self.meta:set_int("stack_max_factor"..self.visualId, self.stackMaxFactor)
|
||||
end
|
||||
})
|
||||
|
||||
@ -286,6 +363,13 @@ core.register_lbm({
|
||||
nodenames = {"group:drawer"},
|
||||
run_at_every_load = true,
|
||||
action = function(pos, node)
|
||||
local meta = core.get_meta(pos)
|
||||
-- create drawer upgrade inventory
|
||||
meta:get_inventory():set_size("upgrades", 5)
|
||||
-- set the formspec
|
||||
meta:set_string("formspec", drawers.drawer_formspec)
|
||||
|
||||
-- count the drawer visuals
|
||||
local drawerType = core.registered_nodes[node.name].groups.drawer
|
||||
local foundVisuals = 0
|
||||
local objs = core.get_objects_inside_radius(pos, 0.537)
|
||||
|
BIN
mods/storage/drawers/sounds/drawers_interact.1.ogg
Normal file
BIN
mods/storage/drawers/sounds/drawers_interact.2.ogg
Normal file
BIN
mods/storage/drawers/textures/drawers_upgrade_diamond.png
Normal file
After Width: | Height: | Size: 219 B |
BIN
mods/storage/drawers/textures/drawers_upgrade_emerald.png
Normal file
After Width: | Height: | Size: 217 B |
BIN
mods/storage/drawers/textures/drawers_upgrade_gold.png
Normal file
After Width: | Height: | Size: 481 B |
BIN
mods/storage/drawers/textures/drawers_upgrade_iron.png
Normal file
After Width: | Height: | Size: 217 B |
BIN
mods/storage/drawers/textures/drawers_upgrade_obsidian.png
Normal file
After Width: | Height: | Size: 217 B |
BIN
mods/storage/drawers/textures/drawers_upgrade_slot_bg.png
Normal file
After Width: | Height: | Size: 120 B |
BIN
mods/storage/drawers/textures/drawers_upgrade_steel.png
Normal file
After Width: | Height: | Size: 217 B |
BIN
mods/storage/drawers/textures/drawers_upgrade_template.png
Normal file
After Width: | Height: | Size: 204 B |