Skip to content

Commit

Permalink
Stop creating hard world border to not interfer with edges
Browse files Browse the repository at this point in the history
  • Loading branch information
Danielv123 committed Jun 10, 2024
1 parent bfbe241 commit 8957bf2
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 55 deletions.
11 changes: 3 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@ name: CI

on:
push:
# pull_request:
create:
tags:
- v*

workflow_dispatch:

jobs:
Expand All @@ -18,7 +13,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18.x
node-version: 22.x
- run: npm i -g pnpm
- run: pnpm i --no-optional
env:
Expand All @@ -40,12 +35,12 @@ jobs:
name: "Publish to npm"
runs-on: ubuntu-latest

if: github.event.ref_type == 'tag' && startsWith(github.event.ref, 'v')
if: github.ref_type == 'tag' && startsWith(github.ref_name, 'v')
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18.x
node-version: 22.x
- run: npm i -g pnpm
- run: pnpm i --no-optional
- run: pnpm run prepare
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/diagram.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
name: Create diagram
on:
workflow_dispatch: {}
create:
tags:
- v*

jobs:
get_data:
runs-on: ubuntu-latest
Expand Down
99 changes: 56 additions & 43 deletions module/worldgen/create_world_limit.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,91 +9,104 @@ local function create_world_limit(x_size, y_size, world_x, world_y, force)

--[[ Remove everything inside the border wall area ]]

local allowed_names = {"steel-chest", "transport-belt", "fast-transport-belt", "express-transport-belt", "loader", "fast-loader", "express-loader", "character"}
local allowed_types = {"container", "transport-belt", "loader", "character"}
local allowed_names = {
"steel-chest",
"transport-belt",
"fast-transport-belt",
"express-transport-belt",
"loader",
"fast-loader",
"express-loader",
"character",
"pipe",
"pump",
"substation",
"straight-rail",
}
local allowed_types = {
"container",
"transport-belt",
"loader",
"character",
"pipe",
"electric-energy-interface",
"locomotive",
"cargo-wagon",
"fluid-wagon",
"artillery-wagon",
"spider-vehicle",
"car",
"rail-signal",
"rail-chain-signal",
"constant-combinator",
}
--[[ West of border ]]
for _,v in pairs(
for _, v in pairs(
game.surfaces[1].find_entities_filtered({
area = {
{-10 + (world_x - 1) * x_size, -10 + (world_y - 1) * y_size},
{(world_x - 1) * x_size, y_size + (world_y - 1) * y_size}
{ -10 + (world_x - 1) * x_size, -10 + (world_y - 1) * y_size },
{ (world_x - 1) * x_size, y_size + (world_y - 1) * y_size }
},
name = allowed_names,
type = allowed_types,
invert = true,
})
) do
v.destroy()
-- v.destroy()
end
--[[ East of border ]]
for _,v in pairs(
for _, v in pairs(
game.surfaces[1].find_entities_filtered({
area = {
{x_size + (world_x - 1) * x_size, (world_y - 1) * y_size},
{x_size + 10 + (world_x - 1) * x_size, y_size + 10 + (world_y - 1) * y_size}
{ x_size + (world_x - 1) * x_size, (world_y - 1) * y_size },
{ x_size + 10 + (world_x - 1) * x_size, y_size + 10 + (world_y - 1) * y_size }
},
name = allowed_names,
type = allowed_types,
invert = true,
})
) do
v.destroy()
-- v.destroy()
end
--[[ South of border ]]
for _,v in pairs(
for _, v in pairs(
game.surfaces[1].find_entities_filtered({
area = {
{-10 + (world_x - 1) * x_size, y_size + (world_y - 1) * y_size},
{x_size + 10 + (world_x - 1) * x_size, y_size + 10 + (world_y - 1) * y_size}
{ -10 + (world_x - 1) * x_size, y_size + (world_y - 1) * y_size },
{ x_size + 10 + (world_x - 1) * x_size, y_size + 10 + (world_y - 1) * y_size }
},
name = allowed_names,
type = allowed_types,
invert = true,
})
) do
v.destroy()
-- v.destroy()
end
--[[ North of border ]]
for _,v in pairs(
for _, v in pairs(
game.surfaces[1].find_entities_filtered({
area = {
{-10 + (world_x - 1) * x_size, -10 + (world_y - 1) * y_size},
{x_size + 10 + (world_x - 1) * x_size, (world_y - 1) * y_size}
{ -10 + (world_x - 1) * x_size, -10 + (world_y - 1) * y_size },
{ x_size + 10 + (world_x - 1) * x_size, (world_y - 1) * y_size }
},
name = allowed_names,
type = allowed_types,
invert = true,
})
) do
v.destroy()
end

--[[ Create border of "out-of-map"/"stone-wall" ]]
local function create_wall(x,y)
game.surfaces[1].set_tiles({{
name = "out-of-map",
position = {x = x + (world_x - 1) * x_size, y = y + (world_y - 1) * y_size},
}}, false)
end
for i = -19, x_size + 18 do
for o = 0, 15 do
create_wall(i, y_size + 3 + o)
create_wall(i, -4 + o * -1)
end
end
for i = -3, y_size + 2 do
for o = 0, 15 do
create_wall(x_size + 3 + o, i)
create_wall(-4 + o * -1, i)
end
-- v.destroy()
end

--[[ Set tiles in the border area out of "refined-concrete" ]]
local function create_concrete(x,y)
game.surfaces[1].set_tiles({{
name = "refined-concrete",
position = {x = x + (world_x - 1) * x_size, y = y + (world_y - 1) * y_size},
}})
local function create_concrete(x, y)
game.surfaces[1].set_tiles(
{ {
name = "refined-concrete",
position = { x = x + (world_x - 1) * x_size, y = y + (world_y - 1) * y_size },
} },
true, -- Correct tiles
false -- Remove colliding entities
)
end
for i = -2, x_size + 1 do
create_concrete(i, y_size + 2)
Expand Down
5 changes: 4 additions & 1 deletion src/worldgen/factionGrid/createServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ module.exports = async function createServer({
hostId: host.id,
load: mapFilter(instances, instance => instance.config.get("instance.assigned_host") === host.id).length,
}));
hostId = hostLoads.sort((a, b) => a.load - b.load)[0].hostId;
hostId = hostLoads.sort((a, b) => a.load - b.load)[0]?.hostId;
}
if (hostId === undefined) {
throw new Error("No hosts with gridworld plugin found");
}

// Create instance
Expand Down

0 comments on commit 8957bf2

Please sign in to comment.