Reduce code + Remove github workflow
This commit is contained in:
parent
91af3b73d2
commit
27226a0d1b
|
@ -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 .
|
|
|
@ -14,7 +14,7 @@ This mod requires **Minetest 5.4+**
|
||||||
- Progressive Mode¹
|
- Progressive Mode¹
|
||||||
- Quick Crafting
|
- Quick Crafting
|
||||||
- 3D Player Model Real-Time Preview
|
- 3D Player Model Real-Time Preview
|
||||||
- Isometric Area Preview
|
- Isometric Map Preview
|
||||||
- Inventory Sorting (+ options: compression, reverse mode, automation, etc.)
|
- Inventory Sorting (+ options: compression, reverse mode, automation, etc.)
|
||||||
- Item List Compression (**`moreblocks`** is supported)
|
- Item List Compression (**`moreblocks`** is supported)
|
||||||
- Item Bookmarks
|
- Item Bookmarks
|
||||||
|
|
11
src/api.lua
11
src/api.lua
|
@ -1,11 +1,10 @@
|
||||||
local make_fs = i3.files.gui()
|
local make_fs = i3.files.gui()
|
||||||
|
|
||||||
local gmatch, split = i3.get("gmatch", "split")
|
IMPORT("gmatch", "split")
|
||||||
local S, err, fmt, reg_items = i3.get("S", "err", "fmt", "reg_items")
|
IMPORT("S", "err", "fmt", "reg_items")
|
||||||
local sorter, sort_inventory = i3.get("sorter", "sort_inventory")
|
IMPORT("sorter", "sort_inventory")
|
||||||
local sort, concat, copy, insert, remove = i3.get("sort", "concat", "copy", "insert", "remove")
|
IMPORT("sort", "concat", "copy", "insert", "remove")
|
||||||
local true_str, true_table, is_str, is_func, is_table, clean_name =
|
IMPORT("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")
|
|
||||||
|
|
||||||
function i3.register_craft_type(name, def)
|
function i3.register_craft_type(name, def)
|
||||||
if not true_str(name) then
|
if not true_str(name) then
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
local set_fs = i3.set_fs
|
local set_fs = i3.set_fs
|
||||||
local ItemStack = ItemStack
|
|
||||||
local S, ES, fmt, msg, slz, dslz = i3.get("S", "ES", "fmt", "msg", "slz", "dslz")
|
IMPORT("S", "ES", "fmt", "msg", "slz", "dslz", "ItemStack")
|
||||||
local get_group, play_sound, get_detached_inv, create_inventory =
|
IMPORT("get_group", "play_sound", "get_detached_inv", "create_inventory")
|
||||||
i3.get("get_group", "play_sound", "get_detached_inv", "create_inventory")
|
|
||||||
|
|
||||||
local function get_content(content)
|
local function get_content(content)
|
||||||
local t = {}
|
local t = {}
|
||||||
|
|
|
@ -1,14 +1,9 @@
|
||||||
local replacements = {fuel = {}}
|
local replacements = {fuel = {}}
|
||||||
|
|
||||||
local ItemStack = ItemStack
|
IMPORT("maxn", "copy", "insert", "sort", "match", "sub")
|
||||||
local draw_cube = core.inventorycube
|
IMPORT("is_group", "extract_groups", "item_has_groups", "groups_to_items")
|
||||||
local fmt, reg_items, reg_aliases, reg_nodes = i3.get("fmt", "reg_items", "reg_aliases", "reg_nodes")
|
IMPORT("fmt", "reg_items", "reg_aliases", "reg_nodes", "draw_cube", "ItemStack")
|
||||||
local maxn, copy, insert, sort, match, sub = i3.get("maxn", "copy", "insert", "sort", "match", "sub")
|
IMPORT("true_str", "true_table", "is_table", "valid_item", "table_merge", "table_replace", "rcp_eq")
|
||||||
|
|
||||||
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")
|
|
||||||
|
|
||||||
local function get_burntime(item)
|
local function get_burntime(item)
|
||||||
return core.get_craft_result{method = "fuel", items = {item}}.time
|
return core.get_craft_result{method = "fuel", items = {item}}.time
|
||||||
|
|
|
@ -1,19 +1,14 @@
|
||||||
local _, get_inventory_fs = i3.files.gui()
|
local _, get_inventory_fs = i3.files.gui()
|
||||||
|
|
||||||
local set_fs = i3.set_fs
|
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 =
|
IMPORT("vec_eq", "vec_round")
|
||||||
i3.get("msg", "is_fav", "pos_to_str", "str_to_pos", "add_hud_waypoint", "play_sound", "spawn_item")
|
IMPORT("reg_items", "reg_aliases")
|
||||||
local search, get_sorting_idx, sort_inventory, sort_by_category, get_recipes, get_detached_inv =
|
IMPORT("S", "min", "random", "ItemStack")
|
||||||
i3.get("search", "get_sorting_idx", "sort_inventory", "sort_by_category", "get_recipes", "get_detached_inv")
|
IMPORT("sort", "copy", "insert", "remove", "indexof")
|
||||||
local valid_item, get_stack, craft_stack, clean_name, compressible, check_privs, safe_teleport =
|
IMPORT("fmt", "find", "match", "sub", "lower", "split")
|
||||||
i3.get("valid_item", "get_stack", "craft_stack", "clean_name", "compressible", "check_privs", "safe_teleport")
|
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)
|
local function reset_data(data)
|
||||||
data.filter = ""
|
data.filter = ""
|
||||||
|
|
|
@ -624,6 +624,7 @@ local _ = {
|
||||||
msg = msg,
|
msg = msg,
|
||||||
|
|
||||||
-- Misc. functions
|
-- Misc. functions
|
||||||
|
ItemStack = ItemStack,
|
||||||
valid_item = valid_item,
|
valid_item = valid_item,
|
||||||
spawn_item = spawn_item,
|
spawn_item = spawn_item,
|
||||||
clean_name = clean_name,
|
clean_name = clean_name,
|
||||||
|
@ -636,6 +637,7 @@ local _ = {
|
||||||
slz = core.serialize,
|
slz = core.serialize,
|
||||||
dslz = core.deserialize,
|
dslz = core.deserialize,
|
||||||
ESC = core.formspec_escape,
|
ESC = core.formspec_escape,
|
||||||
|
draw_cube = core.inventorycube,
|
||||||
get_group = core.get_item_group,
|
get_group = core.get_item_group,
|
||||||
pos_to_str = core.pos_to_string,
|
pos_to_str = core.pos_to_string,
|
||||||
str_to_pos = core.string_to_pos,
|
str_to_pos = core.string_to_pos,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
local fmt, copy, insert = i3.get("fmt", "copy", "insert")
|
IMPORT("fmt", "copy", "insert")
|
||||||
|
|
||||||
local wood_types = {
|
local wood_types = {
|
||||||
"acacia_wood", "aspen_wood", "junglewood", "pine_wood",
|
"acacia_wood", "aspen_wood", "junglewood", "pine_wood",
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
local set_fs = i3.set_fs
|
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", {
|
local trash = create_inventory("i3_trash", {
|
||||||
allow_put = function(_, _, _, stack)
|
allow_put = function(_, _, _, stack)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
local S = i3.get("S")
|
IMPORT("S")
|
||||||
|
|
||||||
i3.group_stereotypes = {
|
i3.group_stereotypes = {
|
||||||
dye = "dye:white",
|
dye = "dye:white",
|
||||||
|
|
27
src/gui.lua
27
src/gui.lua
|
@ -3,24 +3,19 @@ local damage_enabled = core.settings:get_bool "enable_damage"
|
||||||
local model_aliases = i3.files.model_alias()
|
local model_aliases = i3.files.model_alias()
|
||||||
local PNG, styles, fs_elements, colors = i3.files.styles()
|
local PNG, styles, fs_elements, colors = i3.files.styles()
|
||||||
|
|
||||||
local ItemStack = ItemStack
|
local sprintf = string.format
|
||||||
local VoxelArea, VoxelManip = VoxelArea, VoxelManip
|
local VoxelArea, VoxelManip = VoxelArea, VoxelManip
|
||||||
|
|
||||||
local S, ES, translate = i3.get("S", "ES", "translate")
|
IMPORT("clr", "ESC", "check_privs")
|
||||||
local clr, ESC, check_privs = i3.get("clr", "ESC", "check_privs")
|
IMPORT("find", "match", "sub", "upper")
|
||||||
local vec_new, vec_sub, vec_round = i3.get("vec_new", "vec_sub", "vec_round")
|
IMPORT("vec_new", "vec_sub", "vec_round")
|
||||||
local min, max, floor, ceil, round = i3.get("min", "max", "floor", "ceil", "round")
|
IMPORT("S", "ES", "translate", "ItemStack")
|
||||||
local sprintf, find, match, sub, upper = i3.get("fmt", "find", "match", "sub", "upper")
|
IMPORT("min", "max", "floor", "ceil", "round")
|
||||||
local reg_items, reg_tools, reg_entities = i3.get("reg_items", "reg_tools", "reg_entities")
|
IMPORT("reg_items", "reg_tools", "reg_entities")
|
||||||
local maxn, sort, concat, copy, insert, remove, unpack =
|
IMPORT("groups_to_items", "compression_active", "compressible")
|
||||||
i3.get("maxn", "sort", "concat", "copy", "insert", "remove", "unpack")
|
IMPORT("true_str", "is_fav", "is_num", "get_group", "str_to_pos")
|
||||||
|
IMPORT("maxn", "sort", "concat", "copy", "insert", "remove", "unpack")
|
||||||
local true_str, is_fav, is_num, get_group, str_to_pos =
|
IMPORT("get_sorting_idx", "is_group", "extract_groups", "item_has_groups")
|
||||||
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")
|
|
||||||
|
|
||||||
local function fmt(elem, ...)
|
local function fmt(elem, ...)
|
||||||
if not fs_elements[elem] then
|
if not fs_elements[elem] then
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
local get_player_by_name, str_to_pos, add_hud_waypoint =
|
IMPORT("get_player_by_name", "str_to_pos", "add_hud_waypoint")
|
||||||
i3.get("get_player_by_name", "str_to_pos", "add_hud_waypoint")
|
|
||||||
|
|
||||||
local function init_hud(player)
|
local function init_hud(player)
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
|
|
|
@ -36,6 +36,10 @@ local operators = {
|
||||||
}
|
}
|
||||||
|
|
||||||
local function compile(data)
|
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
|
for op, func in pairs(operators) do
|
||||||
data = data:gsub("(" .. var .. "+)%s?" .. op .. "%s?(" .. var .. "*)", func)
|
data = data:gsub("(" .. var .. "+)%s?" .. op .. "%s?(" .. var .. "*)", func)
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,13 +1,10 @@
|
||||||
local set_fs = i3.set_fs
|
local set_fs = i3.set_fs
|
||||||
local hud_notif = i3.hud_notif
|
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
|
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 function get_filtered_items(player, data)
|
||||||
local items, known, c = {}, 0, 0
|
local items, known, c = {}, 0, 0
|
||||||
|
|
||||||
|
|
Ŝarĝante…
Reference in New Issue