-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlayout.lua
107 lines (100 loc) · 1.73 KB
/
layout.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
local layout = {}
local example_params = {
origin = {0, 0},
nodes = {
{
name = "offshore-pump",
count = 1,
},
{
name = "boiler",
count = 1,
},
{
name = "steam-engine",
count = 1,
},
},
edges = {
{
type = "pipe",
from = "offshore-pump",
to = "boiler",
},
{
type = "pipe",
from = "boiler",
to = "steam-engine",
}
},
}
local solution = {
entities = {
{
name = "offshore-pump",
position = {1, 2},
direction = defines.direction.north,
},
{
name = "boiler",
position = {1, 3},
direction = defines.direction.north,
},
{
name = "steam-engine",
position = {1, 4},
direction = defines.direction.north,
},
},
}
-- return a solution
-- params has
function layout:layout(player, params) -- luacheck: ignore self
local origin = params.origin or player.position --luacheck: ignore origin
end
local example_chunk = {
area = {{3, 4},
{-1, -2}},
outputs = {
name = "water",
type = "pipe",
position = {3, 4},
direction = defines.direction.north,
},
inputs = {},
fluid = "water",
entities = {
{
name = "offshore-pump",
position = {3,4},
direction = defines.direction.north,
},
},
}
local function make_chunk(node)
local proto = game.entity_prototypes[node.name]
local chunk = {}
if node.count == 1 then
chunk.entities = {
name = node.name,
position = {0, 0},
}
if proto.fluid ~= nil then
chunk.fluid = proto.fluid
end
if proto.pipe_connections then
game.print('connect pipes')
end
else
game.print('cannot layout multi node counts')
node.fix.this()
end
return chunk
end
function layout.test()
example_params = example_params
example_chunk = example_chunk
solution = solution
make_chunk(nil)
end
return layout