mirror of
https://github.com/sys4-fr/server-nalc.git
synced 2024-11-08 11:30:21 +01:00
Updated unified_inventory
- Added system hidding crafts involving unknown items - Solves #186
This commit is contained in:
parent
21e53d2ac6
commit
9a4787834b
|
@ -19,7 +19,20 @@ minetest.after(0.01, function()
|
||||||
local recipes = minetest.get_all_craft_recipes(name)
|
local recipes = minetest.get_all_craft_recipes(name)
|
||||||
if recipes then
|
if recipes then
|
||||||
for _, recipe in ipairs(recipes) do
|
for _, recipe in ipairs(recipes) do
|
||||||
unified_inventory.register_craft(recipe)
|
|
||||||
|
local unknowns
|
||||||
|
|
||||||
|
for _,chk in pairs(recipe.items) do
|
||||||
|
local groupchk = string.find(chk, "group:")
|
||||||
|
if (not groupchk and not minetest.registered_items[chk])
|
||||||
|
or (groupchk and not unified_inventory.get_group_item(string.gsub(chk, "group:", "")).item) then
|
||||||
|
unknowns = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if not unknowns then
|
||||||
|
unified_inventory.register_craft(recipe)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,13 +3,7 @@
|
||||||
-- Copyright (c) 2012 cornernote, Brett O'Donnell <cornernote@gmail.com>
|
-- Copyright (c) 2012 cornernote, Brett O'Donnell <cornernote@gmail.com>
|
||||||
-- License: GPLv3
|
-- License: GPLv3
|
||||||
|
|
||||||
local S
|
local S = unified_inventory.gettext
|
||||||
if (minetest.get_modpath("intllib")) then
|
|
||||||
dofile(minetest.get_modpath("intllib").."/intllib.lua")
|
|
||||||
S = intllib.Getter(minetest.get_current_modname())
|
|
||||||
else
|
|
||||||
S = function(s) return s end
|
|
||||||
end
|
|
||||||
|
|
||||||
unified_inventory.register_page("bags", {
|
unified_inventory.register_page("bags", {
|
||||||
get_formspec = function(player)
|
get_formspec = function(player)
|
||||||
|
|
|
@ -83,3 +83,4 @@ dofile(modpath.."/item_names.lua")
|
||||||
if minetest.get_modpath("datastorage") and not unified_inventory.lite_mode then
|
if minetest.get_modpath("datastorage") and not unified_inventory.lite_mode then
|
||||||
dofile(modpath.."/waypoints.lua")
|
dofile(modpath.."/waypoints.lua")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,4 @@
|
||||||
local S
|
local S = unified_inventory.gettext
|
||||||
if (minetest.get_modpath("intllib")) then
|
|
||||||
dofile(minetest.get_modpath("intllib").."/intllib.lua")
|
|
||||||
S = intllib.Getter(minetest.get_current_modname())
|
|
||||||
else
|
|
||||||
S = function(s) return s end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- This pair of encoding functions is used where variable text must go in
|
-- This pair of encoding functions is used where variable text must go in
|
||||||
-- button names, where the text might contain formspec metacharacters.
|
-- button names, where the text might contain formspec metacharacters.
|
||||||
|
@ -63,6 +57,7 @@ function unified_inventory.get_formspec(player, page)
|
||||||
button_row = 1
|
button_row = 1
|
||||||
i = 1
|
i = 1
|
||||||
end
|
end
|
||||||
|
|
||||||
local tooltip = def.tooltip or ""
|
local tooltip = def.tooltip or ""
|
||||||
if def.type == "image" then
|
if def.type == "image" then
|
||||||
formspec = formspec.."image_button["
|
formspec = formspec.."image_button["
|
||||||
|
@ -214,7 +209,11 @@ function unified_inventory.apply_filter(player, filter, search_dir)
|
||||||
end
|
end
|
||||||
unified_inventory.filtered_items_list[player_name]={}
|
unified_inventory.filtered_items_list[player_name]={}
|
||||||
for name, def in pairs(minetest.registered_items) do
|
for name, def in pairs(minetest.registered_items) do
|
||||||
if (def.groups.not_in_creative_inventory or 0) == 0 and (def.description or "") ~= "" and ffilter(name, def) then
|
if (def.groups.not_in_creative_inventory or 0) == 0
|
||||||
|
and (def.description or "") ~= ""
|
||||||
|
and ffilter(name, def)
|
||||||
|
and (unified_inventory.is_creative(player_name)
|
||||||
|
or unified_inventory.crafts_for.recipe[def.name]) then
|
||||||
table.insert(unified_inventory.filtered_items_list[player_name], name)
|
table.insert(unified_inventory.filtered_items_list[player_name], name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,13 +1,4 @@
|
||||||
local S
|
local S = unified_inventory.gettext
|
||||||
if (minetest.get_modpath("intllib")) then
|
|
||||||
dofile(minetest.get_modpath("intllib").."/intllib.lua")
|
|
||||||
S = intllib.Getter(minetest.get_current_modname())
|
|
||||||
else
|
|
||||||
S = function(s) return s end
|
|
||||||
end
|
|
||||||
|
|
||||||
local timers = {}
|
|
||||||
local HOME_INTERVAL = 30*60
|
|
||||||
|
|
||||||
minetest.register_privilege("creative", {
|
minetest.register_privilege("creative", {
|
||||||
description = "Can use the creative inventory",
|
description = "Can use the creative inventory",
|
||||||
|
|
|
@ -1,9 +1,4 @@
|
||||||
local S
|
local S = unified_inventory.gettext
|
||||||
if intllib then
|
|
||||||
S = intllib.Getter()
|
|
||||||
else
|
|
||||||
S = function(s) return s end
|
|
||||||
end
|
|
||||||
|
|
||||||
local hud_colors = {
|
local hud_colors = {
|
||||||
{"#FFFFFF", 0xFFFFFF, S("White")},
|
{"#FFFFFF", 0xFFFFFF, S("White")},
|
||||||
|
|
Loading…
Reference in New Issue
Block a user