starlit  Diff

Differences From Artifact [8a376bbedc]:

To Artifact [339ae3b1f1]:


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
local scenario = starlit.world.scenario
local log = starlit.logger 'scenario'

local function makeChip(label, schem, sw)
	local E = starlit.mod.electronics
	local files = {}
	local sz = 0








	for _, e in ipairs(schem) do
		local p = E.sw.findSchematicFor(e[1])
		if p then
			local file = {
				kind = 'sw', name = '', drm = e[2];
				body = {pgmId = p, conf = {}};
			}
			table.insert(files, file)
			sz = sz + E.chip.fileSize(file)
		end
	end
	for _, e in ipairs(sw) do
		local file = {
			kind = 'sw', name = '', drm = e[2];
			body = {pgmId = e[1], conf = {}};
		}
		table.insert(files, file)
		sz = sz + E.chip.fileSize(file)
	end
	local chip = ItemStack(assert(E.chip.findBest(function(c)
		return c.flash >= sz, c.ram + c.clockRate
	end)))
	local r = E.chip.read(chip)
	r.label = label
	r.files = files
	E.chip.write(chip, r)







>
>
>
>
>
>
>
>











<
<
<
<
<
<
<
<







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
local scenario = starlit.world.scenario
local log = starlit.logger 'scenario'

local function makeChip(label, schem, sw)
	local E = starlit.mod.electronics
	local files = {}
	local sz = 0
	for _, e in ipairs(sw) do
		local file = {
			kind = 'sw', name = '', drm = e[2];
			body = {pgmId = e[1], conf = {}};
		}
		table.insert(files, file)
		sz = sz + E.chip.fileSize(file)
	end
	for _, e in ipairs(schem) do
		local p = E.sw.findSchematicFor(e[1])
		if p then
			local file = {
				kind = 'sw', name = '', drm = e[2];
				body = {pgmId = p, conf = {}};
			}
			table.insert(files, file)
			sz = sz + E.chip.fileSize(file)
		end
	end








	local chip = ItemStack(assert(E.chip.findBest(function(c)
		return c.flash >= sz, c.ram + c.clockRate
	end)))
	local r = E.chip.read(chip)
	r.label = label
	r.files = files
	E.chip.write(chip, r)