diff --git a/.github/workflows/check-release.yml b/.github/workflows/check-release.yml new file mode 100644 index 0000000..47313ff --- /dev/null +++ b/.github/workflows/check-release.yml @@ -0,0 +1,11 @@ +on: [push, pull_request] +name: Check & Release +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - name: lint + uses: Roang-zero1/factorio-mod-luacheck@master + with: + luacheckrc_url: https://raw.githubusercontent.com/minetest-mods/unified_inventory/master/.luacheckrc diff --git a/.luacheckrc b/.luacheckrc new file mode 100644 index 0000000..9fb6a7c --- /dev/null +++ b/.luacheckrc @@ -0,0 +1,20 @@ +unused_args = false +allow_defined_top = true +max_line_length = 999 + +globals = { + "unified_inventory", +} + +read_globals = { + string = {fields = {"split", "trim"}}, + table = {fields = {"copy", "getn"}}, + + "minetest", "vector", + "ItemStack", "datastorage", + + "hb", +} + +files["callbacks.lua"].ignore = { "player", "draw_lite_mode" } +files["bags.lua"].ignore = { "player" } diff --git a/README.md b/README.md index 15802c6..8c917ec 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,9 @@ # Unified Inventory +[![](https://github.com/minetest-mods/unified_inventory/workflows/Check%20&%20Release/badge.svg)](https://github.com/minetest-mods/unified_inventory/actions) + +![Screenshot](screenshot.png) + Unified Inventory replaces the default survival and creative inventory. @@ -13,15 +17,14 @@ Unified Inventory replaces the default survival and creative inventory. * Home function to teleport * Trash slot * Lite mode: reduces the item browser width + * `minetest.conf` setting `unified_inventory_lite = true` * Mod API for modders: see [mod_api.txt](doc/mod_api.txt) * Setting-determinated features: see [settingtypes.txt](settingtypes.txt) ## Requirements - * Minetest 5.0.0+ since commit 4403b69 - * Minetest 0.4.16+ prior commit 4403b69 - + * Minetest 5.0.0+ # Licenses diff --git a/api.lua b/api.lua index 071900d..d24135b 100644 --- a/api.lua +++ b/api.lua @@ -16,8 +16,8 @@ minetest.after(0.01, function() table.insert(unified_inventory.items_list, name) local all_names = rev_aliases[name] or {} table.insert(all_names, name) - for _, name in ipairs(all_names) do - local recipes = minetest.get_all_craft_recipes(name) + for _, player_name in ipairs(all_names) do + local recipes = minetest.get_all_craft_recipes(player_name) if recipes then for _, recipe in ipairs(recipes) do diff --git a/bags.lua b/bags.lua index 1ebbdd3..c61c982 100644 --- a/bags.lua +++ b/bags.lua @@ -1,4 +1,4 @@ ---[[ +--[[ Bags for Minetest Copyright (c) 2012 cornernote, Brett O'Donnell @@ -166,7 +166,6 @@ local function load_bags_metadata(player, bags_inv) end minetest.register_on_joinplayer(function(player) - local player_inv = player:get_inventory() local player_name = player:get_player_name() local bags_inv = minetest.create_detached_inventory(player_name .. "_bags",{ on_put = function(inv, listname, index, stack, player) @@ -250,7 +249,7 @@ if minetest.get_modpath("farming") ~= nil then minetest.register_craft({ output = "unified_inventory:bag_small", recipe = { - {"", "farming:cotton", ""}, + {"", "farming:string", ""}, {"group:wool", "group:wool", "group:wool"}, {"group:wool", "group:wool", "group:wool"}, }, @@ -260,8 +259,8 @@ if minetest.get_modpath("farming") ~= nil then output = "unified_inventory:bag_medium", recipe = { {"", "", ""}, - {"farming:cotton", "unified_inventory:bag_small", "farming:cotton"}, - {"farming:cotton", "unified_inventory:bag_small", "farming:cotton"}, + {"farming:string", "unified_inventory:bag_small", "farming:string"}, + {"farming:string", "unified_inventory:bag_small", "farming:string"}, }, }) @@ -269,8 +268,8 @@ if minetest.get_modpath("farming") ~= nil then output = "unified_inventory:bag_large", recipe = { {"", "", ""}, - {"farming:cotton", "unified_inventory:bag_medium", "farming:cotton"}, - {"farming:cotton", "unified_inventory:bag_medium", "farming:cotton"}, + {"farming:string", "unified_inventory:bag_medium", "farming:string"}, + {"farming:string", "unified_inventory:bag_medium", "farming:string"}, }, }) end diff --git a/callbacks.lua b/callbacks.lua index 8bfe6b6..bc90237 100644 --- a/callbacks.lua +++ b/callbacks.lua @@ -28,7 +28,6 @@ minetest.register_on_joinplayer(function(player) -- Refill slot local refill = minetest.create_detached_inventory(player_name.."refill", { allow_put = function(inv, listname, index, stack, player) - local player_name = player:get_player_name() if unified_inventory.is_creative(player_name) then return stack:get_count() else @@ -36,7 +35,6 @@ minetest.register_on_joinplayer(function(player) end end, on_put = function(inv, listname, index, stack, player) - local player_name = player:get_player_name() local handle_refill = (minetest.registered_items[stack:get_name()] or {}).on_refill or default_refill stack = handle_refill(stack) inv:set_stack(listname, index, stack) diff --git a/internal.lua b/internal.lua index 43914ef..65225e1 100644 --- a/internal.lua +++ b/internal.lua @@ -220,11 +220,10 @@ function unified_inventory.get_formspec(player, page) else local dir = unified_inventory.active_search_direction[player_name] local list_index = unified_inventory.current_index[player_name] - local page = math.floor(list_index / (ui_peruser.items_per_page) + 1) + local page2 = math.floor(list_index / (ui_peruser.items_per_page) + 1) local pagemax = math.floor( (#unified_inventory.filtered_items_list[player_name] - 1) / (ui_peruser.items_per_page) + 1) - local item = {} for y = 0, ui_peruser.pagerows - 1 do for x = 0, ui_peruser.pagecols - 1 do local name = unified_inventory.filtered_items_list[player_name][list_index] @@ -259,7 +258,7 @@ function unified_inventory.get_formspec(player, page) end end formspec[n] = "label[8.2,"..ui_peruser.form_header_y..";"..F(S("Page")) .. ": " - .. S("@1 of @2",page,pagemax).."]" + .. S("@1 of @2",page2,pagemax).."]" end n= n+1 diff --git a/item_names.lua b/item_names.lua index d374b14..a1368f8 100644 --- a/item_names.lua +++ b/item_names.lua @@ -1,25 +1,25 @@ -- Based on 4itemnames mod by 4aiman -local item_names = {} -- [player_name] = { hud, dtime, itemname } +local item_names = {} -- [player_name] = { hud, dtime, itemname } local dlimit = 3 -- HUD element will be hidden after this many seconds -local air_hud_mod = minetest.get_modpath("4air") -local hud_mod = minetest.get_modpath("hud") local hudbars_mod = minetest.get_modpath("hudbars") local function set_hud(player) local player_name = player:get_player_name() - local off = {x=0, y=-70} - if air_hud_mod or hud_mod then - off.y = off.y - 20 - elseif hudbars_mod then - off.y = off.y + 13 + local off = {x=0, y=-65} + if hudbars_mod then + -- Assume no alignment (2 per line) + off.y = off.y - math.ceil(hb.hudbars_count / 2) * 25 + else + off.y = off.y - 25 end + item_names[player_name] = { hud = player:hud_add({ hud_elem_type = "text", position = {x=0.5, y=1}, offset = off, - alignment = {x=0, y=0}, + alignment = {x=0, y=-1}, number = 0xFFFFFF, text = "", }), diff --git a/locale/unified_inventory.es.tr b/locale/unified_inventory.es.tr index b90bad9..18b6c77 100644 --- a/locale/unified_inventory.es.tr +++ b/locale/unified_inventory.es.tr @@ -1,38 +1,100 @@ # textdomain: unified_inventory -Crafting=Elaboración -Cooking=hornear -Bags=Bolsas -Bag @1=Bolsa @1 -Small Bag=Bolsa Pequeña -Medium Bag=Bolsa Mediana -Large Bag=Bolsa Grande -Page=Página -@1 of @2=@1 de @2 -Filter=Filtro -Can use the creative inventory=Puede usar el inventario creativo -Crafting Guide=Guía de Elaboración -Set home position=Posición en el mundo -Home position set to: @1=Posición de hogar cambiada a: @1 -You don't have the "home" privilege!=¡No tienes el privilegio "home"! -Time of day set to 6am=Hora del día cambiada a 6AM -You don't have the settime privilege!=¡No tienes el privilegio "settime"! -Time of day set to 9pm=Hora del día cambiada a 9PM -Inventory cleared!=¡Inventario limpio! -Trash:=Basura: -Refill:=Rellenar: -Recipe @1 of @2=Receta @1 de @2 -Result=Resultado -To craft grid:=Copiar al cuadro de elaboración -All=Todos + +# waypoints.lua + White=Blanco Yellow=Amarillo Red=Rojo Green=Verde Blue=Azul -Waypoints=Puntos de paso -Waypoint @1=Puntos de paso @1 -Waypoint active=Punto de paso activo -Waypoint inactive=Punto de paso inactivo +Waypoints=Puntos +Select Waypoint #@1=Seleccionar Punto #@1 +Waypoint @1=Punto @1 +Set waypoint to current location=Establecer el punto a la ubicación actual +Make waypoint @1=Hacer punto @1 +invisible=invisible +visible=visible +@1 display of waypoint coordinates=Visualizar coordenadas del punto @1 +Disable=Deshabilitado +Enable=Habilitado +Change color of waypoint display=Cambiar el color del punto +Edit waypoint name=Editar nombre del punto +Waypoint active=Punto activo +Waypoint inactive=Punto inactivo +Finish editing=Terminar edición World position=Posición en el mundo Name=Nombre -HUD text color=Color del HUD +HUD text color=Color del texto de la Interfaz + +# group.lua + + and = y + +# register.lua + +Can use the creative inventory=Puede usar el inventario creativo +Forces Unified Inventory to be displayed in Full mode if Lite mode is configured globally=Obliga al Inventario Unificado a mostrarse en modo Completo si el modo Simple está configurado globalmente +Crafting Grid=Cuadricula de Elaboración +Crafting Guide=Guía de Elaboración +Set home position=Establecer posición de la casa +Home position set to: @1=Posición de la casa cambiada a: @1 +You don't have the \"home\" privilege!=¡No tienes el privilegio \"home\"! +Go home=Ir a casa +Set time to day=Cambiar a dia +Set time to night=Cambiar a noche +Time of day set to 6am=Hora del día cambiada a 6 AM +Time of day set to 9pm=Hora del día cambiada a 9 PM +You don't have the settime privilege!=¡No tienes el privilegio "settime"! +Clear inventory=Limpiar inventario +Inventory cleared!=¡Inventario limpio! +This button has been disabled outside=Este botón ha sido deshabilitado +Crafting=Elaboración +Trash:=Basura: +Refill:=Rellenar: +Any item belonging to the @1 group=Cualquier elemento que pertenezca al grupo @1 +Any item belonging to the groups @1=Cualquier elemento perteneciente a los grupos @1 +Recipe @1 of @2=Receta @1 de @2 +Usage @1 of @2=Uso @1 de @2 +No recipes=No tiene receta +No usages=No tiene uso +Result=Resultado +Ingredient=Ingrediente +Show next recipe=Mostrar la siguiente receta +Show next usage=Mostrar el siguiente uso +Show previous recipe=Mostrar la receta anterior +Show previous usage=Mostrar el uso anterior +@1 (@2)=@1 (@2) +Give me:=Dame: +This recipe is too@nlarge to be displayed.=Esta receta es demasiado@ngrande para ser mostrada. +To craft grid:=Construir: +All=Todos + +# api.lua + +Mixing=Mezclar +Cooking=Hornear +Digging=Recoger + +# internal.lua + +First page=Primera página +Back three pages=Volver tres páginas +Back one page=Volver una página +Forward one page=Avanzar una página +Forward three pages=Avanzar tres páginas +Last page=Ultima Pagina +Search=Buscar +Reset search and display everything=Limpiar la busqueda y mostrar todo +No matching items=No se encontraron elementos +No matches.=No hay resultados. +Page=Página +@1 of @2=@1 de @2 +Filter=Filtro + +# bags.lua + +Bags=Bolsos +Bag @1=Bolso @1 +Small Bag=Bolso Pequeño +Medium Bag=Bolso Mediano +Large Bag=Bolso Grande diff --git a/locale/unified_inventory.template.tr b/locale/unified_inventory.template.tr new file mode 100644 index 0000000..2ea4fca --- /dev/null +++ b/locale/unified_inventory.template.tr @@ -0,0 +1,100 @@ +# textdomain: unified_inventory + +# waypoints.lua + +White= +Yellow= +Red= +Green= +Blue= +Waypoints= +Select Waypoint #@1= +Waypoint @1= +Set waypoint to current location= +Make waypoint @1= +invisible= +visible= +@1 display of waypoint coordinates= +Disable= +Enable= +Change color of waypoint display= +Edit waypoint name= +Waypoint active= +Waypoint inactive= +Finish editing= +World position= +Name= +HUD text color= + +# group.lua + + and = + +# register.lua + +Can use the creative inventory= +Forces Unified Inventory to be displayed in Full mode if Lite mode is configured globally= +Crafting Grid= +Crafting Guide= +Set home position= +Home position set to: @1= +You don't have the \"home\" privilege!= +Go home= +Set time to day= +Set time to night= +Time of day set to 6am= +Time of day set to 9pm= +You don't have the settime privilege!= +Clear inventory= +Inventory cleared!= +This button has been disabled outside= +Crafting= +Trash:= +Refill:= +Any item belonging to the @1 group= +Any item belonging to the groups @1= +Recipe @1 of @2= +Usage @1 of @2= +No recipes= +No usages= +Result= +Ingredient= +Show next recipe= +Show next usage= +Show previous recipe= +Show previous usage= +@1 (@2)= +Give me:= +This recipe is too@nlarge to be displayed.= +To craft grid:= +All= + +# api.lua + +Mixing= +Cooking= +Digging= + +# internal.lua + +First page= +Back three pages= +Back one page= +Forward one page= +Forward three pages= +Last page= +Search= +Reset search and display everything= +No matching items= +No matches.= +Page= +@1 of @2= +Filter= + +# bags.lua + +Bags= +Bag @1= +Small Bag= +Medium Bag= +Large Bag= diff --git a/locale/unified_inventory.zh_CN.tr b/locale/unified_inventory.zh_CN.tr new file mode 100644 index 0000000..524ad67 --- /dev/null +++ b/locale/unified_inventory.zh_CN.tr @@ -0,0 +1,78 @@ +# textdomain: unified_inventory +# traslation by: IFRFSX(BingFengFSX) +#Email: IFRFSX@Protonmail.com + +Crafting=合成 +Mixing=混合 +Cooking=烹饪 +Digging=挖出 +Bags=背包 +Bag @1=背包@1 +Small Bag=小背包 +Medium Bag=中背包 +Large Bag=大背包 + and = 和 +First page=第一页 +Back three pages=后退三页 +Back one page=后退一页 +Forward one page=前进一页 +Forward three pages=前进三页 +Last page=最后一页 +Search=搜索 +No matching items=没有匹配物品 +No matches.=没有匹配 +Page=页面 +@1 of @2=第@1页,共@2页 +Filter=过滤器 +Can use the creative inventory=可以使用创造背包 +Crafting Grid=合成表 +Crafting Guide=合成指南 +Set home position=设置家的位置 +Home position set to: @1=家的位置设置到: @1 +You don't have the "home" privilege!=你没有“home”权限! +Go home=回家 +Set time to day=设置时间到白天 +Time of day set to 6am=时间设置到早晨6点 +You don't have the settime privilege!=你没有“settime”权限! +Set time to night=设置时间到晚上 +Time of day set to 9pm=时间设置到晚上9点 + +Inventory cleared!=清空背包 +Clear inventory=清空背包 + +Trash:=丢弃: +Refill:=填满: +Recipe @1 of @2=第@1配方,共@2个 +Usage @1 of @2=第@1用法,共@2个 +No recipes=没有配方 +No usages=没有用法 +Result=结果 +Ingredient=原料 +Give me:=给予: +To craft grid:=填充物品到合成表 +All=全部 +White=白 +Yellow=黄 +Red=红 +Green=绿 +Blue=蓝 +Waypoints=航路点 +Select Waypoint #@1=查询航路点 #@1 +Waypoint @1=航路点 @1 +Set waypoint to current location=将航路点设置到当前位置 +invisible=不可见的 +visible=可见的 +Make waypoint @1=设置航路点 @1 +@1 display of waypoint coordinates=显示航路点@1坐标 +Change color of waypoint display=改变航路点显示的颜色 +Edit waypoint name=编辑航路点名称 +Waypoint active=航路点已激活 +Waypoint inactive=航路点未激活 +Finish editing=完成编辑 +World position=世界位置 +Name=名称 +HUD text color=HUD文本颜色 + +#new + +Reset search and display everything=重置搜索并显示所有物品 diff --git a/locale/unified_inventory.zh_TW.tr b/locale/unified_inventory.zh_TW.tr new file mode 100644 index 0000000..fa81bbc --- /dev/null +++ b/locale/unified_inventory.zh_TW.tr @@ -0,0 +1,78 @@ +# textdomain: unified_inventory +# traslation by: IFRFSX(BingFengFSX) +#Email: IFRFSX@Protonmail.com + +Crafting=合成 +Mixing=混合 +Cooking=烹飪 +Digging=挖出 +Bags=揹包 +Bag @1=揹包@1 +Small Bag=小揹包 +Medium Bag=中揹包 +Large Bag=大揹包 + and = 和 +First page=第一頁 +Back three pages=後退三頁 +Back one page=後退一頁 +Forward one page=前進一頁 +Forward three pages=前進三頁 +Last page=最後一頁 +Search=搜索 +No matching items=沒有匹配物品 +No matches.=沒有匹配 +Page=頁面 +@1 of @2=第@1頁,共@2頁 +Filter=過濾器 +Can use the creative inventory=可以使用創造揹包 +Crafting Grid=合成表 +Crafting Guide=合成指南 +Set home position=設置家的位置 +Home position set to: @1=家的位置設置到: @1 +You don't have the "home" privilege!=你沒有“home”權限! +Go home=回家 +Set time to day=設置時間到白天 +Time of day set to 6am=時間設置到早晨6點 +You don't have the settime privilege!=你沒有“settime”權限! +Set time to night=設置時間到晚上 +Time of day set to 9pm=時間設置到晚上9點 + +Inventory cleared!=清空揹包 +Clear inventory=清空揹包 + +Trash:=丟棄: +Refill:=填滿: +Recipe @1 of @2=第@1配方,共@2個 +Usage @1 of @2=第@1用法,共@2個 +No recipes=沒有配方 +No usages=沒有用法 +Result=結果 +Ingredient=原料 +Give me:=給予: +To craft grid:=填充物品到合成表 +All=全部 +White=白 +Yellow=黃 +Red=紅 +Green=綠 +Blue=藍 +Waypoints=航路點 +Select Waypoint #@1=查詢航路點 #@1 +Waypoint @1=航路點 @1 +Set waypoint to current location=將航路點設置到當前位置 +invisible=不可見的 +visible=可見的 +Make waypoint @1=設置航路點 @1 +@1 display of waypoint coordinates=顯示航路點@1座標 +Change color of waypoint display=改變航路點顯示的顏色 +Edit waypoint name=編輯航路點名稱 +Waypoint active=航路點已激活 +Waypoint inactive=航路點未激活 +Finish editing=完成編輯 +World position=世界位置 +Name=名稱 +HUD text color=HUD文本顏色 + +#new + +Reset search and display everything=重置搜索並顯示所有物品 diff --git a/register.lua b/register.lua index f2907a0..b77aa87 100644 --- a/register.lua +++ b/register.lua @@ -337,7 +337,7 @@ unified_inventory.register_page("craftguide", { else -- Error fs[#fs + 1] = string.format("label[2,%f;%s]", - formspecy, F(S("This recipe is too\nlarge to be displayed."))) + formspecy, F(S("This recipe is too@nlarge to be displayed."))) end if craft_type.uses_crafting_grid and display_size.width <= 3 then