mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-27 03:25:23 +09:00
Resolve all Luals warnings
This commit is contained in:
@@ -20,8 +20,11 @@ local function bonus_gui_pts_needed(player)
|
||||
total = total + (disp["bonus_display_" .. k .. "_slider"].slider_value / config.player_bonus[v].cost_scale * config.player_bonus[v].cost)
|
||||
end
|
||||
|
||||
total = total +
|
||||
(disp["bonus_display_personal_battery_recharge_slider"].slider_value / config.player_special_bonus["personal_battery_recharge"].cost_scale * config.player_special_bonus["personal_battery_recharge"].cost)
|
||||
total = total + (
|
||||
disp["bonus_display_personal_battery_recharge_slider"].slider_value
|
||||
/ config.player_special_bonus["personal_battery_recharge"].cost_scale
|
||||
* config.player_special_bonus["personal_battery_recharge"].cost
|
||||
)
|
||||
|
||||
return total
|
||||
end
|
||||
@@ -174,15 +177,15 @@ local bonus_gui_control_reset =
|
||||
disp[s].slider_value = config.player_bonus[v].value
|
||||
|
||||
if config.player_bonus[v].is_percentage then
|
||||
disp[disp[s].tags.counter].caption = format_number(disp[s].slider_value * 100) .. " %"
|
||||
disp[disp[s].tags.counter].caption = format_number(disp[s].slider_value * 100, false) .. " %"
|
||||
else
|
||||
disp[disp[s].tags.counter].caption = format_number(disp[s].slider_value)
|
||||
disp[disp[s].tags.counter].caption = format_number(disp[s].slider_value, false)
|
||||
end
|
||||
end
|
||||
|
||||
local slider = disp["bonus_display_personal_battery_recharge_slider"]
|
||||
slider.slider_value = config.player_special_bonus["personal_battery_recharge"].value
|
||||
disp[slider.tags.counter].caption = format_number(slider.slider_value)
|
||||
disp[slider.tags.counter].caption = format_number(slider.slider_value, false)
|
||||
|
||||
local r = bonus_gui_pts_needed(player)
|
||||
element.parent[bonus_gui_control_pts_n_count.name].caption = r
|
||||
@@ -246,9 +249,9 @@ local bonus_gui_slider =
|
||||
local value = bonus.value
|
||||
|
||||
if bonus.is_percentage then
|
||||
value = format_number(value * 100) .. " %"
|
||||
value = format_number(value * 100, false) .. " %"
|
||||
else
|
||||
value = format_number(value)
|
||||
value = format_number(value, false)
|
||||
end
|
||||
|
||||
local slider = parent.add{
|
||||
@@ -279,9 +282,9 @@ local bonus_gui_slider =
|
||||
end)
|
||||
:on_value_changed(function(player, element, _event)
|
||||
if element.tags.is_percentage then
|
||||
element.parent[element.tags.counter].caption = format_number(element.slider_value * 100) .. " %"
|
||||
element.parent[element.tags.counter].caption = format_number(element.slider_value * 100, false) .. " %"
|
||||
else
|
||||
element.parent[element.tags.counter].caption = format_number(element.slider_value)
|
||||
element.parent[element.tags.counter].caption = format_number(element.slider_value, false)
|
||||
end
|
||||
|
||||
local r = bonus_gui_pts_needed(player)
|
||||
|
||||
@@ -10,10 +10,10 @@ local rawset = rawset
|
||||
|
||||
local Public = {}
|
||||
|
||||
local luaObject = { "{", nil, ", name = '", nil, "'}" }
|
||||
local luaPlayer = { "{LuaPlayer, name = '", nil, "', index = ", nil, "}" }
|
||||
local luaEntity = { "{LuaEntity, name = '", nil, "', unit_number = ", nil, "}" }
|
||||
local luaGuiElement = { "{LuaGuiElement, name = '", nil, "'}" }
|
||||
local LuaObject = { "{", nil, ", name = '", nil, "'}" }
|
||||
local LuaPlayer = { "{LuaPlayer, name = '", nil, "', index = ", nil, "}" }
|
||||
local LuaEntity = { "{LuaEntity, name = '", nil, "', unit_number = ", nil, "}" }
|
||||
local LuaGuiElement = { "{LuaGuiElement, name = '", nil, "'}" }
|
||||
|
||||
local function get(obj, prop)
|
||||
return obj[prop]
|
||||
@@ -59,25 +59,25 @@ local function inspect_process(item)
|
||||
end
|
||||
|
||||
if obj_type == "LuaPlayer" then
|
||||
luaPlayer[2] = item.name or "nil"
|
||||
luaPlayer[4] = item.index or "nil"
|
||||
LuaPlayer[2] = item.name or "nil"
|
||||
LuaPlayer[4] = item.index or "nil"
|
||||
|
||||
return concat(luaPlayer)
|
||||
return concat(LuaPlayer)
|
||||
elseif obj_type == "LuaEntity" then
|
||||
luaEntity[2] = item.name or "nil"
|
||||
luaEntity[4] = item.unit_number or "nil"
|
||||
LuaEntity[2] = item.name or "nil"
|
||||
LuaEntity[4] = item.unit_number or "nil"
|
||||
|
||||
return concat(luaEntity)
|
||||
return concat(LuaEntity)
|
||||
elseif obj_type == "LuaGuiElement" then
|
||||
local name = item.name
|
||||
luaGuiElement[2] = gui_names and gui_names[name] or name or "nil"
|
||||
LuaGuiElement[2] = gui_names and gui_names[name] or name or "nil"
|
||||
|
||||
return concat(luaGuiElement)
|
||||
return concat(LuaGuiElement)
|
||||
else
|
||||
luaObject[2] = obj_type
|
||||
luaObject[4] = get_name_safe(item)
|
||||
LuaObject[2] = obj_type
|
||||
LuaObject[4] = get_name_safe(item)
|
||||
|
||||
return concat(luaObject)
|
||||
return concat(LuaObject)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ local label_width = {
|
||||
local short_time_format = ExpUtil.format_time_factory_locale{ format = "short", coefficient = 3600, hours = true, minutes = true }
|
||||
|
||||
local function format_number_n(n)
|
||||
return format_number(math.floor(n)) .. string.format("%.2f", n % 1):sub(2)
|
||||
return format_number(math.floor(n), false) .. string.format("%.2f", n % 1):sub(2)
|
||||
end
|
||||
|
||||
local PlayerStats = PlayerData.Statistics
|
||||
@@ -96,7 +96,7 @@ local pd_data_set =
|
||||
for _, stat_name in pairs(PlayerData.Statistics.metadata.display_order) do
|
||||
local child = PlayerData.Statistics[stat_name]
|
||||
local metadata = child.metadata
|
||||
local value = metadata.stringify_short and metadata.stringify_short(0) or metadata.stringify and metadata.stringify(0) or format_number(0)
|
||||
local value = metadata.stringify_short and metadata.stringify_short(0) or metadata.stringify and metadata.stringify(0) or format_number(0, false)
|
||||
label(disp, label_width["name"], metadata.name or { "exp-statistics." .. stat_name }, metadata.tooltip or { "exp-statistics." .. stat_name .. "-tooltip" })
|
||||
label(disp, label_width["count"], { "readme.data-format", value, metadata.unit or "" }, metadata.value_tooltip or { "exp-statistics." .. stat_name .. "-tooltip" }, stat_name)
|
||||
end
|
||||
@@ -119,7 +119,7 @@ local function pd_update(table, player_name)
|
||||
elseif metadata.stringify then
|
||||
value = metadata.stringify(value or 0)
|
||||
else
|
||||
value = format_number(value or 0)
|
||||
value = format_number(value or 0, false)
|
||||
end
|
||||
table[stat_name].caption = { "readme.data-format", value, metadata.unit or "" }
|
||||
end
|
||||
|
||||
@@ -372,7 +372,7 @@ define_tab({ "readme.data-tab" }, { "readme.data-tooltip" },
|
||||
if metadata.stringify then
|
||||
value = metadata.stringify(value)
|
||||
else
|
||||
value = format_number(value or 0)
|
||||
value = format_number(value or 0, false)
|
||||
end
|
||||
Gui.centered_label(statistics, 150, metadata.name or { "exp-statistics." .. name }, metadata.tooltip or { "exp-statistics." .. name .. "-tooltip" })
|
||||
Gui.centered_label(statistics, 130, { "readme.data-format", value, metadata.unit or "" }, metadata.value_tooltip or { "exp-statistics." .. name .. "-tooltip" })
|
||||
|
||||
@@ -144,12 +144,11 @@ local subfooter_frame =
|
||||
style = "subfooter_frame",
|
||||
}
|
||||
end
|
||||
):style
|
||||
{
|
||||
padding = 5,
|
||||
use_header_filler = false,
|
||||
horizontally_stretchable = true,
|
||||
}
|
||||
):style{
|
||||
padding = 5,
|
||||
use_header_filler = false,
|
||||
horizontally_stretchable = true,
|
||||
}
|
||||
|
||||
|
||||
--- Label element preset
|
||||
@@ -351,22 +350,21 @@ local task_message_textfield =
|
||||
name = Gui.unique_static_name,
|
||||
type = "text-box",
|
||||
text = "",
|
||||
}:style
|
||||
{
|
||||
maximal_width = 268,
|
||||
minimal_height = 100,
|
||||
horizontally_stretchable = true,
|
||||
}
|
||||
}:style{
|
||||
maximal_width = 268,
|
||||
minimal_height = 100,
|
||||
horizontally_stretchable = true,
|
||||
}
|
||||
:on_text_changed(
|
||||
function(player, element, _)
|
||||
local isEditing = PlayerIsEditing:get(player)
|
||||
local isCreating = PlayerIsCreating:get(player)
|
||||
local is_editing = PlayerIsEditing:get(player)
|
||||
local is_creating = PlayerIsCreating:get(player)
|
||||
|
||||
local valid = string.len(element.text) > 5
|
||||
|
||||
if isCreating then
|
||||
if is_creating then
|
||||
element.parent.actions[task_create_confirm_button.name].enabled = valid
|
||||
elseif isEditing then
|
||||
elseif is_editing then
|
||||
element.parent.actions[task_edit_confirm_button.name].enabled = valid
|
||||
end
|
||||
end
|
||||
@@ -676,8 +674,8 @@ PlayerSelected:on_update(
|
||||
local task_list_element = frame.container.scroll.task_list
|
||||
local view_flow = frame.container.view
|
||||
local edit_flow = frame.container.edit
|
||||
local isEditing = PlayerIsEditing:get(player)
|
||||
local isCreating = PlayerIsCreating:get(player)
|
||||
local is_editing = PlayerIsEditing:get(player)
|
||||
local is_creating = PlayerIsCreating:get(player)
|
||||
|
||||
-- If the selection has an previous state re-enable the button list element
|
||||
if prev_state then
|
||||
@@ -692,12 +690,12 @@ PlayerSelected:on_update(
|
||||
update_task_view_footer(player, curr_state)
|
||||
|
||||
-- If a player is creating then remove the creation dialogue
|
||||
if isCreating then
|
||||
if is_creating then
|
||||
PlayerIsCreating:set(player, false)
|
||||
end
|
||||
|
||||
-- Depending on if the player is currently editing change the current task edit footer to the current task
|
||||
if isEditing then
|
||||
if is_editing then
|
||||
update_task_edit_footer(player, curr_state)
|
||||
Tasks.set_editing(prev_state, player.name, nil)
|
||||
Tasks.set_editing(curr_state, player.name, true)
|
||||
@@ -756,8 +754,8 @@ local function role_update_event(event)
|
||||
local has_permission = check_player_permissions(player)
|
||||
local add_new_task_element = container.header.alignment[add_new_task.name]
|
||||
add_new_task_element.visible = has_permission
|
||||
local isCreating = PlayerIsCreating:get(player)
|
||||
if isCreating and not has_permission then
|
||||
local is_creating = PlayerIsCreating:get(player)
|
||||
if is_creating and not has_permission then
|
||||
PlayerIsCreating:set(player, false)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -487,14 +487,14 @@ Event.on_nth_tick(config.update_tick_gui, function(_)
|
||||
local vlayer_display = {
|
||||
[vlayer_gui_display_item_solar_count.name] = {
|
||||
val = (items_alloc["solar-panel"] / math.max(items["solar-panel"], 1)),
|
||||
cap = format_number(items_alloc["solar-panel"]) .. " / " .. format_number(items["solar-panel"]),
|
||||
cap = format_number(items_alloc["solar-panel"], false) .. " / " .. format_number(items["solar-panel"], false),
|
||||
},
|
||||
[vlayer_gui_display_item_accumulator_count.name] = {
|
||||
val = (items_alloc["accumulator"] / math.max(items["accumulator"], 1)),
|
||||
cap = format_number(items_alloc["accumulator"]) .. " / " .. format_number(items["accumulator"]),
|
||||
cap = format_number(items_alloc["accumulator"], false) .. " / " .. format_number(items["accumulator"], false),
|
||||
},
|
||||
[vlayer_gui_display_signal_remaining_surface_area_count.name] = {
|
||||
cap = format_number(stats.remaining_surface_area),
|
||||
cap = format_number(stats.remaining_surface_area, false),
|
||||
},
|
||||
[vlayer_gui_display_signal_sustained_count.name] = {
|
||||
cap = format_energy(stats.energy_sustained, "W"),
|
||||
|
||||
Reference in New Issue
Block a user