From 4fcf4f5790ec3fc32b554f4999eff1311fb37add Mon Sep 17 00:00:00 2001 From: Jean-Patrick Guerrero Date: Mon, 1 Nov 2021 15:34:10 +0100 Subject: [PATCH] Rename some variables --- etc/api.lua | 6 +++--- etc/common.lua | 4 ++-- etc/gui.lua | 6 +++--- etc/inventory.lua | 8 ++++---- etc/progressive.lua | 2 +- init.lua | 4 ++-- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/etc/api.lua b/etc/api.lua index 871109d..278f30d 100644 --- a/etc/api.lua +++ b/etc/api.lua @@ -205,7 +205,7 @@ function i3.get_current_tab(player) local name = player:get_player_name() local data = i3.data[name] - return data.current_tab + return data.tab end function i3.set_tab(player, tabname) @@ -213,7 +213,7 @@ function i3.set_tab(player, tabname) local data = i3.data[name] if not tabname or tabname == "" then - data.current_tab = 0 + data.tab = 0 return end @@ -221,7 +221,7 @@ function i3.set_tab(player, tabname) for i, def in ipairs(i3.tabs) do if not found and def.name == tabname then - data.current_tab = i + data.tab = i found = true end end diff --git a/etc/common.lua b/etc/common.lua index 988d17d..095b1dd 100644 --- a/etc/common.lua +++ b/etc/common.lua @@ -328,9 +328,9 @@ local function sort_by_category(data) local item = items[i] local to_add = true - if data.current_itab == 2 then + if data.itab == 2 then to_add = reg_nodes[item] - elseif data.current_itab == 3 then + elseif data.itab == 3 then to_add = reg_craftitems[item] or reg_tools[item] end diff --git a/etc/gui.lua b/etc/gui.lua index 5d8eee2..4080034 100644 --- a/etc/gui.lua +++ b/etc/gui.lua @@ -1163,7 +1163,7 @@ local function get_items_fs(fs, data, full_height) local tab_len, tab_hgh = 1.8, 0.5 for i, title in ipairs(_tabs) do - local selected = i == data.current_itab + local selected = i == data.itab fs(fmt([[style_type[image_button;fgimg=%s;fgimg_hovered=%s;noclip=true; font_size=16;textcolor=%s;content_offset=0;sound=i3_tab] ]], @@ -1256,7 +1256,7 @@ local function get_tabs_fs(player, data, fs, full_height) shift = #_tabs - 3 end - local selected = i == data.current_tab + local selected = i == data.tab fs(fmt([[style_type[image_button;fgimg=%s;fgimg_hovered=%s;noclip=true; font_size=16;textcolor=%s;content_offset=0;sound=i3_tab] ]], @@ -1323,7 +1323,7 @@ local function make_fs(player, data) data.inv_width = 10.23 local full_height = 12 - local tab = i3.tabs[data.current_tab] + local tab = i3.tabs[data.tab] fs(fmt("formspec_version[%u]size[%f,%f]no_prepend[]bgcolor[#0000]", i3.MIN_FORMSPEC_VERSION, data.inv_width + 8, full_height), styles) diff --git a/etc/inventory.lua b/etc/inventory.lua index f674071..0826a08 100644 --- a/etc/inventory.lua +++ b/etc/inventory.lua @@ -44,7 +44,7 @@ local function reset_data(data) data.show_setting = "home" data.items = data.items_raw - if data.current_itab > 1 then + if data.itab > 1 then sort_by_category(data) end end @@ -413,7 +413,7 @@ local function rcp_fields(player, data, fields) search(data) - if data.current_itab > 1 then + if data.itab > 1 then sort_by_category(data) end @@ -502,14 +502,14 @@ core.register_on_player_receive_fields(function(player, formname, fields) break elseif sub(f, 1, 5) == "itab_" then data.pagenum = 1 - data.current_itab = tonumber(f:sub(-1)) + data.itab = tonumber(f:sub(-1)) sort_by_category(data) end end rcp_fields(player, data, fields) - local tab = i3.tabs[data.current_tab] + local tab = i3.tabs[data.tab] if tab and tab.fields then return true, tab.fields(player, data, fields) diff --git a/etc/progressive.lua b/etc/progressive.lua index 74ffad8..4be1311 100644 --- a/etc/progressive.lua +++ b/etc/progressive.lua @@ -222,7 +222,7 @@ local function poll_new_items() end data.items_raw = items - data.current_itab = 1 + data.itab = 1 search(data) i3.set_fs(player) diff --git a/init.lua b/init.lua index b0ff7a1..7786567 100644 --- a/init.lua +++ b/init.lua @@ -156,8 +156,8 @@ local function init_data(player, info) data.reverse_sorting = false data.inv_compress = true data.export_counts = {} - data.current_tab = 1 - data.current_itab = 1 + data.tab = 1 + data.itab = 1 data.subcat = 1 data.scrbar_inv = 0 data.lang_code = get_lang_code(info)