mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-27 11:35:22 +09:00
Apply suggestions from code review
All changes where corrections to spelling and grammar in comments. Co-authored-by: mark9064 <30447455+mark9064@users.noreply.github.com>
This commit is contained in:
@@ -37,13 +37,13 @@ Global.register(force_warps, function(tbl)
|
||||
force_warps = tbl
|
||||
end)
|
||||
|
||||
-- Create a array of entity names that will be added to the remove filter
|
||||
-- Create an array of entity names that will be added to the remove filter
|
||||
local remove_warp_area_entity_names = {}
|
||||
for _, entity in pairs(config.entities) do
|
||||
table.insert(remove_warp_area_entity_names, entity[1])
|
||||
end
|
||||
|
||||
-- When a warp is updated change its chat tag and resort the warp order
|
||||
-- When a warp is updated change its chat tag and restore the warp order
|
||||
WrapData:on_update(function(warp_id, warp, old_warp)
|
||||
if warp then
|
||||
warp.updates = warp.updates + 1
|
||||
@@ -156,7 +156,7 @@ function Warps.make_warp_area(warp_id)
|
||||
local posx = position.x
|
||||
local posy = position.y
|
||||
|
||||
-- Get the tile that is being replaced, store.update not needed as we dont want it to trigger
|
||||
-- Get the tile that is being replaced, store.update not needed as we don't want it to trigger
|
||||
local old_tile = surface.get_tile(position).name
|
||||
warp.old_tile = old_tile
|
||||
|
||||
@@ -203,7 +203,7 @@ function Warps.remove_warp_area(warp_id)
|
||||
local old_tile = warp.old_tile
|
||||
if not old_tile then return end
|
||||
|
||||
-- Loop over warp tiles and set them to the old tile that was below
|
||||
-- Restore the original tiles before the creation of the warp
|
||||
local tiles = {}
|
||||
for _, tile in pairs(config.tiles) do
|
||||
table.insert(tiles, {name=old_tile, position={tile[2]+position.x, tile[3]+position.y}})
|
||||
@@ -218,14 +218,14 @@ function Warps.remove_warp_area(warp_id)
|
||||
-- Remove warp structure entities
|
||||
local entities = surface.find_entities_filtered{ force='neutral', area=area, name = remove_warp_area_entity_names }
|
||||
for _, entity in pairs(entities) do
|
||||
-- Destroy them, this will leave corpses of the entities that it distroyed.
|
||||
-- Destroy them, this will leave corpses of the entities that it destroyed.
|
||||
if entity and entity.valid and entity.destructible == false then
|
||||
entity.destructible = true
|
||||
entity.die(entity.force)
|
||||
end
|
||||
end
|
||||
|
||||
-- Rechart map area, usefull if warp is not covered by a radar
|
||||
-- Rechart map area, useful if warp is not covered by a radar
|
||||
game.forces[warp.force_name].chart(surface, area)
|
||||
end
|
||||
|
||||
@@ -459,4 +459,4 @@ function Warps.get_editing(warp_id, player_name)
|
||||
end
|
||||
|
||||
-- Module return
|
||||
return Warps
|
||||
return Warps
|
||||
|
||||
@@ -234,7 +234,7 @@ Gui.element(function(event_trigger, parent)
|
||||
}
|
||||
end)
|
||||
:style{
|
||||
-- when editing mode because textbox is larger the icon would move up.
|
||||
-- When editing mode because textbox is larger the icon would move up.
|
||||
top_padding = 1,
|
||||
single_line = false,
|
||||
}
|
||||
@@ -252,7 +252,7 @@ Gui.element(function(event_trigger, parent, warp)
|
||||
}
|
||||
end)
|
||||
:style{
|
||||
-- Needed fields to make it squashable and strechable.
|
||||
-- Required fields to make it squashable and strechable.
|
||||
minimal_width = 10,
|
||||
maximal_width = 300,
|
||||
horizontally_squashable = "on",
|
||||
@@ -302,7 +302,7 @@ Gui.element{
|
||||
:style(Styles.sprite22)
|
||||
:on_click(function(player, element)
|
||||
local warp_id = element.parent.caption
|
||||
-- Check if this is this is the first edit, if so remove the warp.
|
||||
-- Check if this is the first edit, if so remove the warp.
|
||||
local warp = Warps.get_warp(warp_id)
|
||||
if warp.updates == 1 then
|
||||
Warps.remove_warp(warp_id)
|
||||
@@ -346,7 +346,7 @@ local update_all_warp_elements
|
||||
-- @element add_warp_elements
|
||||
local add_warp_elements =
|
||||
Gui.element(function(_, parent, warp)
|
||||
-- Add icon flow this will contain the warp button and warp icon edit button
|
||||
-- Add icon flow, this will contain the warp button and warp icon edit button
|
||||
local icon_flow = parent.add{
|
||||
name = 'icon-'..warp.warp_id,
|
||||
type = 'flow',
|
||||
@@ -358,7 +358,7 @@ Gui.element(function(_, parent, warp)
|
||||
warp_icon_button(icon_flow, warp)
|
||||
warp_icon_editing(icon_flow, warp)
|
||||
|
||||
-- Add name flow this will contain the warp label and textbox
|
||||
-- Add name flow, this will contain the warp label and textbox
|
||||
local name_flow = parent.add{
|
||||
type = 'flow',
|
||||
name = 'name-'..warp.warp_id,
|
||||
@@ -372,7 +372,7 @@ Gui.element(function(_, parent, warp)
|
||||
warp_textfield(name_flow, warp)
|
||||
|
||||
|
||||
-- Add button flow this will contain buttons to manage this specific warp
|
||||
-- Add button flow, this will contain buttons to manage this specific warp
|
||||
local button_flow = parent.add{
|
||||
type = 'flow',
|
||||
name = 'button-'..warp.warp_id,
|
||||
@@ -510,13 +510,13 @@ end
|
||||
local function update_warp(player, warp_table, warp_id)
|
||||
local warp = Warps.get_warp(warp_id)
|
||||
|
||||
-- If the warp does no longer exist then remove the warp elements from the warp table
|
||||
-- If the warp no longer exists then remove the warp elements from the warp table
|
||||
if not warp then
|
||||
remove_warp_elements(warp_table, warp_id)
|
||||
return
|
||||
end
|
||||
|
||||
-- Check if the warp elements are created, if they are not then create a new set of them
|
||||
-- Create the warp elements if they do not already exist
|
||||
if not warp_table['icon-'..warp_id] then
|
||||
add_warp_elements(warp_table, warp)
|
||||
end
|
||||
@@ -551,7 +551,7 @@ local function update_warp(player, warp_table, warp_id)
|
||||
edit_warp_element.tooltip = {'warp-list.edit-tooltip-none'}
|
||||
end
|
||||
|
||||
-- Set the warp elements visibility based on if the user is editing or not
|
||||
-- Set the visibility of the warp elements based on whether the user is editing or not
|
||||
local player_is_editing = warp.currently_editing[player.name]
|
||||
if player_is_editing then
|
||||
-- Set the icon elements visibility
|
||||
@@ -855,7 +855,7 @@ local function role_update_event(event)
|
||||
|
||||
-- Check if user has permission to add warps
|
||||
local allow_add_warp = check_player_permissions(player, 'allow_add_warp')
|
||||
-- Update container size depending on if the player is allowed to add warps
|
||||
-- Update container size depending on whether the player is allowed to add warps
|
||||
container.parent.style.width = allow_add_warp and 268 or 220
|
||||
|
||||
-- Update the warps, incase the user can now edit them
|
||||
|
||||
Reference in New Issue
Block a user