From 2fa971acb4a3e58bb6c1f247b297630aa55da122 Mon Sep 17 00:00:00 2001 From: Jean-Patrick Guerrero Date: Tue, 11 Jan 2022 02:49:44 +0100 Subject: [PATCH] Fix missing func --- src/common.lua | 25 +++++++++++++++++++++++++ src/fields.lua | 28 ++-------------------------- 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/src/common.lua b/src/common.lua index a180b0a..7cc3922 100644 --- a/src/common.lua +++ b/src/common.lua @@ -561,6 +561,30 @@ local function sort_inventory(player, data) end end +local function reset_data(data) + data.filter = "" + data.expand = "" + data.pagenum = 1 + data.rnum = 1 + data.unum = 1 + data.scrbar_rcp = 1 + data.scrbar_usg = 1 + data.query_item = nil + data.recipes = nil + data.usages = nil + data.export_rcp = nil + data.export_usg = nil + data.alt_items = nil + data.confirm_trash = nil + data.show_settings = nil + data.show_setting = "home" + data.items = data.items_raw + + if data.itab > 1 then + sort_by_category(data) + end +end + local function add_hud_waypoint(player, name, pos, color) return player:hud_add { hud_elem_type = "waypoint", @@ -638,6 +662,7 @@ local _ = { spawn_item = spawn_item, clean_name = clean_name, play_sound = play_sound, + reset_data = reset_data, safe_teleport = safe_teleport, add_hud_waypoint = add_hud_waypoint, diff --git a/src/fields.lua b/src/fields.lua index d5a22bc..6f299a3 100644 --- a/src/fields.lua +++ b/src/fields.lua @@ -2,37 +2,13 @@ local set_fs = i3.set_fs IMPORT("vec_eq", "vec_round") IMPORT("reg_items", "reg_aliases") -IMPORT("sort", "copy", "insert", "remove", "indexof") IMPORT("S", "random", "translate", "ItemStack") +IMPORT("sort", "copy", "insert", "remove", "indexof") IMPORT("fmt", "find", "match", "sub", "lower", "split", "toupper") -IMPORT("msg", "is_fav", "pos_to_str", "str_to_pos", "add_hud_waypoint", "play_sound") +IMPORT("msg", "is_fav", "pos_to_str", "str_to_pos", "add_hud_waypoint", "play_sound", "reset_data") 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 = "" - data.expand = "" - data.pagenum = 1 - data.rnum = 1 - data.unum = 1 - data.scrbar_rcp = 1 - data.scrbar_usg = 1 - data.query_item = nil - data.recipes = nil - data.usages = nil - data.export_rcp = nil - data.export_usg = nil - data.alt_items = nil - data.confirm_trash = nil - data.show_settings = nil - data.show_setting = "home" - data.items = data.items_raw - - if data.itab > 1 then - sort_by_category(data) - end -end - local function inv_fields(player, data, fields) local name = data.player_name local inv = player:get_inventory()