Some cleaning
This commit is contained in:
parent
3c1355b13e
commit
1285a77060
5
init.lua
5
init.lua
|
@ -72,7 +72,8 @@ i3.files.groups()
|
||||||
i3.files.callbacks()
|
i3.files.callbacks()
|
||||||
|
|
||||||
local storage = core.get_mod_storage()
|
local storage = core.get_mod_storage()
|
||||||
local slz, dslz, copy, str_to_pos, add_hud_waypoint = i3.get("slz", "dslz", "copy", "str_to_pos", "add_hud_waypoint")
|
local slz, dslz, copy = i3.get("slz", "dslz", "copy")
|
||||||
|
local str_to_pos, add_hud_waypoint = i3.get("str_to_pos", "add_hud_waypoint")
|
||||||
local set_fs = i3.set_fs
|
local set_fs = i3.set_fs
|
||||||
|
|
||||||
i3.data = dslz(storage:get_string"data") or {}
|
i3.data = dslz(storage:get_string"data") or {}
|
||||||
|
@ -184,7 +185,7 @@ end
|
||||||
local function init_hudbar(player)
|
local function init_hudbar(player)
|
||||||
core.after(0, function()
|
core.after(0, function()
|
||||||
player:hud_set_hotbar_itemcount(i3.HOTBAR_LEN)
|
player:hud_set_hotbar_itemcount(i3.HOTBAR_LEN)
|
||||||
player:hud_set_hotbar_image("i3_hotbar.png")
|
player:hud_set_hotbar_image"i3_hotbar.png"
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
local make_fs = i3.files.gui()
|
local make_fs = i3.files.gui()
|
||||||
|
|
||||||
local gmatch, match, split = i3.get("gmatch", "match", "split")
|
local gmatch, split = i3.get("gmatch", "split")
|
||||||
local S, err, fmt, reg_items = i3.get("S", "err", "fmt", "reg_items")
|
local S, err, fmt, reg_items = i3.get("S", "err", "fmt", "reg_items")
|
||||||
local sorter, sort_inventory = i3.get("sorter", "sort_inventory")
|
local sorter, sort_inventory = i3.get("sorter", "sort_inventory")
|
||||||
local sort, concat, copy, insert, remove = i3.get("sort", "concat", "copy", "insert", "remove")
|
local sort, concat, copy, insert, remove = i3.get("sort", "concat", "copy", "insert", "remove")
|
||||||
|
@ -115,7 +115,7 @@ function i3.register_craft(def)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local item = match(def.output, "%S+")
|
local item = ItemStack(def.output):get_name()
|
||||||
i3.recipes_cache[item] = i3.recipes_cache[item] or {}
|
i3.recipes_cache[item] = i3.recipes_cache[item] or {}
|
||||||
|
|
||||||
def.custom = true
|
def.custom = true
|
||||||
|
|
40
src/bags.lua
40
src/bags.lua
|
@ -14,42 +14,12 @@ local function get_content(content)
|
||||||
local t = {}
|
local t = {}
|
||||||
|
|
||||||
for i, v in pairs(content) do
|
for i, v in pairs(content) do
|
||||||
local stack = ItemStack(v.name)
|
t[i] = ItemStack(v)
|
||||||
|
|
||||||
if v.meta then
|
|
||||||
local m = stack:get_meta()
|
|
||||||
m:from_table(v.meta)
|
|
||||||
end
|
|
||||||
|
|
||||||
if v.wear then
|
|
||||||
stack:set_wear(v.wear)
|
|
||||||
end
|
|
||||||
|
|
||||||
t[i] = stack
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return t
|
return t
|
||||||
end
|
end
|
||||||
|
|
||||||
local function safe_format(stack)
|
|
||||||
local meta = stack:get_meta():to_table()
|
|
||||||
local wear = stack:get_wear()
|
|
||||||
local has_meta = next(meta.fields)
|
|
||||||
|
|
||||||
local info = {}
|
|
||||||
info.name = fmt("%s %u", stack:get_name(), stack:get_count())
|
|
||||||
|
|
||||||
if has_meta then
|
|
||||||
info.meta = meta
|
|
||||||
end
|
|
||||||
|
|
||||||
if wear > 0 then
|
|
||||||
info.wear = wear
|
|
||||||
end
|
|
||||||
|
|
||||||
return info
|
|
||||||
end
|
|
||||||
|
|
||||||
local function init_bags(player)
|
local function init_bags(player)
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
local data = i3.data[name]
|
local data = i3.data[name]
|
||||||
|
@ -73,7 +43,7 @@ local function init_bags(player)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
on_put = function(_, _, _, stack)
|
on_put = function(_, _, _, stack)
|
||||||
data.bag_item = safe_format(stack)
|
data.bag_item = stack:to_string()
|
||||||
data.bag_size = core.get_item_group(stack:get_name(), "bag")
|
data.bag_size = core.get_item_group(stack:get_name(), "bag")
|
||||||
|
|
||||||
local meta = stack:get_meta()
|
local meta = stack:get_meta()
|
||||||
|
@ -108,7 +78,7 @@ local function init_bags(player)
|
||||||
local bagstack = bag:get_stack("main", 1)
|
local bagstack = bag:get_stack("main", 1)
|
||||||
local meta = bagstack:get_meta()
|
local meta = bagstack:get_meta()
|
||||||
|
|
||||||
if inv:is_empty("main") then
|
if inv:is_empty"main" then
|
||||||
meta:set_string("description", "")
|
meta:set_string("description", "")
|
||||||
meta:set_string("content", "")
|
meta:set_string("content", "")
|
||||||
else
|
else
|
||||||
|
@ -119,7 +89,7 @@ local function init_bags(player)
|
||||||
local stack = list[i]
|
local stack = list[i]
|
||||||
|
|
||||||
if not stack:is_empty() then
|
if not stack:is_empty() then
|
||||||
t[i] = safe_format(stack)
|
t[i] = stack:to_string()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -141,7 +111,7 @@ local function init_bags(player)
|
||||||
end
|
end
|
||||||
|
|
||||||
bag:set_stack("main", 1, bagstack)
|
bag:set_stack("main", 1, bagstack)
|
||||||
data.bag_item = safe_format(bagstack)
|
data.bag_item = bagstack:to_string()
|
||||||
|
|
||||||
set_fs(player)
|
set_fs(player)
|
||||||
end
|
end
|
||||||
|
|
18
src/gui.lua
18
src/gui.lua
|
@ -71,8 +71,8 @@ local function get_desc(item)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function get_stack_max(inv, data, is_recipe, rcp)
|
local function get_stack_max(inv, data, is_recipe, rcp)
|
||||||
local list = inv:get_list("main")
|
local list = inv:get_list"main"
|
||||||
local size = inv:get_size("main")
|
local size = inv:get_size"main"
|
||||||
local counts_inv, counts_rcp, counts = {}, {}, {}
|
local counts_inv, counts_rcp, counts = {}, {}, {}
|
||||||
local rcp_usg = is_recipe and "recipe" or "usage"
|
local rcp_usg = is_recipe and "recipe" or "usage"
|
||||||
|
|
||||||
|
@ -441,10 +441,10 @@ local function show_popup(fs, data)
|
||||||
local show_misc = data.show_setting == "misc"
|
local show_misc = data.show_setting == "misc"
|
||||||
|
|
||||||
fs(fmt("style[setting_home;textcolor=%s;font=bold;sound=i3_click]",
|
fs(fmt("style[setting_home;textcolor=%s;font=bold;sound=i3_click]",
|
||||||
show_home and colors.yellow or "#fff"))
|
show_home and colors.yellow or "#fff"),
|
||||||
fs(fmt("style[setting_sorting;textcolor=%s;font=bold;sound=i3_click]",
|
fmt("style[setting_sorting;textcolor=%s;font=bold;sound=i3_click]",
|
||||||
show_sorting and colors.yellow or "#fff"))
|
show_sorting and colors.yellow or "#fff"),
|
||||||
fs(fmt("style[setting_misc;textcolor=%s;font=bold;sound=i3_click]",
|
fmt("style[setting_misc;textcolor=%s;font=bold;sound=i3_click]",
|
||||||
show_misc and colors.yellow or "#fff"))
|
show_misc and colors.yellow or "#fff"))
|
||||||
|
|
||||||
fs("button", 2.2, 9.25, 1.8, 0.55, "setting_home", "Home")
|
fs("button", 2.2, 9.25, 1.8, 0.55, "setting_home", "Home")
|
||||||
|
@ -469,8 +469,8 @@ local function show_popup(fs, data)
|
||||||
elseif show_sorting then
|
elseif show_sorting then
|
||||||
fs("button", 2.1, 9.7, 6, 0.8, "select_sorting", ES"Select the inventory sorting method:")
|
fs("button", 2.1, 9.7, 6, 0.8, "select_sorting", ES"Select the inventory sorting method:")
|
||||||
|
|
||||||
fs(fmt("style[prev_sort;fgimg=%s;fgimg_hovered=%s]", PNG.prev, PNG.prev_hover))
|
fs(fmt("style[prev_sort;fgimg=%s;fgimg_hovered=%s]", PNG.prev, PNG.prev_hover),
|
||||||
fs(fmt("style[next_sort;fgimg=%s;fgimg_hovered=%s]", PNG.next, PNG.next_hover))
|
fmt("style[next_sort;fgimg=%s;fgimg_hovered=%s]", PNG.next, PNG.next_hover))
|
||||||
|
|
||||||
fs("image_button", 2.2, 10.6, 0.35, 0.35, "", "prev_sort", "")
|
fs("image_button", 2.2, 10.6, 0.35, 0.35, "", "prev_sort", "")
|
||||||
fs("image_button", 7.65, 10.6, 0.35, 0.35, "", "next_sort", "")
|
fs("image_button", 7.65, 10.6, 0.35, 0.35, "", "next_sort", "")
|
||||||
|
@ -643,7 +643,7 @@ local function get_tooltip(item, info, pos)
|
||||||
|
|
||||||
if info.replace then
|
if info.replace then
|
||||||
for i = 1, #info.replace.items do
|
for i = 1, #info.replace.items do
|
||||||
local rpl = match(info.replace.items[i], "%S+")
|
local rpl = ItemStack(info.replace.items[i]):get_name()
|
||||||
local desc = clr("#ff0", get_desc(rpl))
|
local desc = clr("#ff0", get_desc(rpl))
|
||||||
|
|
||||||
if info.replace.type == "cooking" then
|
if info.replace.type == "cooking" then
|
||||||
|
|
|
@ -8,6 +8,7 @@ mt2:get_meta():set_string("color", "#ff0")
|
||||||
|
|
||||||
local mt3 = ItemStack("default:pick_diamond")
|
local mt3 = ItemStack("default:pick_diamond")
|
||||||
mt3:get_meta():set_string("description", "Worn Pick")
|
mt3:get_meta():set_string("description", "Worn Pick")
|
||||||
|
mt3:get_meta():set_string("color", "yellow")
|
||||||
mt3:set_wear(10000)
|
mt3:set_wear(10000)
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
|
|
Ŝarĝante…
Reference in New Issue