From 606ba6a1a3ad6c425e8834975fe47203f8d9fa67 Mon Sep 17 00:00:00 2001 From: David Leal Date: Wed, 25 Mar 2020 11:46:35 -0600 Subject: [PATCH] Add GitHub workflow (#149) --- .github/workflows/check-release.yml | 11 +++++++++++ .luacheckrc | 18 ++++++++++++++++++ README.md | 3 ++- api.lua | 4 ++-- bags.lua | 3 +-- callbacks.lua | 2 -- internal.lua | 5 ++--- item_names.lua | 2 +- 8 files changed, 37 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/check-release.yml create mode 100644 .luacheckrc 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..709c485 --- /dev/null +++ b/.luacheckrc @@ -0,0 +1,18 @@ +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", +} + +files["callbacks.lua"].ignore = { "player", "draw_lite_mode" } +files["bags.lua"].ignore = { "player" } diff --git a/README.md b/README.md index be95e09..8c917ec 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # 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. @@ -24,7 +26,6 @@ Unified Inventory replaces the default survival and creative inventory. * Minetest 5.0.0+ - # Licenses Copyright (C) 2012-2014 Maciej Kasatkin (RealBadAngel) 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 a365139..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) 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 05dc5f5..ee8b4a9 100644 --- a/internal.lua +++ b/internal.lua @@ -215,11 +215,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] @@ -254,7 +253,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..111c9ee 100644 --- a/item_names.lua +++ b/item_names.lua @@ -1,6 +1,6 @@ -- 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")