Differences From
Artifact [8a376bbedc]:
2 2 local scenario = starlit.world.scenario
3 3 local log = starlit.logger 'scenario'
4 4
5 5 local function makeChip(label, schem, sw)
6 6 local E = starlit.mod.electronics
7 7 local files = {}
8 8 local sz = 0
9 + for _, e in ipairs(sw) do
10 + local file = {
11 + kind = 'sw', name = '', drm = e[2];
12 + body = {pgmId = e[1], conf = {}};
13 + }
14 + table.insert(files, file)
15 + sz = sz + E.chip.fileSize(file)
16 + end
9 17 for _, e in ipairs(schem) do
10 18 local p = E.sw.findSchematicFor(e[1])
11 19 if p then
12 20 local file = {
13 21 kind = 'sw', name = '', drm = e[2];
14 22 body = {pgmId = p, conf = {}};
15 23 }
16 24 table.insert(files, file)
17 25 sz = sz + E.chip.fileSize(file)
18 26 end
19 27 end
20 - for _, e in ipairs(sw) do
21 - local file = {
22 - kind = 'sw', name = '', drm = e[2];
23 - body = {pgmId = e[1], conf = {}};
24 - }
25 - table.insert(files, file)
26 - sz = sz + E.chip.fileSize(file)
27 - end
28 28 local chip = ItemStack(assert(E.chip.findBest(function(c)
29 29 return c.flash >= sz, c.ram + c.clockRate
30 30 end)))
31 31 local r = E.chip.read(chip)
32 32 r.label = label
33 33 r.files = files
34 34 E.chip.write(chip, r)