starlit  Check-in [5267c0742d]

Overview
Comment:add basic electrical parts, fix scrollbars to the greatest extent possible, fix error in marshal error msg, tweak inane compute stats
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 5267c0742dc28ca6c50bf7ce78bcfa3dec0dc793cd8dd0543b9c0fce5e47f56e
User & Date: lexi on 2024-05-07 00:27:19
Other Links: manifest | tags
Context
2024-05-07
03:45
compiler now draws power, better compile job progress bars, stats screen refreshes check-in: 52a4f364ac user: lexi tags: trunk
00:27
add basic electrical parts, fix scrollbars to the greatest extent possible, fix error in marshal error msg, tweak inane compute stats check-in: 5267c0742d user: lexi tags: trunk
2024-05-06
21:29
fix image regression check-in: 108df84ed3 user: lexi tags: trunk
Changes

Modified mods/starlit-building/init.lua from [7b434e8bee] to [35031ce713].

5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
..
59
60
61
62
63
64
65
66
67
68
69
70
71
72



73
74











































75
76
77
78
79
80
81
...
129
130
131
132
133
134
135

B.path = {}
-- this maps stage IDs to tables of the following form
--[[ {
	part = {
		['starlit_building:pipe'] = 'myMod:stage3';
	};
	tool = {
		['starlit:scredriver'] = 'myMod:otherThing_stage1';
		['starlit:saw'] = function(node, tool)
			minetest.replace_node(node, {name='myMod:stage1'})
			minetest.drop_item(node, 'starlit_building:pipe')
		end;
		['myMod:laserWrench'] = {
			allow = function(node, tool) ... end;
			handle = function(node, tool) ... end;
................................................................................
			fixed = { ... };
		};
	})
]]

B.part = lib.registry.mk 'starlit_building:part'
-- a part is implemented as a special craftitem with the proper callbacks
-- to index the registries and place/replace noes by reference to the
-- build tree.
--[[
	starlit.mod.building.part.link(id, {
		name = ''; -- display name
		desc = ''; -- display desc
		img = ''; -- display image



	})
]]












































B.stage.foreach('starlit:stageGen', {}, function(id, e)
	local box = {type = 'fixed', fixed = {}}
	local tex = {}
	local ofs = vector.new(0,0,0)
	for idx, p in ipairs(e.pieces) do
		local ho, pieceID, pos
................................................................................
end

function B.pathFind(from, kind, what)
	if not B.path[from] then return nil end
	return B.path[from][kind][what]
end









|







 







|






>
>
>


>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
..
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
...
175
176
177
178
179
180
181
182
B.path = {}
-- this maps stage IDs to tables of the following form
--[[ {
	part = {
		['starlit_building:pipe'] = 'myMod:stage3';
	};
	tool = {
		['starlit:screwdriver'] = 'myMod:otherThing_stage1';
		['starlit:saw'] = function(node, tool)
			minetest.replace_node(node, {name='myMod:stage1'})
			minetest.drop_item(node, 'starlit_building:pipe')
		end;
		['myMod:laserWrench'] = {
			allow = function(node, tool) ... end;
			handle = function(node, tool) ... end;
................................................................................
			fixed = { ... };
		};
	})
]]

B.part = lib.registry.mk 'starlit_building:part'
-- a part is implemented as a special craftitem with the proper callbacks
-- to index the registries and place/replace nodes by reference to the
-- build tree.
--[[
	starlit.mod.building.part.link(id, {
		name = ''; -- display name
		desc = ''; -- display desc
		img = ''; -- display image
		mass = 0;
		fab = {}; -- (optional) auto-gen schematic
		rarity = 0;
	})
]]
B.part.foreach('starlit:partGen', {}, function(id, e)
	local props = {}
	if e.mass then
		table.insert(props, {title='Mass', desc=lib.math.siUI('g',e.mass), affinity='info'})
	end
	local rev, scmID
	if e.fab then
		scmID = string.format('%s_schematic', id)
		rev = {
			sw = scmID;
			complexity = e.complexity or 1;
		}
	end
	minetest.register_craftitem(id, {
		short_description = e.name;
		description = starlit.ui.tooltip {
			title = e.name;
			desc = e.desc;
			props = props;
		};
		inventory_image = e.img;
		_starlit = {
			mass = e.mass;
			reverseEngineer = rev;
			recover = e.recover or e.fab;
		};
	})
	if e.fab then
		starlit.item.sw.link(scmID, {
			kind = 'schematic';
			name = string.format('%s Schematic', e.name);
			size = e.size or 32e6;
			input = e.fab;
			output = id;
			cost = e.cost or {
				cycles = 4e9;
				ram = 1e9;
			};
			rarity = e.rarity or 0;
		})
	end

end)

B.stage.foreach('starlit:stageGen', {}, function(id, e)
	local box = {type = 'fixed', fixed = {}}
	local tex = {}
	local ofs = vector.new(0,0,0)
	for idx, p in ipairs(e.pieces) do
		local ho, pieceID, pos
................................................................................
end

function B.pathFind(from, kind, what)
	if not B.path[from] then return nil end
	return B.path[from][kind][what]
end

starlit.include 'parts'

Added mods/starlit-building/parts.lua version [01ffc64dd2].

















































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
local lib = starlit.mod.lib
local E = starlit.mod.electronics
local B = starlit.mod.building

B.part.link('starlit_building:battery_box', {
	name = 'Battery Box';
	desc = 'A receptacle for a battery.';
	img = 'starlit-item-battery-box.png';
	fab = starlit.type.fab {
		element = {
			copper = 5;
			aluminum = 10;
		};
		cost = {power = 300};
		flag = {print=true};
		time = {print=10};
	};
	mass = 15;
	rarity = 1;
})

B.part.link('starlit_building:electrode', {
	name = 'Electrode';
	desc = 'An electrical conductor used to make contact with a nonmetallic circuit component.';
	img = 'starlit-item-electrode.png';
	fab = starlit.type.fab {
		element = {
			copper = 1;
			aluminum = 1;
		};
		cost = {power = 150};
		flag = {print=true};
		time = {print=5};
	};
	mass = 2;
	rarity = 1;
})

B.part.link('starlit_building:heating_element', {
	name = 'Heating Element';
	desc = 'An extremely inefficient conductor of electricity.';
	img = 'starlit-item-heating-element.png';
	fab = starlit.type.fab {
		element = {
			copper = 2;
			nickel = 2;
		};
		cost = {power = 300};
		flag = {print=true};
		time = {print=10};
	};
	mass = 4;
	rarity = 1;
})

B.part.link('starlit_building:cable_electric', {
	name = 'Electric Cable';
	desc = 'A length of conductive metal in a protective graphene sheathe.';
	img = 'starlit-item-cable-electric.png';
	fab = starlit.type.fab {
		element = {
			copper = 16;
			carbon = 16;
		};
		cost = {power = 700};
		flag = {print=true};
		time = {print=20};
	};
	mass = 32;
	rarity = 1;
})

B.part.link('starlit_building:transformer', {
	name = 'Transformer';
	desc = 'An electrical component used to step-up or step-down voltage levels.';
	img = 'starlit-item-transformer.png';
	fab = starlit.type.fab {
		element = {
			copper = 8;
			iron = 16;
		};
		cost = {power = 500};
		flag = {print=true};
		time = {print=20};
	};
	mass = 24;
	rarity = 1;
})

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

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

183
184
185
186
187
188
189
190
191
192
193
194
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
		end;
	}
end

starlit.item.sw.link('starlit_electronics:compile_commune', matterCompiler {
	name = 'Compile Matter';
	desc = "A basic suit matter compiler program. It's rather slow, but it's been ruthlessly optimized for size- and memory-efficiency by some of the Commune's most fanatic coders, to the point where every Commune nanosuit can come with the program preinstalled.";
	size = 700e3;
	cost = {
		cycles = 4e9;
		ram = .3e9;
	};
})

starlit.item.sw.link('starlit_electronics:compile_block_commune', {
	name = 'Compile Block';
	kind = 'suitPower', powerKind = 'active';
	desc = "An advanced suit matter compiler program, capable of printing complete devices and structure parts directly into the world.";
	size = 5e6;
	cost = {
		cycles = 8e9;
		ram = 1e9;
	};
	ui = 'starlit:compile-matter-block';
	run = function(user, ctx)
	end;
})

starlit.item.sw.link('starlit_electronics:compile_imperial', matterCompiler {
	name = 'Genesis Deluxe';
	desc = "House Bascundir has long dominated the matter compiler market in the Crystal Sea. Their firmware is excessively complex due to mountains of specialized edge-case handling, but the end result is certainly speedier than the competitors'.";
	size = 2e4;
	cost = {
		cycles = 100e6;
		ram = 1.5e9;
	};
})

do local J = starlit.store.compilerJob
	starlit.item.sw.link('starlit_electronics:driver_compiler_commune', {
		name = 'Matter Compiler';







|










|












|

|







183
184
185
186
187
188
189
190
191
192
193
194
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
		end;
	}
end

starlit.item.sw.link('starlit_electronics:compile_commune', matterCompiler {
	name = 'Compile Matter';
	desc = "A basic suit matter compiler program. It's rather slow, but it's been ruthlessly optimized for size- and memory-efficiency by some of the Commune's most fanatic coders, to the point where every Commune nanosuit can come with the program preinstalled.";
	size = 700e6;
	cost = {
		cycles = 4e9;
		ram = .3e9;
	};
})

starlit.item.sw.link('starlit_electronics:compile_block_commune', {
	name = 'Compile Block';
	kind = 'suitPower', powerKind = 'active';
	desc = "An advanced suit matter compiler program, capable of printing complete devices and structure parts directly into the world.";
	size = 500e6;
	cost = {
		cycles = 8e9;
		ram = 1e9;
	};
	ui = 'starlit:compile-matter-block';
	run = function(user, ctx)
	end;
})

starlit.item.sw.link('starlit_electronics:compile_imperial', matterCompiler {
	name = 'Genesis Deluxe';
	desc = "House Bascundir has long dominated the matter compiler market in the Crystal Sea. Their firmware is excessively complex due to mountains of specialized edge-case handling, but the end result is certainly speedier than the competitors'.";
	size = 2e9;
	cost = {
		cycles = 1e9;
		ram = 1.5e9;
	};
})

do local J = starlit.store.compilerJob
	starlit.item.sw.link('starlit_electronics:driver_compiler_commune', {
		name = 'Matter Compiler';

Modified mods/starlit-material/elements.lua from [81b3a1522a] to [0b9dddbb90].

76
77
78
79
80
81
82





83
84
85
86
87
88
89
		color = lib.color(.7,.7,.7);
	};
	vanadium = {
		name = 'vanadium', sym = 'V', n = 23; density = 6;
		metal = true;
		color = lib.color(.3,0.5,.3);
	};





	xenon = {
		name = 'xenon', sym = 'Xe', n = 54;  density = 0.005894;
		gas = true;
		color = lib.color(.5,.1,1);
	};
	argon = {
		name = 'argon', sym = 'Ar', n = 18;  density = 0.001784;







>
>
>
>
>







76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
		color = lib.color(.7,.7,.7);
	};
	vanadium = {
		name = 'vanadium', sym = 'V', n = 23; density = 6;
		metal = true;
		color = lib.color(.3,0.5,.3);
	};
	nickel = {
		name = 'nickel', sym = 'ni', n = 28, density = 8.908;
		metal = true;
		color = lib.color(.7,.7,.6);
	};
	xenon = {
		name = 'xenon', sym = 'Xe', n = 54;  density = 0.005894;
		gas = true;
		color = lib.color(.5,.1,1);
	};
	argon = {
		name = 'argon', sym = 'Ar', n = 18;  density = 0.001784;

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

34
35
36
37
38
39
40





41
42
43
44
45
46
47
	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};







>
>
>
>
>







34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
	E.chip.write(chip, r)
	return chip
end

local survivalBasics = {
		{'starlit_tech:chem_lamp', 0};
		{'starlit_tech:crate', 0};
		{'starlit_building:battery_box', 0};
		{'starlit_building:heating_element', 0};
		{'starlit_building:electrode', 0};
		{'starlit_building:cable_electric', 0};
		{'starlit_building:transformer', 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};

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

94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
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;







|







94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
end


minetest.register_node('starlit_tech:crate', {
	short_description = 'Crate';
	description = starlit.ui.tooltip {
		title = 'Crate';
		desc = 'A sturdy but lightweight storage crate woven from graphene.';
		props = { {title='Mass', affinity='info', desc='100g'} };
	};
	drawtype = 'nodebox';
	node_box = {
		type = 'fixed';
		fixed = {
			 .4,  .2,  .4;

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

321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
							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;







|







321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
							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 = "Base 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;

Modified mods/starlit/ui.lua from [5149fd5b74] to [60598b98d5].

176
177
178
179
180
181
182

183
184
185
186




187
188
189



190
191
192







193
194

195
196
197
198

199
200

201
202
203
204
205
206
207
...
323
324
325
326
327
328
329

330
331
332
333
334
335
336
			maxX = math.max(state.x, maxX)
		end
		totalH = totalH + rowH
		state.h = math.max(state.h, totalH) + state.padding
		state.w = state.x + state.padding/2
		state.x = maxX
	elseif def.kind == 'pane' then

		widget('scroll_container[%s,%s;%s,%s;%s;vertical]',
			state.x, state.y, state.w, state.h,
			def.id)
		local y = 0




		for _, w in ipairs(def) do
			local src, st = starlit.ui.build(w, state)
			widget('container[%s,%s]%scontainer_end[]', 0, y, src)



			y=y + state.spacing + st.h
			state.w = math.max(state.w, st.w)
		end







		widget('scroll_container_end[]')
		if y > state.h then

			widget('scrollbar[%s,%s;%s,%s;vertical;%s;]',
				state.x, state.y, .5, state.h,
				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};
................................................................................
	if def.mode or def.container then
		if def.mode then
			l = string.format('background9[%s,%s;%s,%s;%s;false;64]',
					originX, originY, state.w, state.h,
					E(string.format('starlit-ui-bg-%s.png%s^[resize:128x128',
						(def.mode == 'sw') and 'digital'
											or 'panel', cmod))) .. l

		end
		if parent == nil or state.color ~= parent.color then
			l = btnColorDef() .. l
		end
	end
	if not parent then
		return string.format('formspec_version[6]size[%s,%s]%s', state.w, state.h, l), state







>




>
>
>
>


<
>
>
>



>
>
>
>
>
>
>

<
>
|
|


>
|

>







 







>







176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193

194
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
...
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
			maxX = math.max(state.x, maxX)
		end
		totalH = totalH + rowH
		state.h = math.max(state.h, totalH) + state.padding
		state.w = state.x + state.padding/2
		state.x = maxX
	elseif def.kind == 'pane' then
		local top = state.y
		widget('scroll_container[%s,%s;%s,%s;%s;vertical]',
			state.x, state.y, state.w, state.h,
			def.id)
		local y = 0
		local x,w = state.x,state.w
-- 		state.x = state.x + .75
-- 		state.w = state.w - .75
		local widgs = {}
		for _, w in ipairs(def) do
			local src, st = starlit.ui.build(w, state)

			table.insert(widgs, {
				y=y, src=src
			})
			y=y + state.spacing + st.h
			state.w = math.max(state.w, st.w)
		end
		local xo, barred = 0, false
		if y-top > state.h then
			barred, xo = true, .60
		end
		for k,v in ipairs(widgs) do
			widget('container[%s,%s]%scontainer_end[]', xo, v.y, v.src)
		end
		widget('scroll_container_end[]')

		if barred then
			widget('scrollbaroptions[max=%s]scrollbar[%s,%s;%s,%s;vertical;%s;]',
				(y-top-state.h)*10, x, state.y, .5, state.h,
				def.id)
		end
		state.x = x
		state.w = w + state.padding
		state.h = state.h + state.padding/2
		state.y = state.y + state.h
	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};
................................................................................
	if def.mode or def.container then
		if def.mode then
			l = string.format('background9[%s,%s;%s,%s;%s;false;64]',
					originX, originY, state.w, state.h,
					E(string.format('starlit-ui-bg-%s.png%s^[resize:128x128',
						(def.mode == 'sw') and 'digital'
											or 'panel', cmod))) .. l
--  			l = string.format('style_type[scrollbar;bgcolor=#1155ff]') .. l
		end
		if parent == nil or state.color ~= parent.color then
			l = btnColorDef() .. l
		end
	end
	if not parent then
		return string.format('formspec_version[6]size[%s,%s]%s', state.w, state.h, l), state

Modified mods/vtlib/marshal.lua from [2822b4a0ba] to [979397aff5].

195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211


212
213
214
215
216
217
218
	-- }
	local def, name
	if select('#', ...) >= 2 then
		name, def = ...
	else
		def = ...
	end
	name = 'struct' .. (name and ':' .. name or '');
	report('defining struct name=%q fields=%s', name, dump(def))
	return {
		name = name;
		enc = function(obj)
		report('encoding struct name=%q vals=%s', name, dump(obj))
			local enc = m.streamEncoder()
			local n = 0
			for k,ty in pairs(def) do n=n+1
				if obj[k] == nil then error('missing key '..dump(k)..' for type '..ty.name) end


				local encoded = ty.enc(obj[k])
				enc.push(T.u8.enc(#k), size.enc(#encoded), k, encoded)
			end
			return size.enc(n) .. enc.peek()
		end;
		dec = debugger.wrap(function(blob)
			if blob == '' then







|








|
>
>







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
	-- }
	local def, name
	if select('#', ...) >= 2 then
		name, def = ...
	else
		def = ...
	end
	name = 'struct' .. (name and (':' .. name) or '');
	report('defining struct name=%q fields=%s', name, dump(def))
	return {
		name = name;
		enc = function(obj)
		report('encoding struct name=%q vals=%s', name, dump(obj))
			local enc = m.streamEncoder()
			local n = 0
			for k,ty in pairs(def) do n=n+1
				if obj[k] == nil then
					error(string.format("missing %s field %q for %s", ty.name, k, name))
				end
				local encoded = ty.enc(obj[k])
				enc.push(T.u8.enc(#k), size.enc(#encoded), k, encoded)
			end
			return size.enc(n) .. enc.peek()
		end;
		dec = debugger.wrap(function(blob)
			if blob == '' then