starlit  Check-in [4b3aa092f8]

Overview
Comment:add storage crate & generic interface for, add LED for print completion, add program tooltips, disfuckulate some longstanding idiot bugs
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 4b3aa092f85aebb8f99a8b846efc0ce4bf40058cc784c2c5c718690771b19d0f
User & Date: lexi on 2024-05-06 20:58:38
Other Links: manifest | tags
Context
2024-05-06
21:29
fix image regression check-in: 108df84ed3 user: lexi tags: trunk
20:58
add storage crate & generic interface for, add LED for print completion, add program tooltips, disfuckulate some longstanding idiot bugs check-in: 4b3aa092f8 user: lexi tags: trunk
16:20
complete (-ish) matter compiler UI (power drain still missing), add printable chemical light check-in: 3df08bd5ac user: lexi tags: trunk
Changes

Modified mods/starlit-electronics/init.lua from [6d0114ddbf] to [6f6bfb54e1].

233
234
235
236
237
238
239

240
241
242
243
244
245
246
...
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505




506
507
508
509
510
511
512
...
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
...
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
...
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
					--[[if not how.gift then -- cheap hack to make starting batteries fully charged
						E.battery.setCharge(st, 0)
					end]]
					E.battery.update(st)
				end;
			};
			fab = def.fab;

			dynamo = {
				vtable = E.dynamo.kind.battery;
			};
			battery = def;
		};
	})
end)
................................................................................
			return fab.size and fab.size.print or 1
		else
			return bType[s] * (bTier[s] or 1) * (bSize[s] or 1)
		end
	end

	local swID = 'starlit_electronics:schematic_'..baseID
	fab.reverseEngineer = {
		complexity = bTier.complexity * bSize.complexity * bType.complexity;
		sw = swID;
	}
	fab.flag = {print=true}

	starlit.item.battery.link(id, {
		name = name;
		desc = table.concat({
			bType.desc or '';
			bTier.desc or '';
			bSize.desc or '';
		}, ' ');

		fab = fab;





		capacity = batStat 'capacity';
		dischargeRate  = batStat 'dischargeRate';
		leak     = batStat 'leak';
		decay    = batStat 'decay';
	})

................................................................................
-- chips --
-----------

E.sw = {}
function E.sw.findSchematicFor(item)
	local id = ItemStack(item):get_name()
	local fm = minetest.registered_items[id]._starlit
	if not (fm and fm.fab and fm.fab.reverseEngineer) then return nil end
	local id = fm.fab.reverseEngineer.sw
	return id, starlit.item.sw.db[id]
end

E.chip = { file = {} }
do local T,G = lib.marshal.t, lib.marshal.g
	-- love too reinvent unions from first principles
	E.chip.data = G.struct {
................................................................................
		elseif file.kind == 'note' then
			local sz = 0x10 + #file.body.author
			for _, e in pairs(file.body.entries) do
				sz = sz + #e.title + #e.body + 0x10 -- header overhead
			end
			return sz
		elseif file.kind == 'research' then
			local re = assert(minetest.registered_items[file.body.itemId]._starlit.fab.reverseEngineer)
			return starlit.item.sw.db[re.sw].size * file.body.progress
		elseif file.kind == 'sw' then
			return starlit.item.sw.db[file.body.pgmId].size
		elseif file.kind == 'genome' then
			return 0 -- TODO
		end
	end
................................................................................
	}
	local n = 0
	for _, e in pairs(chips) do
		n = n + 1
		if not e:is_empty() then
			local ch = e:get_definition()._starlit.chip
			c.cycles = c.cycles + ch.clockRate
			c.ram = c.ram + ch.clockRate
			c.flashFree = c.flashFree + E.chip.freeSpace(e)
			c.powerEfficiency = c.powerEfficiency + ch.powerEfficiency
		end
	end
	if n > 0 then c.powerEfficiency = c.powerEfficiency / n end
	return c
end







>







 







<
<
<
<











>
>
>
>







 







|
|







 







|







 







|







233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
...
485
486
487
488
489
490
491




492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
...
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
...
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
...
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
					--[[if not how.gift then -- cheap hack to make starting batteries fully charged
						E.battery.setCharge(st, 0)
					end]]
					E.battery.update(st)
				end;
			};
			fab = def.fab;
			reverseEngineer = def.reverseEngineer;
			dynamo = {
				vtable = E.dynamo.kind.battery;
			};
			battery = def;
		};
	})
end)
................................................................................
			return fab.size and fab.size.print or 1
		else
			return bType[s] * (bTier[s] or 1) * (bSize[s] or 1)
		end
	end

	local swID = 'starlit_electronics:schematic_'..baseID




	fab.flag = {print=true}

	starlit.item.battery.link(id, {
		name = name;
		desc = table.concat({
			bType.desc or '';
			bTier.desc or '';
			bSize.desc or '';
		}, ' ');

		fab = fab;
		reverseEngineer = {
			complexity = bTier.complexity * bSize.complexity * bType.complexity;
			sw = swID;
		};

		capacity = batStat 'capacity';
		dischargeRate  = batStat 'dischargeRate';
		leak     = batStat 'leak';
		decay    = batStat 'decay';
	})

................................................................................
-- chips --
-----------

E.sw = {}
function E.sw.findSchematicFor(item)
	local id = ItemStack(item):get_name()
	local fm = minetest.registered_items[id]._starlit
	if not (fm and fm.reverseEngineer) then return nil end
	local id = fm.reverseEngineer.sw
	return id, starlit.item.sw.db[id]
end

E.chip = { file = {} }
do local T,G = lib.marshal.t, lib.marshal.g
	-- love too reinvent unions from first principles
	E.chip.data = G.struct {
................................................................................
		elseif file.kind == 'note' then
			local sz = 0x10 + #file.body.author
			for _, e in pairs(file.body.entries) do
				sz = sz + #e.title + #e.body + 0x10 -- header overhead
			end
			return sz
		elseif file.kind == 'research' then
			local re = assert(minetest.registered_items[file.body.itemId]._starlit.reverseEngineer)
			return starlit.item.sw.db[re.sw].size * file.body.progress
		elseif file.kind == 'sw' then
			return starlit.item.sw.db[file.body.pgmId].size
		elseif file.kind == 'genome' then
			return 0 -- TODO
		end
	end
................................................................................
	}
	local n = 0
	for _, e in pairs(chips) do
		n = n + 1
		if not e:is_empty() then
			local ch = e:get_definition()._starlit.chip
			c.cycles = c.cycles + ch.clockRate
			c.ram = c.ram + ch.ram
			c.flashFree = c.flashFree + E.chip.freeSpace(e)
			c.powerEfficiency = c.powerEfficiency + ch.powerEfficiency
		end
	end
	if n > 0 then c.powerEfficiency = c.powerEfficiency / n end
	return c
end

Modified mods/starlit-electronics/sw.lua from [1f9bdf2a9e] to [f5ad2a2c21].

170
171
172
173
174
175
176

177
178
179
180
181
182
183
...
325
326
327
328
329
330
331













			job.cyclesLeft = math.max(0, job.cyclesLeft - ctx.comp.cycles)
			if job.cyclesLeft == 0 then
				job.timeLeft = math.max(0, job.timeLeft - interval)
			end
			if job.timeLeft == 0 and job.cyclesLeft == 0 then
				table.remove(conf, jobSlot)
				user:give(scm.output)

			else
				conf[jobSlot].value = job_t.enc(job)
			end

			ctx.saveConf()
		end;
	}
................................................................................
	size = 1e9;
	cost = {
		cycles = 700e6;
		ram = 1e9;
	};
	run = pasv_heal(4, 50, .7);
})




















>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
...
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
			job.cyclesLeft = math.max(0, job.cyclesLeft - ctx.comp.cycles)
			if job.cyclesLeft == 0 then
				job.timeLeft = math.max(0, job.timeLeft - interval)
			end
			if job.timeLeft == 0 and job.cyclesLeft == 0 then
				table.remove(conf, jobSlot)
				user:give(scm.output)
				user:alarm(-2, 'item')
			else
				conf[jobSlot].value = job_t.enc(job)
			end

			ctx.saveConf()
		end;
	}
................................................................................
	size = 1e9;
	cost = {
		cycles = 700e6;
		ram = 1e9;
	};
	run = pasv_heal(4, 50, .7);
})

starlit.item.sw.link('starlit_electronics:battle_buddy_extreme', {
	name = 'BattleBuddy XTREME';
	kind = 'suitPower', powerKind = 'passive';
	desc = "Who needs a unit medic when you've got BattleBuddy XTREME Edition! BattleBuddy XTREME Edition is fully loaded with emergency response protocols for wounds of every caliber, and is GUARANTEED* to keep you alive as long as you can still crawl to safety. BattleBuddy XTREME is not intended for civilian use. By using BattleBuddy XTREME, you commit to unbind House Vacsatar, its subcontractors, and cadet houses from all liability for product failure, intracellular mutilation, transcription drift, runaway prion cascades, or military defeat.\n*Guarantees not legally binding.";
	size = 4e9;
	cost = {
		cycles = 2000e6;
		ram = 8e9;
	};
	run = pasv_heal(4, 50, .7);
})

Modified mods/starlit-scenario/init.lua from [98f93d94ac] to [739d68f851].

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
	end)))
	local r = E.chip.read(chip)
	r.label = label
	r.files = files
	E.chip.write(chip, r)
	return chip
end






local chipLibrary = {
	compendium = makeChip('The Gentleman Adventurer\'s Compleat Wilderness Compendium', {
		{'starlit_electronics:battery_chemical_imperial_small', 0};
	}, {
		{'starlit_electronics:shred', 0};
		--{'starlit_electronics:compile_empire', 0};
		{'starlit_electronics:autodoc_deluxe', 1};
		--{'starlit_electronics:driver_compiler_empire', 0};
	});
	survivalware = makeChip('Emergency Survivalware', {
		{'starlit_electronics:battery_chemical_commune_small', 0};
		{'starlit_tech:chem_lamp', 0};
	}, {
		{'starlit_electronics:shred', 0};
		{'starlit_electronics:compile_commune', 0};
		{'starlit_electronics:nanomed', 0};
		{'starlit_electronics:driver_compiler_commune', 0};
	});
	misfortune = makeChip("Sold1er0fMisf0rtune TOP Schematic Crackz REPACK", {

		{'starlit_electronics:battery_chemical_usukwinya_mid', 0};
		{'starlit_electronics:battery_hybrid_imperial_small', 0};
		-- ammunition
	}, {});


}

local battery = function(name)
	local s = ItemStack(name)
	starlit.mod.electronics.battery.setChargeF(s, 1.0)
	return s
end








>
>
>
>
>

|

|

|



|

<
|






>



|
>
>







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
	end)))
	local r = E.chip.read(chip)
	r.label = label
	r.files = files
	E.chip.write(chip, r)
	return chip
end

local survivalBasics = {
		{'starlit_tech:chem_lamp', 0};
		{'starlit_tech:crate', 0};
}

local chipLibrary = {
	compendium = makeChip('The Gentleman Adventurer\'s Compleat Wilderness Compendium', lib.tbl.append(survivalBasics, {
		{'starlit_electronics:battery_chemical_imperial_small', 0};
	}), {
		{'starlit_electronics:shred', 0};
		{'starlit_electronics:compile_imperial', 0};
		{'starlit_electronics:autodoc_deluxe', 1};
		--{'starlit_electronics:driver_compiler_empire', 0};
	});
	survivalware = makeChip('Emergency Survivalware', lib.tbl.append(survivalBasics, {
		{'starlit_electronics:battery_chemical_commune_small', 0};

	}), {
		{'starlit_electronics:shred', 0};
		{'starlit_electronics:compile_commune', 0};
		{'starlit_electronics:nanomed', 0};
		{'starlit_electronics:driver_compiler_commune', 0};
	});
	misfortune = makeChip("Sold1er0fMisf0rtune TOP Schematic Crackz REPACK", {
		{'starlit_tech:chem_lamp', 0};
		{'starlit_electronics:battery_chemical_usukwinya_mid', 0};
		{'starlit_electronics:battery_hybrid_imperial_small', 0};
		-- ammunition
	}, {
		{'starlit_electronics:battle_buddy_extreme', 1}; --
	});
}

local battery = function(name)
	local s = ItemStack(name)
	starlit.mod.electronics.battery.setChargeF(s, 1.0)
	return s
end

Modified mods/starlit-scenario/mod.conf from [8a1ae19f59] to [6a41220601].

1
2
3
4
5
name = starlit_scenario
title = starlit scenarios
description = built-in scenarios for Starsoul
depends = starlit, starlit_suit, starlit_electronics, starlit_building, starlit_material
# be sure to add any mods from which you list new starting items!



|

1
2
3
4
5
name = starlit_scenario
title = starlit scenarios
description = built-in scenarios for Starsoul
depends = vtlib, starlit, starlit_suit, starlit_electronics, starlit_building, starlit_material, starlit_tech
# be sure to add any mods from which you list new starting items!

Modified mods/starlit-tech/init.lua from [2a09a8ef6e] to [c5d4cbc341].

11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
..
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
..
61
62
63
64
65
66
67
68



69
70
71
72
73
74
75
..
89
90
91
92
93
94
95















































































		return string.format('starlit_tech:chem_lamp_%s',n)
	end
	local fab = starlit.type.fab {
		element = { carbon = 8, magnesium = 2 };
		cost = { power = 100 };
		flag = { print = true };
		time = { print = 5 };
		reverseEngineer = {
			complexity = 1;
			sw = 'starlit_tech:schematic_chem_lamp';
		};
	};
	for i = stages, 0, -1 do
		minetest.register_node(chemLampID(i), {
			short_description = 'Chem Lamp';
			description = starlit.ui.tooltip {
				title = 'Chem Lamp';
				desc = "A simple carbon-frame chemical light source powered by ambient oxygen. Cheap, quick to print, and biodedragable, without any need for an electric grid or complex power storage mechanism. However, the light only lasts a few days, after which the lamp must be recycled or discarded.";
................................................................................
				props = {
					{title = 'Burn Remaining', desc=lib.math.timespec(stageTimeout * i), affinity=i > 4 and 'good' or 'bad'};
					{title = 'Mass', desc='10g', affinity='info'};
				};
			};
			drawtype = 'nodebox';
			groups = {
				object = 2;
				attached_node = 1;
			};
			node_box = {
				type = 'fixed';
				fixed = {
					-.4, -.5, -.20;
					 .4, -.3,  .20;
................................................................................
			on_timer = i ~= 0 and function(pos)
				local me = minetest.get_node(pos)
				minetest.swap_node(pos, {name=chemLampID(i-1), param2=me.param2})
				return i > 1
			end or nil;
			_starlit = {
				mass = 10;
				fab = fab;



				recover = starlit.type.fab {
					element = {
						carbon = 8;
						magnesium = math.floor(lib.math.lerp(i/stages, 0, 2));
					};
					time = {
						shred = .5;
................................................................................
		cost = {
			cycles = 8e9;
			ram = 16e6;
		};
		rarity = 1;
	})
end






















































































<
<
<
<







 







|







 







|
>
>
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
11
12
13
14
15
16
17




18
19
20
21
22
23
24
..
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
..
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
..
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
		return string.format('starlit_tech:chem_lamp_%s',n)
	end
	local fab = starlit.type.fab {
		element = { carbon = 8, magnesium = 2 };
		cost = { power = 100 };
		flag = { print = true };
		time = { print = 5 };




	};
	for i = stages, 0, -1 do
		minetest.register_node(chemLampID(i), {
			short_description = 'Chem Lamp';
			description = starlit.ui.tooltip {
				title = 'Chem Lamp';
				desc = "A simple carbon-frame chemical light source powered by ambient oxygen. Cheap, quick to print, and biodedragable, without any need for an electric grid or complex power storage mechanism. However, the light only lasts a few days, after which the lamp must be recycled or discarded.";
................................................................................
				props = {
					{title = 'Burn Remaining', desc=lib.math.timespec(stageTimeout * i), affinity=i > 4 and 'good' or 'bad'};
					{title = 'Mass', desc='10g', affinity='info'};
				};
			};
			drawtype = 'nodebox';
			groups = {
				object = 1;
				attached_node = 1;
			};
			node_box = {
				type = 'fixed';
				fixed = {
					-.4, -.5, -.20;
					 .4, -.3,  .20;
................................................................................
			on_timer = i ~= 0 and function(pos)
				local me = minetest.get_node(pos)
				minetest.swap_node(pos, {name=chemLampID(i-1), param2=me.param2})
				return i > 1
			end or nil;
			_starlit = {
				mass = 10;
				reverseEngineer = {
					complexity = 1;
					sw = 'starlit_tech:schematic_chem_lamp';
				};
				recover = starlit.type.fab {
					element = {
						carbon = 8;
						magnesium = math.floor(lib.math.lerp(i/stages, 0, 2));
					};
					time = {
						shred = .5;
................................................................................
		cost = {
			cycles = 8e9;
			ram = 16e6;
		};
		rarity = 1;
	})
end


minetest.register_node('starlit_tech:crate', {
	short_description = 'Crate';
	description = starlit.ui.tooltip {
		title = 'Crate';
		desc = 'A sturdy but lightweight storage crate made from solid carbon polymer.';
		props = { {title='Mass', affinity='info', desc='100g'} };
	};
	drawtype = 'nodebox';
	node_box = {
		type = 'fixed';
		fixed = {
			 .4,  .2,  .4;
			-.4, -.5, -.2;
		};
	};
	groups = {
		object = 3;
		attached_node = 3;
	};
	paramtype2 = 'facedir';
	tiles = {
		'starlit-tech-crate-top.png';
		'starlit-tech-crate-bottom.png';

		'starlit-tech-crate-side.png^[transformFX';
		'starlit-tech-crate-side.png';

		'starlit-tech-crate-back.png';
		'starlit-tech-crate-front.png';
	};
	_starlit = {
		mass = 100;
		reverseEngineer = {
			complexity = 1;
			sw = 'starlit_tech:schematic_crate';
		};
		recover = starlit.type.fab {
			element = { carbon = 100; };
			time = {
				shred = 1;
				shredPower = 3;
			};
		};
	};
	on_construct = function(pos)
		local m = minetest.get_meta(pos)
		local inv = m:get_inventory()
		inv:set_size('starlit:contents', 12)
	end;
	on_rightclick = function(pos, node, luser)
		if not luser then return end
		local user = starlit.activeUsers[luser:get_player_name()]
		user:openUI('starlit:box', 'index', {
			inv={
				{id = 'starlit:contents', pos=pos};
			};
		})
	end;
})

starlit.item.sw.link('starlit_tech:schematic_crate', {
	name = 'Crate Schematic';
	kind = 'schematic';
	input = starlit.type.fab {
		element = { carbon = 100; };
		flag = {print = true};
		time = {print = 25};
		cost = {power = 250};
	};
	output = 'starlit_tech:crate';
	size = 48e6;
	cost = {
		cycles = 12e9;
		ram = 16e6;
	};
	rarity = 1;
})

Modified mods/starlit/compile.lua from [8a9b22510e] to [5db02bfe42].

314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
							{kind = 'button', w=5,h=1.5; id='showAll', label='Show All'};
							{kind = 'button', w=5,h=1.5; id='find', label='Find'};
						})
					end
				else
					if sel.scm == nil then
						for idx, ent in ipairs(sel.scms) do
							local fab = ItemStack(ent.sw.output):get_definition()._starlit.fab
							if fab.flag and fab.flag.print then
								local req = fab:visualize()
								pushSelector('scm_' .. idx, ent.sw.output, ent.sw.name, nil, req)
							end
						end
						table.insert(pgmSelector, back)
					else







|







314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
							{kind = 'button', w=5,h=1.5; id='showAll', label='Show All'};
							{kind = 'button', w=5,h=1.5; id='find', label='Find'};
						})
					end
				else
					if sel.scm == nil then
						for idx, ent in ipairs(sel.scms) do
							local fab = ent.sw.input
							if fab.flag and fab.flag.print then
								local req = fab:visualize()
								pushSelector('scm_' .. idx, ent.sw.output, ent.sw.name, nil, req)
							end
						end
						table.insert(pgmSelector, back)
					else

Modified mods/starlit/init.lua from [a5bde19f07] to [df4ee2ddd8].

399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
})
minetest.register_item("starlit:_hand_dig", {
	type = "none",
	wield_image = "wieldhand.png",
	wield_scale = {x=1,y=1,z=2.5},
	tool_capabilities = {
		groupcaps = {
			object = {maxlevel=1, times = {.20,.10}};
			plant = {maxlevel=1, times = {.50}};

			-- sand, dirt, gravel
			looseClump = {maxlevel=1, times = {1.5, 2.5}};
		};
	}
})







|







399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
})
minetest.register_item("starlit:_hand_dig", {
	type = "none",
	wield_image = "wieldhand.png",
	wield_scale = {x=1,y=1,z=2.5},
	tool_capabilities = {
		groupcaps = {
			object = {maxlevel=1, times = {.10,.20,.40}};
			plant = {maxlevel=1, times = {.50}};

			-- sand, dirt, gravel
			looseClump = {maxlevel=1, times = {1.5, 2.5}};
		};
	}
})

Modified mods/starlit/interfaces.lua from [ddaa1e9478] to [39c7d68ac6].

93
94
95
96
97
98
99

100
101
102
103
104
105
106
...
306
307
308
309
310
311
312
















313
314
315
316






317

318
319
320
321
322
323
324
325
...
515
516
517
518
519
520
521




































			kind = i.img and 'contact' or 'button', close = i.close;
			color = i.color;
			fg = i.fg;
			label = i.label;
			img = i.img;
			id = i.id;
			w = bw, h = rh;

		})
		if i.cfg then 
			table.insert(bar, {
				kind = 'button';
				color = i.color;
				fg = i.fg;
				label = "CFG";
................................................................................
								if e.key == 'disable' and e.value == 'yes' then
									color.lum = -.2
									fg = lib.color {hue=color.hue,sat=0.7,lum=0.7}
									break
								end
							end
						end
















						if tbl then table.insert(tbl, {
							color = color, fg = fg;
							label = r.sw.label or r.sw.name;
							id = string.format('suit_pgm_%s_', id);






							cfg = cfg, close = close;

						}) end
					end
				end
				local menu = { kind = 'vert', mode = 'sw', padding = 0.5 }
				if swm then table.insert(menu, abilityMenu(swm)) end

				local inv = user.entity:get_inventory()
				--[[
................................................................................
					user:suitPowerStateSet(suitMode)
					return true
				end
			end;
		};
	};
})











































>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|
|
|
>
>
>
>
>
>
|
>
|







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
...
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
...
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
			kind = i.img and 'contact' or 'button', close = i.close;
			color = i.color;
			fg = i.fg;
			label = i.label;
			img = i.img;
			id = i.id;
			w = bw, h = rh;
			desc = i.desc;
		})
		if i.cfg then 
			table.insert(bar, {
				kind = 'button';
				color = i.color;
				fg = i.fg;
				label = "CFG";
................................................................................
								if e.key == 'disable' and e.value == 'yes' then
									color.lum = -.2
									fg = lib.color {hue=color.hue,sat=0.7,lum=0.7}
									break
								end
							end
						end
						if tbl then
							local props = {
								{title = "Size", desc=lib.math.siUI('B', r.sw.size), affinity='info'};
							}
							if r.sw.cost and r.sw.cost.ram then
								table.insert(props, {title = "Memory Usage", desc=lib.math.siUI('B', r.sw.cost.ram), affinity='info'})
							end
							if r.sw.cost and r.sw.cost.cycles then
								table.insert(props, {title = "Compute Usage", desc=lib.math.siUI('cycles',r.sw.cost.cycles,true), affinity='info'})
							end
							if r.powerCost then
								table.insert(props, {title = "Power Draw", desc=lib.math.siUI('W', r.powerCost), affinity='info'})
							end
							if r.speed then
								table.insert(props, {title = "Minimum Runtime", desc=lib.math.timespec(r.speed), affinity='info'})
							end
							table.insert(tbl, {
								color = color, fg = fg;
								label = r.sw.label or r.sw.name;
								id = string.format('suit_pgm_%s_', id);
								desc = starlit.ui.tooltip {
									title = r.sw.name;
									desc = r.sw.desc;
									color = lib.color(1,0,.8);
									props = props;
								};
								cfg = cfg, close = close;
							})
						end
					end
				end
				local menu = { kind = 'vert', mode = 'sw', padding = 0.5 }
				if swm then table.insert(menu, abilityMenu(swm)) end

				local inv = user.entity:get_inventory()
				--[[
................................................................................
					user:suitPowerStateSet(suitMode)
					return true
				end
			end;
		};
	};
})

starlit.interface.install(starlit.type.ui {
	id = 'starlit:box';
	pages = {
		index = {
			setupState = function(state, user, ctx)
				state.ctx = ctx
			end;
			handle = function(state, user, q)
				if q.quit then
					user:suitSound 'starlit-quit' -- TODO better sound
				end
			end;
			render = function(state, user)
				local body = {kind='vert', w=6; mode='hw', spacing=.5, padding=1 }
				for i, l in ipairs(state.ctx.inv) do
					local inv = minetest.get_meta(l.pos):get_inventory()
					local w = l.w or 6
					if l.label then
						table.insert(body, {kind = 'hbar'; text = l.label, w=w+.5, h = .5})
					end
					table.insert(body, {kind = 'list';
						w = w, h = inv:get_size(l.id)/w;
						node = l.pos, inv = l.id;
						spacing = .1;
					})
				end
				table.insert(body, {kind = 'list';
					target = 'current_player', inv = 'main';
					w = 6, h = 1, spacing = 0.1;
				})
				return starlit.ui.build(body)
			end;
		}
	}
})

Modified mods/starlit/ui.lua from [16bf595c8c] to [5149fd5b74].

131
132
133
134
135
136
137

138
139
140
141
142
143
144

145
146
147
148
149
150
151
...
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213




214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
...
231
232
233
234
235
236
237

238
239
240
241
242
243
244

245
246
247
248
249
250
251
252
253




254
255
256
257
258
259
260
...
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
		return climg('',         'starlit-ui-button-sw.png')       ..
		       climg(':hovered', 'starlit-ui-button-sw-hover.png') ..
		       climg(':pressed', 'starlit-ui-button-sw-press.png')
	end
	local function widget(...)
		table.insert(lines, string.format(...))
	end

	if def.kind == 'vert' then
		for _, w in ipairs(def) do
			local src, st = starlit.ui.build(w, state)
			widget('container[%s,%s]%scontainer_end[]', state.x, state.y, src)
			state.y=state.y + state.spacing + st.h
			state.w = math.max(state.w, st.w)
		end

		state.w = state.w + state.padding
		state.h = state.y + state.padding/2
	elseif def.kind == 'hztl' then
		for _, w in ipairs(def) do
			local src, st = starlit.ui.build(w, state)
			widget('container[%s,%s]%scontainer_end[]', state.x, state.y, src)
			-- TODO alignments
................................................................................
				def.id)
		end
		state.w = state.w + state.padding
		state.h = state.h + state.padding/2
	elseif def.kind == 'list' then
		local slotTypes = {
			plain = {hue = 200, sat = -.1, lum = 0};
			element = {hue = 20, sat = -.3, lum = 0};
			chip = {hue = 0, sat = -1, lum = 0};
			psi = {hue = 300, sat = 0, lum = 0};
			power = {hue = 50, sat = 0, lum = .2};
		}
		local img
		if state.mode == 'hw' then
			img = lib.image('starlit-ui-slot-physical.png');
		else
			img = lib.image('starlit-ui-slot.png'):shift(slotTypes[def.listContent or 'plain']);
		end
		local spac = state.spacing




		widget('style_type[list;spacing=%s,%s]',spac,spac)
		assert(def.w and def.h, 'ui-lists require a fixed size')
		for lx = 0, def.w-1 do
		for ly = 0, def.h-1 do
			local ox, oy = state.x + lx*(1+spac), state.y + ly*(1+spac)
			table.insert(lines, string.format('image[%s,%s;1.1,1.1;%s]', ox-0.05,oy-0.05, img:render()))
		end end
		table.insert(lines, string.format('listcolors[#00000000;#ffffff10]')) -- FIXME
		table.insert(lines, string.format('list[%s;%s;%s,%s;%s,%s;%s]',
			E(def.target), E(def.inv),
			state.x, state.y,
			def.w,   def.h,
			def.idx))
		local sm = 1
		state.w = def.w * sm + (spac * (def.w - 1))
		state.h = def.h * sm + (spac * (def.h - 1))
	elseif def.kind == 'contact' then
................................................................................
		if def.color then table.insert(lines, btnColorDef(def.id)) end
		local img = def.img
		local desc
		if def.item then
			img  = ItemStack(def.item):get_name()
			desc = ItemStack(def.item):get_description()
		end

		widget('%simage_button%s[%s,%s;%s,%s;%s;%s;%s]',
			def.item and 'item_' or '',
			def.close and '_exit' or '',
			state.x, state.y, def.w, def.h,
			E(img), E(def.id), E(def.label or ''))
		if desc and not def.desc then
			widget('tooltip[%s;%s]', E(def.id), E(desc))

		end
	elseif def.kind == 'button' then
		if def.color then table.insert(lines, btnColorDef(def.id)) end
		local label = E(def.label or '')
		if state.fg then label = lib.color(state.fg):fmt(label) end
		widget('button%s[%s,%s;%s,%s;%s;%s]',
			def.close and '_exit' or '',
			state.x, state.y, def.w, def.h,
			E(def.id), label)




	elseif def.kind == 'img' then
		widget('%s[%s,%s;%s,%s;%s]',
			def.item and 'item_image' or 'image',
			state.x, state.y, def.w, def.h, E(def.item or def.img))
	elseif def.kind == 'label' then
		local txt = E(def.text)
		if state.fg then txt = lib.color(state.fg):fmt(txt) end
................................................................................
		if def.text then
			widget('hypertext[%s,%s;%s,%s;;%s]',
				state.x, state.y, def.w, def.h,
				string.format('<global halign=center valign=middle color=%s>%s', fg:hex(), E(def.text)))
		end
	end

	if def.desc then
		local coord
		if def.id then
			coord = E(def.id)
		else
			coord = string.format("%s,%s;%s,%s", state.x, state.y, def.w, def.h)
		end
		widget('tooltip[%s;%s;#000000;#ffffff]', coord, E(def.desc))







>







>







 







|

|









>
>
>
>









|







 







>





|

>









>
>
>
>







 







|







131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
...
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
...
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
...
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
		return climg('',         'starlit-ui-button-sw.png')       ..
		       climg(':hovered', 'starlit-ui-button-sw-hover.png') ..
		       climg(':pressed', 'starlit-ui-button-sw-press.png')
	end
	local function widget(...)
		table.insert(lines, string.format(...))
	end
	local specializedTooltip = false
	if def.kind == 'vert' then
		for _, w in ipairs(def) do
			local src, st = starlit.ui.build(w, state)
			widget('container[%s,%s]%scontainer_end[]', state.x, state.y, src)
			state.y=state.y + state.spacing + st.h
			state.w = math.max(state.w, st.w)
		end
		state.y = state.y - state.spacing
		state.w = state.w + state.padding
		state.h = state.y + state.padding/2
	elseif def.kind == 'hztl' then
		for _, w in ipairs(def) do
			local src, st = starlit.ui.build(w, state)
			widget('container[%s,%s]%scontainer_end[]', state.x, state.y, src)
			-- TODO alignments
................................................................................
				def.id)
		end
		state.w = state.w + state.padding
		state.h = state.h + state.padding/2
	elseif def.kind == 'list' then
		local slotTypes = {
			plain = {hue = 200, sat = -.1, lum = 0};
-- 			element = {hue = 20, sat = -.3, lum = 0};
			chip = {hue = 0, sat = -1, lum = 0};
-- 			psi = {hue = 300, sat = 0, lum = 0};
			power = {hue = 50, sat = 0, lum = .2};
		}
		local img
		if state.mode == 'hw' then
			img = lib.image('starlit-ui-slot-physical.png');
		else
			img = lib.image('starlit-ui-slot.png'):shift(slotTypes[def.listContent or 'plain']);
		end
		local spac = state.spacing
		local target = def.target
		if not target and def.node then
			target=string.format('nodemeta:%s,%s,%s', def.node.x,def.node.y,def.node.z)
		end
		widget('style_type[list;spacing=%s,%s]',spac,spac)
		assert(def.w and def.h, 'ui-lists require a fixed size')
		for lx = 0, def.w-1 do
		for ly = 0, def.h-1 do
			local ox, oy = state.x + lx*(1+spac), state.y + ly*(1+spac)
			table.insert(lines, string.format('image[%s,%s;1.1,1.1;%s]', ox-0.05,oy-0.05, img:render()))
		end end
		table.insert(lines, string.format('listcolors[#00000000;#ffffff10]')) -- FIXME
		table.insert(lines, string.format('list[%s;%s;%s,%s;%s,%s;%s]',
			E(target), E(def.inv),
			state.x, state.y,
			def.w,   def.h,
			def.idx))
		local sm = 1
		state.w = def.w * sm + (spac * (def.w - 1))
		state.h = def.h * sm + (spac * (def.h - 1))
	elseif def.kind == 'contact' then
................................................................................
		if def.color then table.insert(lines, btnColorDef(def.id)) end
		local img = def.img
		local desc
		if def.item then
			img  = ItemStack(def.item):get_name()
			desc = ItemStack(def.item):get_description()
		end
		desc = def.desc or desc
		widget('%simage_button%s[%s,%s;%s,%s;%s;%s;%s]',
			def.item and 'item_' or '',
			def.close and '_exit' or '',
			state.x, state.y, def.w, def.h,
			E(img), E(def.id), E(def.label or ''))
		if desc then
			widget('tooltip[%s;%s]', E(def.id), E(desc))
			specializedTooltip = true
		end
	elseif def.kind == 'button' then
		if def.color then table.insert(lines, btnColorDef(def.id)) end
		local label = E(def.label or '')
		if state.fg then label = lib.color(state.fg):fmt(label) end
		widget('button%s[%s,%s;%s,%s;%s;%s]',
			def.close and '_exit' or '',
			state.x, state.y, def.w, def.h,
			E(def.id), label)
		if def.desc then
			widget('tooltip[%s;%s]', E(def.id), E(def.desc))
			specializedTooltip = true
		end
	elseif def.kind == 'img' then
		widget('%s[%s,%s;%s,%s;%s]',
			def.item and 'item_image' or 'image',
			state.x, state.y, def.w, def.h, E(def.item or def.img))
	elseif def.kind == 'label' then
		local txt = E(def.text)
		if state.fg then txt = lib.color(state.fg):fmt(txt) end
................................................................................
		if def.text then
			widget('hypertext[%s,%s;%s,%s;;%s]',
				state.x, state.y, def.w, def.h,
				string.format('<global halign=center valign=middle color=%s>%s', fg:hex(), E(def.text)))
		end
	end

	if def.desc and not specializedTooltip then
		local coord
		if def.id then
			coord = E(def.id)
		else
			coord = string.format("%s,%s;%s,%s", state.x, state.y, def.w, def.h)
		end
		widget('tooltip[%s;%s;#000000;#ffffff]', coord, E(def.desc))

Modified mods/starlit/user.lua from [aa3a95c242] to [d58ed76b59].

52
53
54
55
56
57
58





59
60
61
62
63
64
65
...
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309



310
311
312
313
314
315
316
		side = 'right';
	};
	fatigue = {
		icon = lib.image('starlit-ui-alert-fatigue.png');
		bg = lib.image('starlit-ui-alert-bg-fatigue.png');
		side = 'right';
	};





}

starlit.type.user = lib.class {
	name = 'starlit:user';
	leds = leds;
	construct = function(ident)
		local name, luser
................................................................................
				local v,txt,color,txtcolor,hl,hlcolor = def.measure(luser,def)
				v = math.max(0, math.min(1, v))
				local n = math.floor(v*16) + 1
				local function adjust(img)
					return hudAdjustBacklight(lib.image(img)):shift(color or def.color)
				end
				local img = adjust 'starlit-ui-meter.png'
				if def.flipX then
					img = img:transform 'FX'
				end
				img = img:render()
				img = img .. '^[verticalframe:17:' .. tostring(17 - n)
				if hl then
					hl = math.floor(hl*16) + 1
					local hi = hudAdjustBacklight(lib.image 'starlit-ui-meter-hl.png')
						:shift(hlcolor or def.color)
						:render()
					hi = hi .. '^[verticalframe:17:' .. tostring(17 - hl)
					img = string.format('%s^(%s)', img, hi)
				end
				img = string.format('%s^(%s)', img, adjust 'starlit-ui-meter-readout.png':render())



				luser:hud_change(m.meter, 'text', img)
				if txt then
					luser:hud_change(m.readout, 'text', txt)
				end
				if txtcolor then
					luser:hud_change(m.readout, 'number', txtcolor:hex())
				end







>
>
>
>
>







 







<
<
<











>
>
>







52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
...
294
295
296
297
298
299
300



301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
		side = 'right';
	};
	fatigue = {
		icon = lib.image('starlit-ui-alert-fatigue.png');
		bg = lib.image('starlit-ui-alert-bg-fatigue.png');
		side = 'right';
	};
	item = {
		icon = lib.image('starlit-ui-alert-item.png');
		bg = lib.image('starlit-ui-alert-bg-success.png');
		side = 'right';
	};
}

starlit.type.user = lib.class {
	name = 'starlit:user';
	leds = leds;
	construct = function(ident)
		local name, luser
................................................................................
				local v,txt,color,txtcolor,hl,hlcolor = def.measure(luser,def)
				v = math.max(0, math.min(1, v))
				local n = math.floor(v*16) + 1
				local function adjust(img)
					return hudAdjustBacklight(lib.image(img)):shift(color or def.color)
				end
				local img = adjust 'starlit-ui-meter.png'



				img = img:render()
				img = img .. '^[verticalframe:17:' .. tostring(17 - n)
				if hl then
					hl = math.floor(hl*16) + 1
					local hi = hudAdjustBacklight(lib.image 'starlit-ui-meter-hl.png')
						:shift(hlcolor or def.color)
						:render()
					hi = hi .. '^[verticalframe:17:' .. tostring(17 - hl)
					img = string.format('%s^(%s)', img, hi)
				end
				img = string.format('%s^(%s)', img, adjust 'starlit-ui-meter-readout.png':render())
				if def.flipX then
					img = img .. '^[transformFX'
				end
				luser:hud_change(m.meter, 'text', img)
				if txt then
					luser:hud_change(m.readout, 'text', txt)
				end
				if txtcolor then
					luser:hud_change(m.readout, 'number', txtcolor:hex())
				end

Modified mods/vtlib/image.lua from [33182947e9] to [a9a0d17ab5].

11
12
13
14
15
16
17
18
19
20
21
22
23
24



25
26
27
28
29
30
31
			local bracket = false
			if self.combine then
				str = string.format('[combine:%sx%s', self.w, self.h)
				for _,i in pairs(self.atop) do
					str = str .. string.format(':%s,%s=(%s)', i.at.x, i.at.y, i.img:render())
				end
			else
				for _,i in pairs(self.atop) do
					str = '(' .. i.img:render() .. ')^' .. str
				end
				if str ~= '' then
					str = str .. '('
					bracket = true
				end



				str = str .. self.string
			end
			for _,e in pairs(self.fx) do
				str = str .. '^[' .. e
				-- be sure to escape ones that take arguments
				-- correctly!
			end







<
<
<




>
>
>







11
12
13
14
15
16
17



18
19
20
21
22
23
24
25
26
27
28
29
30
31
			local bracket = false
			if self.combine then
				str = string.format('[combine:%sx%s', self.w, self.h)
				for _,i in pairs(self.atop) do
					str = str .. string.format(':%s,%s=(%s)', i.at.x, i.at.y, i.img:render())
				end
			else



				if str ~= '' then
					str = str .. '('
					bracket = true
				end
				for _,i in pairs(self.atop) do
					str = '(' .. i.img:render() .. ')^' .. str
				end
				str = str .. self.string
			end
			for _,e in pairs(self.fx) do
				str = str .. '^[' .. e
				-- be sure to escape ones that take arguments
				-- correctly!
			end

Modified mods/vtlib/math.lua from [557fe13815] to [276f7a5d6e].

77
78
79
80
81
82
83

84
85
86
87
88
89
90
...
154
155
156
157
158
159
160

161
162
163
164
165
166
167
168
169
170
171
172
173
					return string.format("%s%s%s",
						vd, (full and (' ' .. pmin) or smin), unitForAmt(vd))
				end
			end
		end
	end


	return string.format("%s%s", val, unitForAmt(val))
end
function fn.siUI(u,v,f,us,...) return fn.si(u,v,f,us,2,...) end

function fn.lerp(t, a, b) return (1-t)*a + t*b end
function fn.gradient(grad, pos)
	local n = #grad
................................................................................
	end;
}
-- function fn.vlerp

function fn.timespec(n)
	if n == 0 then return '0s' end
	if n < 0 then return '-' .. fn.timespec(n*-1) end


	local sec = math.floor(n % 60)
	local min = math.floor(n / 60)
	local hr = math.floor(min / 60)
	min = min % 60
	local spec = {}

	if hr  ~= 0 then table.insert(spec, string.format("%shr", hr))  end
	if min  ~= 0 then table.insert(spec, string.format("%sm", min))  end
	if sec ~= 0 then table.insert(spec, string.format("%ss",  sec)) end
	return table.concat(spec, ' ')
end
return fn







>







 







>













77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
...
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
					return string.format("%s%s%s",
						vd, (full and (' ' .. pmin) or smin), unitForAmt(vd))
				end
			end
		end
	end

	if prec then val = lib.math.trim(val,prec) end
	return string.format("%s%s", val, unitForAmt(val))
end
function fn.siUI(u,v,f,us,...) return fn.si(u,v,f,us,2,...) end

function fn.lerp(t, a, b) return (1-t)*a + t*b end
function fn.gradient(grad, pos)
	local n = #grad
................................................................................
	end;
}
-- function fn.vlerp

function fn.timespec(n)
	if n == 0 then return '0s' end
	if n < 0 then return '-' .. fn.timespec(n*-1) end
	if n < 1 then return fn.siUI('s', n) end

	local sec = math.floor(n % 60)
	local min = math.floor(n / 60)
	local hr = math.floor(min / 60)
	min = min % 60
	local spec = {}

	if hr  ~= 0 then table.insert(spec, string.format("%shr", hr))  end
	if min  ~= 0 then table.insert(spec, string.format("%sm", min))  end
	if sec ~= 0 then table.insert(spec, string.format("%ss",  sec)) end
	return table.concat(spec, ' ')
end
return fn