mirror of
https://github.com/minetest-mods/i3.git
synced 2024-12-26 10:50:42 +01:00
Some cleaning
This commit is contained in:
parent
43b20b317e
commit
caba7f3599
@ -21,3 +21,8 @@ globals = {
|
||||
"sfinv",
|
||||
"unified_inventory",
|
||||
}
|
||||
|
||||
exclude_files = {
|
||||
"tests/test_custom_recipes.lua",
|
||||
"tests/test_tabs.lua",
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
local fmt, insert = string.format, table.insert
|
||||
local fmt, insert, copy, pairs, ipairs = string.format, table.insert, table.copy, pairs, ipairs
|
||||
|
||||
local wood_types = {
|
||||
"acacia_wood", "aspen_wood", "junglewood", "pine_wood",
|
||||
@ -262,7 +262,7 @@ local moreblocks_nodes = {
|
||||
"ice",
|
||||
}
|
||||
|
||||
local colors_moreblocks = table.copy(colors)
|
||||
local colors_moreblocks = copy(colors)
|
||||
insert(colors_moreblocks, "white")
|
||||
|
||||
local moreblocks_mods = {
|
||||
|
13
etc/gui.lua
13
etc/gui.lua
@ -1,4 +1,3 @@
|
||||
local modpath = core.get_modpath "i3"
|
||||
local damage_enabled = core.settings:get_bool "enable_damage"
|
||||
|
||||
local reg_items = core.registered_items
|
||||
@ -20,14 +19,10 @@ local min, max, floor, ceil = math.min, math.max, math.floor, math.ceil
|
||||
local clr, ESC, check_privs, translate =
|
||||
core.colorize, core.formspec_escape, core.check_player_privs, core.get_translated_string
|
||||
|
||||
local model_aliases = dofile(modpath .. "/etc/model_aliases.lua")
|
||||
local PNG, styles, fs_elements = dofile(modpath .. "/etc/styles.lua")
|
||||
|
||||
local _, _, is_group, extract_groups, item_has_groups =
|
||||
unpack(dofile(modpath .. "/etc/common.lua").progressive)
|
||||
|
||||
local groups_to_items, compression_active, compressible, true_str, is_fav =
|
||||
unpack(dofile(modpath .. "/etc/common.lua").gui)
|
||||
local model_aliases = i3.files.model_alias()
|
||||
local PNG, styles, fs_elements = i3.files.styles()
|
||||
local _, _, is_group, extract_groups, item_has_groups = unpack(i3.files.common().progressive)
|
||||
local groups_to_items, compression_active, compressible, true_str, is_fav = unpack(i3.files.common().gui)
|
||||
|
||||
local S = i3.S
|
||||
|
||||
|
@ -1,14 +1,12 @@
|
||||
local POLL_FREQ = 0.25
|
||||
local HUD_TIMER_MAX = 1.5
|
||||
|
||||
local set_fs = i3.set_fs
|
||||
local modpath = core.get_modpath "i3"
|
||||
|
||||
local search, table_merge, is_group, extract_groups, item_has_groups, apply_recipe_filters =
|
||||
unpack(dofile(modpath .. "/etc/common.lua").progressive)
|
||||
unpack(i3.files.common().progressive)
|
||||
|
||||
local singleplayer = core.is_singleplayer()
|
||||
local fmt, after = string.format, core.after
|
||||
local fmt, after, pairs = string.format, core.after, pairs
|
||||
local set_fs = i3.set_fs
|
||||
|
||||
local function array_diff(t1, t2)
|
||||
local hash = {}
|
||||
@ -204,8 +202,7 @@ local function show_hud_success(player, data)
|
||||
end
|
||||
|
||||
player:hud_change(data.hud.text, "text",
|
||||
fmt("%u new recipe%s unlocked!",
|
||||
data.discovered, data.discovered > 1 and "s" or ""))
|
||||
fmt("%u new recipe%s unlocked!", data.discovered, data.discovered > 1 and "s" or ""))
|
||||
|
||||
elseif data.show_hud == false then
|
||||
if data.hud_timer >= HUD_TIMER_MAX then
|
||||
|
35
init.lua
35
init.lua
@ -1,3 +1,9 @@
|
||||
local modpath = core.get_modpath "i3"
|
||||
|
||||
local function lf(path)
|
||||
return loadfile(modpath .. path)
|
||||
end
|
||||
|
||||
i3 = {
|
||||
modules = {},
|
||||
|
||||
@ -39,9 +45,18 @@ i3 = {
|
||||
search_filters = {},
|
||||
craft_types = {},
|
||||
tabs = {},
|
||||
|
||||
files = {
|
||||
common = lf("/etc/common.lua"),
|
||||
compress = lf("/etc/compress.lua"),
|
||||
groups = lf("/etc/groups.lua"),
|
||||
gui = lf("/etc/gui.lua"),
|
||||
model_alias = lf("/etc/model_aliases.lua"),
|
||||
progressive = lf("/etc/progressive.lua"),
|
||||
styles = lf("/etc/styles.lua"),
|
||||
}
|
||||
}
|
||||
|
||||
local modpath = core.get_modpath "i3"
|
||||
local http = core.request_http_api()
|
||||
local storage = core.get_mod_storage()
|
||||
|
||||
@ -49,16 +64,16 @@ i3.S = core.get_translator "i3"
|
||||
local S, slz, dslz = i3.S, core.serialize, core.deserialize
|
||||
|
||||
i3.data = dslz(storage:get_string "data") or {}
|
||||
i3.compress_groups, i3.compressed = dofile(modpath .. "/etc/compress.lua")
|
||||
i3.group_stereotypes, i3.group_names = dofile(modpath .. "/etc/groups.lua")
|
||||
i3.compress_groups, i3.compressed = i3.files.compress()
|
||||
i3.group_stereotypes, i3.group_names = i3.files.groups()
|
||||
|
||||
local is_str, show_item, reset_compression = unpack(dofile(modpath .. "/etc/common.lua").init)
|
||||
local groups_to_items, _, compressible, true_str, is_fav = unpack(dofile(modpath .. "/etc/common.lua").gui)
|
||||
local is_str, show_item, reset_compression = unpack(i3.files.common().init)
|
||||
local groups_to_items, _, compressible, true_str, is_fav = unpack(i3.files.common().gui)
|
||||
|
||||
local search, table_merge, is_group, extract_groups, item_has_groups, apply_recipe_filters =
|
||||
unpack(dofile(modpath .. "/etc/common.lua").progressive)
|
||||
unpack(i3.files.common().progressive)
|
||||
|
||||
local make_fs, get_inventory_fs = dofile(modpath .. "/etc/gui.lua")
|
||||
local make_fs, get_inventory_fs = i3.files.gui()
|
||||
|
||||
local progressive_mode = core.settings:get_bool "i3_progressive_mode"
|
||||
|
||||
@ -82,9 +97,7 @@ local fmt, find, gmatch, match, sub, split, upper, lower =
|
||||
string.sub, string.split, string.upper, string.lower
|
||||
|
||||
local min, ceil, random = math.min, math.ceil, math.random
|
||||
|
||||
local pairs, ipairs, next, type, tonum =
|
||||
pairs, ipairs, next, type, tonumber
|
||||
local pairs, ipairs, next, type, tonum = pairs, ipairs, next, type, tonumber
|
||||
|
||||
local vec_new, vec_add, vec_mul, vec_eq, vec_round =
|
||||
vector.new, vector.add, vector.multiply, vector.equals, vector.round
|
||||
@ -1618,7 +1631,7 @@ core.register_on_player_hpchange(function(player, hpchange)
|
||||
end)
|
||||
|
||||
if progressive_mode then
|
||||
dofile(modpath .. "/etc/progressive.lua")
|
||||
i3.files.progressive()
|
||||
end
|
||||
|
||||
local bag_recipes = {
|
||||
|
Loading…
Reference in New Issue
Block a user