Update all code styles

This commit is contained in:
Cooldude2606
2024-09-28 01:56:54 +01:00
parent 5e2a62ab27
commit 292c1a1b68
194 changed files with 9817 additions and 9703 deletions

View File

@@ -11,7 +11,7 @@ local Roles = require("modules.exp_legacy.expcore.roles") --- @dep expcore.roles
local rolling_stocks = {}
local function landfill_init()
for name, _ in pairs(prototypes.get_entity_filtered{{filter = 'rolling-stock'}}) do
for name, _ in pairs(prototypes.get_entity_filtered{ { filter = "rolling-stock" } }) do
rolling_stocks[name] = true
end
end
@@ -20,50 +20,50 @@ local function rotate_bounding_box(box)
return {
left_top = {
x = -box.right_bottom.y,
y = box.left_top.x
y = box.left_top.x,
},
right_bottom = {
x = -box.left_top.y,
y = box.right_bottom.x
}
y = box.right_bottom.x,
},
}
end
local function curve_flip_lr(oc)
local nc = table.deepcopy(oc)
local nc = table.deepcopy(oc)
for r=1, 8 do
for c=1, 8 do
nc[r][c] = oc[r][9 - c]
end
end
for r = 1, 8 do
for c = 1, 8 do
nc[r][c] = oc[r][9 - c]
end
end
return nc
return nc
end
local function curve_flip_d(oc)
local nc = table.deepcopy(oc)
local nc = table.deepcopy(oc)
for r=1, 8 do
for c=1, 8 do
nc[r][c] = oc[c][r]
end
end
for r = 1, 8 do
for c = 1, 8 do
nc[r][c] = oc[c][r]
end
end
return nc
return nc
end
local curves = {}
curves[1] = {
{0, 0, 0, 0, 0, 1, 0, 0},
{0, 0, 0, 0, 1, 1, 1, 0},
{0, 0, 0, 1, 1, 1, 1, 0},
{0, 0, 0, 1, 1, 1, 0, 0},
{0, 0, 1, 1, 1, 0, 0, 0},
{0, 0, 1, 1, 1, 0, 0, 0},
{0, 0, 1, 1, 0, 0, 0, 0},
{0, 0, 1, 1, 0, 0, 0, 0}
{ 0, 0, 0, 0, 0, 1, 0, 0 },
{ 0, 0, 0, 0, 1, 1, 1, 0 },
{ 0, 0, 0, 1, 1, 1, 1, 0 },
{ 0, 0, 0, 1, 1, 1, 0, 0 },
{ 0, 0, 1, 1, 1, 0, 0, 0 },
{ 0, 0, 1, 1, 1, 0, 0, 0 },
{ 0, 0, 1, 1, 0, 0, 0, 0 },
{ 0, 0, 1, 1, 0, 0, 0, 0 },
}
curves[6] = curve_flip_d(curves[1])
curves[3] = curve_flip_lr(curves[6])
@@ -79,12 +79,12 @@ for i, map in ipairs(curves) do
curve_n[i] = {}
local index = 1
for r=1, 8 do
for c=1, 8 do
for r = 1, 8 do
for c = 1, 8 do
if map[r][c] == 1 then
curve_n[i][index] = {
['x'] = c - 5,
['y'] = r - 5
["x"] = c - 5,
["y"] = r - 5,
}
index = index + 1
@@ -100,13 +100,13 @@ local function landfill_gui_add_landfill(blueprint)
for _, ent in pairs(entities) do
-- vehicle
if not (rolling_stocks[ent.name] or ent.name == 'offshore-pump') then
if not (rolling_stocks[ent.name] or ent.name == "offshore-pump") then
-- curved rail, special
if ent.name ~= 'curved-rail' then
if ent.name ~= "curved-rail" then
local proto = prototypes.entity[ent.name]
local box = proto.collision_box or proto.selection_box
if proto.collision_mask['ground-tile'] == nil then
if proto.collision_mask["ground-tile"] == nil then
if ent.direction then
if ent.direction ~= defines.direction.north then
box = rotate_bounding_box(box)
@@ -125,21 +125,21 @@ local function landfill_gui_add_landfill(blueprint)
for x = math.floor(ent.position.x + box.left_top.x), math.floor(ent.position.x + box.right_bottom.x), 1 do
tile_index = tile_index + 1
new_tiles[tile_index] = {
name = 'landfill',
position = {x, y}
name = "landfill",
position = { x, y },
}
end
end
end
-- curved rail
-- curved rail
else
local curve_mask = curve_n[ent.direction or 8]
for m=1, #curve_mask do
for m = 1, #curve_mask do
new_tiles[tile_index + 1] = {
name = 'landfill',
position = {curve_mask[m].x + ent.position.x, curve_mask[m].y + ent.position.y}
name = "landfill",
position = { curve_mask[m].x + ent.position.x, curve_mask[m].y + ent.position.y },
}
tile_index = tile_index + 1
@@ -153,34 +153,33 @@ local function landfill_gui_add_landfill(blueprint)
if old_tiles then
for _, old_tile in pairs(old_tiles) do
new_tiles[tile_index + 1] = {
name = 'landfill',
position = {old_tile.position.x, old_tile.position.y}
name = "landfill",
position = { old_tile.position.x, old_tile.position.y },
}
tile_index = tile_index + 1
end
end
return {tiles = new_tiles}
return { tiles = new_tiles }
end
-- @element toolbar_button
Gui.toolbar_button('item/landfill', {'landfill.main-tooltip'}, function(player)
return Roles.player_allowed(player, 'gui/landfill')
Gui.toolbar_button("item/landfill", { "landfill.main-tooltip" }, function(player)
return Roles.player_allowed(player, "gui/landfill")
end)
:on_click(function(player, _, _)
if player.cursor_stack and player.cursor_stack.valid_for_read then
if player.cursor_stack.type == 'blueprint' and player.cursor_stack.is_blueprint_setup() then
local modified = landfill_gui_add_landfill(player.cursor_stack)
:on_click(function(player, _, _)
if player.cursor_stack and player.cursor_stack.valid_for_read then
if player.cursor_stack.type == "blueprint" and player.cursor_stack.is_blueprint_setup() then
local modified = landfill_gui_add_landfill(player.cursor_stack)
if modified and next(modified.tiles) then
player.cursor_stack.set_blueprint_tiles(modified.tiles)
if modified and next(modified.tiles) then
player.cursor_stack.set_blueprint_tiles(modified.tiles)
end
end
else
player.print{ "landfill.cursor-none" }
end
else
player.print{'landfill.cursor-none'}
end
end)
end)
Event.add(defines.events.on_player_joined_game, landfill_init)