Reduce code + Remove github workflow

This commit is contained in:
Jean-Patrick Guerrero 2021-11-29 19:15:14 +01:00
parent 91af3b73d2
commit 27226a0d1b
14 changed files with 46 additions and 82 deletions

View File

@ -1,21 +0,0 @@
name: Luacheck
on: [push, pull_request]
jobs:
luacheck:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup lua
uses: leafo/gh-actions-lua@v8
with:
luaVersion: 5.1
- name: Setup luarocks
uses: leafo/gh-actions-luarocks@v4
- name: Setup luacheck
run: luarocks install luacheck
- name: Run luacheck linter
run: luacheck .

View File

@ -14,7 +14,7 @@ This mod requires **Minetest 5.4+**
- Progressive Mode¹
- Quick Crafting
- 3D Player Model Real-Time Preview
- Isometric Area Preview
- Isometric Map Preview
- Inventory Sorting (+ options: compression, reverse mode, automation, etc.)
- Item List Compression (**`moreblocks`** is supported)
- Item Bookmarks

View File

@ -1,11 +1,10 @@
local make_fs = i3.files.gui()
local gmatch, split = i3.get("gmatch", "split")
local S, err, fmt, reg_items = i3.get("S", "err", "fmt", "reg_items")
local sorter, sort_inventory = i3.get("sorter", "sort_inventory")
local sort, concat, copy, insert, remove = i3.get("sort", "concat", "copy", "insert", "remove")
local true_str, true_table, is_str, is_func, is_table, clean_name =
i3.get("true_str", "true_table", "is_str", "is_func", "is_table", "clean_name")
IMPORT("gmatch", "split")
IMPORT("S", "err", "fmt", "reg_items")
IMPORT("sorter", "sort_inventory")
IMPORT("sort", "concat", "copy", "insert", "remove")
IMPORT("true_str", "true_table", "is_str", "is_func", "is_table", "clean_name")
function i3.register_craft_type(name, def)
if not true_str(name) then

View File

@ -1,8 +1,7 @@
local set_fs = i3.set_fs
local ItemStack = ItemStack
local S, ES, fmt, msg, slz, dslz = i3.get("S", "ES", "fmt", "msg", "slz", "dslz")
local get_group, play_sound, get_detached_inv, create_inventory =
i3.get("get_group", "play_sound", "get_detached_inv", "create_inventory")
IMPORT("S", "ES", "fmt", "msg", "slz", "dslz", "ItemStack")
IMPORT("get_group", "play_sound", "get_detached_inv", "create_inventory")
local function get_content(content)
local t = {}

View File

@ -1,14 +1,9 @@
local replacements = {fuel = {}}
local ItemStack = ItemStack
local draw_cube = core.inventorycube
local fmt, reg_items, reg_aliases, reg_nodes = i3.get("fmt", "reg_items", "reg_aliases", "reg_nodes")
local maxn, copy, insert, sort, match, sub = i3.get("maxn", "copy", "insert", "sort", "match", "sub")
local is_group, extract_groups, item_has_groups, groups_to_items =
i3.get("is_group", "extract_groups", "item_has_groups", "groups_to_items")
local true_str, true_table, is_table, valid_item, table_merge, table_replace, rcp_eq =
i3.get("true_str", "true_table", "is_table", "valid_item", "table_merge", "table_replace", "rcp_eq")
IMPORT("maxn", "copy", "insert", "sort", "match", "sub")
IMPORT("is_group", "extract_groups", "item_has_groups", "groups_to_items")
IMPORT("fmt", "reg_items", "reg_aliases", "reg_nodes", "draw_cube", "ItemStack")
IMPORT("true_str", "true_table", "is_table", "valid_item", "table_merge", "table_replace", "rcp_eq")
local function get_burntime(item)
return core.get_craft_result{method = "fuel", items = {item}}.time

View File

@ -1,19 +1,14 @@
local _, get_inventory_fs = i3.files.gui()
local set_fs = i3.set_fs
local ItemStack = ItemStack
local S, min, random = i3.get("S", "min", "random")
local reg_items, reg_aliases = i3.get("reg_items", "reg_aliases")
local fmt, find, match, sub, lower, split = i3.get("fmt", "find", "match", "sub", "lower", "split")
local vec_eq, vec_round = i3.get("vec_eq", "vec_round")
local sort, copy, insert, remove, indexof = i3.get("sort", "copy", "insert", "remove", "indexof")
local msg, is_fav, pos_to_str, str_to_pos, add_hud_waypoint, play_sound, spawn_item =
i3.get("msg", "is_fav", "pos_to_str", "str_to_pos", "add_hud_waypoint", "play_sound", "spawn_item")
local search, get_sorting_idx, sort_inventory, sort_by_category, get_recipes, get_detached_inv =
i3.get("search", "get_sorting_idx", "sort_inventory", "sort_by_category", "get_recipes", "get_detached_inv")
local valid_item, get_stack, craft_stack, clean_name, compressible, check_privs, safe_teleport =
i3.get("valid_item", "get_stack", "craft_stack", "clean_name", "compressible", "check_privs", "safe_teleport")
IMPORT("vec_eq", "vec_round")
IMPORT("reg_items", "reg_aliases")
IMPORT("S", "min", "random", "ItemStack")
IMPORT("sort", "copy", "insert", "remove", "indexof")
IMPORT("fmt", "find", "match", "sub", "lower", "split")
IMPORT("msg", "is_fav", "pos_to_str", "str_to_pos", "add_hud_waypoint", "play_sound", "spawn_item")
IMPORT("search", "get_sorting_idx", "sort_inventory", "sort_by_category", "get_recipes", "get_detached_inv")
IMPORT("valid_item", "get_stack", "craft_stack", "clean_name", "compressible", "check_privs", "safe_teleport")
local function reset_data(data)
data.filter = ""

View File

@ -624,6 +624,7 @@ local _ = {
msg = msg,
-- Misc. functions
ItemStack = ItemStack,
valid_item = valid_item,
spawn_item = spawn_item,
clean_name = clean_name,
@ -636,6 +637,7 @@ local _ = {
slz = core.serialize,
dslz = core.deserialize,
ESC = core.formspec_escape,
draw_cube = core.inventorycube,
get_group = core.get_item_group,
pos_to_str = core.pos_to_string,
str_to_pos = core.string_to_pos,

View File

@ -1,4 +1,4 @@
local fmt, copy, insert = i3.get("fmt", "copy", "insert")
IMPORT("fmt", "copy", "insert")
local wood_types = {
"acacia_wood", "aspen_wood", "junglewood", "pine_wood",

View File

@ -1,5 +1,5 @@
local set_fs = i3.set_fs
local fmt, play_sound, create_inventory = i3.get("fmt", "play_sound", "create_inventory")
IMPORT("fmt", "play_sound", "create_inventory")
local trash = create_inventory("i3_trash", {
allow_put = function(_, _, _, stack)

View File

@ -1,4 +1,4 @@
local S = i3.get("S")
IMPORT("S")
i3.group_stereotypes = {
dye = "dye:white",

View File

@ -1,26 +1,21 @@
local damage_enabled = core.settings:get_bool "enable_damage"
local damage_enabled = core.settings:get_bool"enable_damage"
local model_aliases = i3.files.model_alias()
local PNG, styles, fs_elements, colors = i3.files.styles()
local ItemStack = ItemStack
local sprintf = string.format
local VoxelArea, VoxelManip = VoxelArea, VoxelManip
local S, ES, translate = i3.get("S", "ES", "translate")
local clr, ESC, check_privs = i3.get("clr", "ESC", "check_privs")
local vec_new, vec_sub, vec_round = i3.get("vec_new", "vec_sub", "vec_round")
local min, max, floor, ceil, round = i3.get("min", "max", "floor", "ceil", "round")
local sprintf, find, match, sub, upper = i3.get("fmt", "find", "match", "sub", "upper")
local reg_items, reg_tools, reg_entities = i3.get("reg_items", "reg_tools", "reg_entities")
local maxn, sort, concat, copy, insert, remove, unpack =
i3.get("maxn", "sort", "concat", "copy", "insert", "remove", "unpack")
local true_str, is_fav, is_num, get_group, str_to_pos =
i3.get("true_str", "is_fav", "is_num", "get_group", "str_to_pos")
local groups_to_items, compression_active, compressible =
i3.get("groups_to_items", "compression_active", "compressible")
local get_sorting_idx, is_group, extract_groups, item_has_groups =
i3.get("get_sorting_idx", "is_group", "extract_groups", "item_has_groups")
IMPORT("clr", "ESC", "check_privs")
IMPORT("find", "match", "sub", "upper")
IMPORT("vec_new", "vec_sub", "vec_round")
IMPORT("S", "ES", "translate", "ItemStack")
IMPORT("min", "max", "floor", "ceil", "round")
IMPORT("reg_items", "reg_tools", "reg_entities")
IMPORT("groups_to_items", "compression_active", "compressible")
IMPORT("true_str", "is_fav", "is_num", "get_group", "str_to_pos")
IMPORT("maxn", "sort", "concat", "copy", "insert", "remove", "unpack")
IMPORT("get_sorting_idx", "is_group", "extract_groups", "item_has_groups")
local function fmt(elem, ...)
if not fs_elements[elem] then

View File

@ -1,5 +1,4 @@
local get_player_by_name, str_to_pos, add_hud_waypoint =
i3.get("get_player_by_name", "str_to_pos", "add_hud_waypoint")
IMPORT("get_player_by_name", "str_to_pos", "add_hud_waypoint")
local function init_hud(player)
local name = player:get_player_name()

View File

@ -36,6 +36,10 @@ local operators = {
}
local function compile(data)
data = data:gsub("IMPORT%((.-)%)", function(a)
return "local " .. a:gsub("\"", "") .. " = i3.get(" .. a .. ")"
end)
for op, func in pairs(operators) do
data = data:gsub("(" .. var .. "+)%s?" .. op .. "%s?(" .. var .. "*)", func)
end

View File

@ -1,13 +1,10 @@
local set_fs = i3.set_fs
local hud_notif = i3.hud_notif
local fmt, search, table_merge, array_diff =
i3.get("fmt", "search", "table_merge", "array_diff")
local is_group, extract_groups, item_has_groups, apply_recipe_filters =
i3.get("is_group", "extract_groups", "item_has_groups", "apply_recipe_filters")
local POLL_FREQ = 0.25
IMPORT("fmt", "search", "table_merge", "array_diff")
IMPORT("is_group", "extract_groups", "item_has_groups", "apply_recipe_filters")
local function get_filtered_items(player, data)
local items, known, c = {}, 0, 0