Compare commits
10 Commits
db22249388
...
66b122f3dd
Author | SHA1 | Date | |
---|---|---|---|
|
66b122f3dd | ||
|
8ce3759628 | ||
|
8185d4f8aa | ||
|
22ef28c899 | ||
|
a37f44dbce | ||
|
277773b32a | ||
|
b03c1451ca | ||
|
81831b7912 | ||
|
2a25487d2b | ||
|
093e95e1f2 |
@ -1,8 +1,8 @@
|
||||
## Get Item
|
||||
|
||||
Version 1.0.1
|
||||
Version 1.1.1
|
||||
|
||||
This Minetest mod allows you to get easy access to all items of the game,
|
||||
This Luanti mod allows you to get easy access to all items of the game,
|
||||
including items that players might not supposed to get (e.g. items
|
||||
that are normally hidden from a Creative Mode inventory).
|
||||
|
||||
@ -25,6 +25,7 @@ If you have it, you can access items in 3 ways:
|
||||
|
||||
In the item window, you can drag out items at will into your
|
||||
inventory. Put items into the trash slot to destroy them.
|
||||
Enter somethin in the text field to filter out items by name.
|
||||
|
||||
## Credits
|
||||
|
||||
|
96
init.lua
96
init.lua
@ -13,6 +13,11 @@ local SLOTS_W = 10
|
||||
local SLOTS_H = 5
|
||||
local SLOTS = SLOTS_W * SLOTS_H
|
||||
|
||||
-- This determines how the items are sorted
|
||||
-- "by_type": Sort by item type (tool/craftitem/node/"getitem" items), then alphabetically by itemstring
|
||||
-- "abc": Alphabetically by itemstring
|
||||
local SORT_MODE = "abc"
|
||||
|
||||
local all_items_list -- cached list of all items
|
||||
|
||||
local function allow_check(player, msg_disallowed)
|
||||
@ -67,6 +72,47 @@ local function add_detached_inventories(player)
|
||||
detached_inventories[name] = { items = inv_items, trash = inv_trash }
|
||||
end
|
||||
|
||||
local sort_items_by_type = function(item1, item2)
|
||||
--[[ Sort items in this order:
|
||||
* Tools
|
||||
* Craftitems
|
||||
* Nodes
|
||||
* items from this mod (come last) ]]
|
||||
local def1 = minetest.registered_items[item1]
|
||||
local def2 = minetest.registered_items[item2]
|
||||
local tool1 = def1.type == "tool"
|
||||
local tool2 = def2.type == "tool"
|
||||
local craftitem1 = def1.type == "craft"
|
||||
local craftitem2 = def2.type == "craft"
|
||||
local node1 = def1.type == "node"
|
||||
local node2 = def2.type == "node"
|
||||
local getitem1 = string.sub(item1, 1, 8) == "getitem:"
|
||||
local getitem2 = string.sub(item2, 1, 8) == "getitem:"
|
||||
if getitem1 and not getitem2 then
|
||||
return false
|
||||
elseif not getitem1 and getitem2 then
|
||||
return true
|
||||
elseif tool1 and not tool2 then
|
||||
return true
|
||||
elseif not tool1 and tool2 then
|
||||
return false
|
||||
elseif craftitem1 and not craftitem2 then
|
||||
return true
|
||||
elseif not craftitem1 and craftitem2 then
|
||||
return false
|
||||
elseif node1 and not node2 then
|
||||
return true
|
||||
elseif not node1 and node2 then
|
||||
return false
|
||||
else
|
||||
return item1 < item2
|
||||
end
|
||||
end
|
||||
|
||||
local sort_items_alphabetically = function(item1, item2)
|
||||
return item1 < item2
|
||||
end
|
||||
|
||||
local collect_items = function(filter, lang_code)
|
||||
local items = {}
|
||||
if filter then
|
||||
@ -81,13 +127,13 @@ local collect_items = function(filter, lang_code)
|
||||
-- First, try to match original description
|
||||
if desc ~= "" then
|
||||
local ldesc = string.lower(desc)
|
||||
matches = string.match(ldesc, filter) ~= nil
|
||||
matches = string.find(ldesc, filter, 1, true) ~= nil
|
||||
-- Second, try to match translated description
|
||||
if not matches then
|
||||
local tdesc = minetest.get_translated_string(lang_code, desc)
|
||||
if tdesc ~= "" then
|
||||
tdesc = string.lower(tdesc)
|
||||
matches = string.match(tdesc, filter) ~= nil
|
||||
matches = string.find(tdesc, filter, 1, true) ~= nil
|
||||
end
|
||||
end
|
||||
-- Third, try to match translated short description
|
||||
@ -96,14 +142,14 @@ local collect_items = function(filter, lang_code)
|
||||
if sdesc ~= "" then
|
||||
sdesc = minetest.get_translated_string(lang_code, sdesc)
|
||||
sdesc = string.lower(sdesc)
|
||||
matches = string.match(sdesc, filter) ~= nil
|
||||
matches = string.find(sdesc, filter, 1, true) ~= nil
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
-- Fourth, try to match itemstring
|
||||
if not matches then
|
||||
matches = string.match(itemstring, filter) ~= nil
|
||||
matches = string.find(itemstring, filter, 1, true) ~= nil
|
||||
end
|
||||
|
||||
-- If item was matched, add to item list
|
||||
@ -115,41 +161,11 @@ local collect_items = function(filter, lang_code)
|
||||
end
|
||||
end
|
||||
end
|
||||
--[[ Sort items in this order:
|
||||
* Nodes
|
||||
* Tools
|
||||
* Craftitems
|
||||
* items from this mod (come last) ]]
|
||||
local function compare(item1, item2)
|
||||
local def1 = minetest.registered_items[item1]
|
||||
local def2 = minetest.registered_items[item2]
|
||||
local tool1 = def1.type == "tool"
|
||||
local tool2 = def2.type == "tool"
|
||||
local craftitem1 = def1.type == "craft"
|
||||
local craftitem2 = def2.type == "craft"
|
||||
local node1 = def1.type == "node"
|
||||
local node2 = def2.type == "node"
|
||||
local getitem1 = string.sub(item1, 1, 8) == "getitem:"
|
||||
local getitem2 = string.sub(item2, 1, 8) == "getitem:"
|
||||
if getitem1 and not getitem2 then
|
||||
return false
|
||||
elseif not getitem1 and getitem2 then
|
||||
return true
|
||||
elseif node1 and not node2 then
|
||||
return true
|
||||
elseif not node1 and node2 then
|
||||
return false
|
||||
elseif tool1 and not tool2 then
|
||||
return true
|
||||
elseif not tool1 and tool2 then
|
||||
return false
|
||||
elseif craftitem1 and not craftitem2 then
|
||||
return true
|
||||
elseif not craftitem1 and craftitem2 then
|
||||
return false
|
||||
else
|
||||
return item1 < item2
|
||||
end
|
||||
local compare
|
||||
if SORT_MODE == "by_type" then
|
||||
compare = sort_items_by_type
|
||||
elseif SORT_MODE == "abc" then
|
||||
compare = sort_items_alphabetically
|
||||
end
|
||||
table.sort(items, compare)
|
||||
|
||||
@ -214,7 +230,7 @@ local function get_formspec(page, name)
|
||||
if current_max_pages[name] > 0 then
|
||||
inventory_list = "list[detached:getitem_items_"..name..";main;0,0;"..SLOTS_W..","..SLOTS_H..";"..start.."]"
|
||||
else
|
||||
inventory_list = "label[3.5,2.5;"..F(S("No items found.")).."]"
|
||||
inventory_list = "label[2.5,2.5;"..F(S("No items found.")).."]"
|
||||
if search_text ~= "" then
|
||||
inventory_list = inventory_list .. "button[2.5,3.25;3,0.8;search_button_reset_big;"..F(S("Reset search")).."]"
|
||||
end
|
||||
|
@ -1,14 +1,16 @@
|
||||
# textdomain: getitem
|
||||
Get Item=Gegenstand erhalten
|
||||
Allows you to get all items=Erlaubt einem, alle Gegenstände zu erhalten
|
||||
You can't take items ('give' privilege required).=Sie können keine Gegenstände entnehmen („give“-Privileg benötigt).
|
||||
You can't trash items ('give' privilege required).=Sie können keine Gegenstände entsorgen („give“-Privileg benötigt).
|
||||
<=<
|
||||
>=>
|
||||
Page: @1/@2=Seite: @1/@2
|
||||
No items found.=
|
||||
Reset search=
|
||||
No items found.=Keine Gegenstände gefunden.
|
||||
Reset search=Suche zurücksetzen
|
||||
Trash:=Müll:
|
||||
Search=
|
||||
X=
|
||||
Search=Suchen
|
||||
X=X
|
||||
You need to have the 'give' privilege to use this.=Sie benötigen das „give“-Privileg, um dies benutzen zu können.
|
||||
Show a dialog to receive all items=Zeigt einen Dialog, aus dem man alle Gegenstände entnehmen kann.
|
||||
Bag of Everything=Tasche mit Allem
|
||||
|
@ -1,4 +1,6 @@
|
||||
# textdomain: getitem
|
||||
Get Item=
|
||||
Allows you to get all items=
|
||||
You can't take items ('give' privilege required).=
|
||||
You can't trash items ('give' privilege required).=
|
||||
<=
|
||||
|
Loading…
x
Reference in New Issue
Block a user