Add GitHub workflow (#149)

This commit is contained in:
David Leal 2020-03-25 11:46:35 -06:00 committed by GitHub
parent c0bd9977be
commit 606ba6a1a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 37 additions and 11 deletions

11
.github/workflows/check-release.yml vendored Normal file

@ -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

18
.luacheckrc Normal file

@ -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" }

@ -1,5 +1,7 @@
# Unified Inventory # 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) ![Screenshot](screenshot.png)
Unified Inventory replaces the default survival and creative inventory. 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+ * Minetest 5.0.0+
# Licenses # Licenses
Copyright (C) 2012-2014 Maciej Kasatkin (RealBadAngel) Copyright (C) 2012-2014 Maciej Kasatkin (RealBadAngel)

@ -16,8 +16,8 @@ minetest.after(0.01, function()
table.insert(unified_inventory.items_list, name) table.insert(unified_inventory.items_list, name)
local all_names = rev_aliases[name] or {} local all_names = rev_aliases[name] or {}
table.insert(all_names, name) table.insert(all_names, name)
for _, name in ipairs(all_names) do for _, player_name in ipairs(all_names) do
local recipes = minetest.get_all_craft_recipes(name) local recipes = minetest.get_all_craft_recipes(player_name)
if recipes then if recipes then
for _, recipe in ipairs(recipes) do for _, recipe in ipairs(recipes) do

@ -166,7 +166,6 @@ local function load_bags_metadata(player, bags_inv)
end end
minetest.register_on_joinplayer(function(player) minetest.register_on_joinplayer(function(player)
local player_inv = player:get_inventory()
local player_name = player:get_player_name() local player_name = player:get_player_name()
local bags_inv = minetest.create_detached_inventory(player_name .. "_bags",{ local bags_inv = minetest.create_detached_inventory(player_name .. "_bags",{
on_put = function(inv, listname, index, stack, player) on_put = function(inv, listname, index, stack, player)

@ -28,7 +28,6 @@ minetest.register_on_joinplayer(function(player)
-- Refill slot -- Refill slot
local refill = minetest.create_detached_inventory(player_name.."refill", { local refill = minetest.create_detached_inventory(player_name.."refill", {
allow_put = function(inv, listname, index, stack, player) allow_put = function(inv, listname, index, stack, player)
local player_name = player:get_player_name()
if unified_inventory.is_creative(player_name) then if unified_inventory.is_creative(player_name) then
return stack:get_count() return stack:get_count()
else else
@ -36,7 +35,6 @@ minetest.register_on_joinplayer(function(player)
end end
end, end,
on_put = function(inv, listname, index, stack, player) 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 local handle_refill = (minetest.registered_items[stack:get_name()] or {}).on_refill or default_refill
stack = handle_refill(stack) stack = handle_refill(stack)
inv:set_stack(listname, index, stack) inv:set_stack(listname, index, stack)

@ -215,11 +215,10 @@ function unified_inventory.get_formspec(player, page)
else else
local dir = unified_inventory.active_search_direction[player_name] local dir = unified_inventory.active_search_direction[player_name]
local list_index = unified_inventory.current_index[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( local pagemax = math.floor(
(#unified_inventory.filtered_items_list[player_name] - 1) (#unified_inventory.filtered_items_list[player_name] - 1)
/ (ui_peruser.items_per_page) + 1) / (ui_peruser.items_per_page) + 1)
local item = {}
for y = 0, ui_peruser.pagerows - 1 do for y = 0, ui_peruser.pagerows - 1 do
for x = 0, ui_peruser.pagecols - 1 do for x = 0, ui_peruser.pagecols - 1 do
local name = unified_inventory.filtered_items_list[player_name][list_index] local name = unified_inventory.filtered_items_list[player_name][list_index]
@ -254,7 +253,7 @@ function unified_inventory.get_formspec(player, page)
end end
end end
formspec[n] = "label[8.2,"..ui_peruser.form_header_y..";"..F(S("Page")) .. ": " 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 end
n= n+1 n= n+1