starlit  Diff

Differences From Artifact [db8d1e2ad1]:

To Artifact [e6ca28c621]:


12
13
14
15
16
17
18

19
20
21
22
23

24
25
26
27
28
29
30
..
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
...
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
...
161
162
163
164
165
166
167






168
169
170
171
172
173
174

175
176
177
178
179
180
181
182












183
184






185
186
187
188
189
190
191
192
193
194
...
212
213
214
215
216
217
218


			-- for the object in question; e.g a normal chunk will be
			-- 100 $element, an ingot will be 1000 $element
		})
	elseif m.gas then
		M.gas.link(id, {
			name = m.name;
			composition = starlit.type.fab{element = {[id] = 1}};

		})
	elseif m.liquid then
		M.liquid.link(id, {
			name = m.name;
			composition = starlit.type.fab{element = {[id] = 1}};

		})
	end
end)

local F = string.format

local function mkEltIndicator(composition)
................................................................................
			props = {
				{title = 'Mass', desc = lib.math.si('g', g), affinity='info'}
			}
		}
	end
	local comp = {[id] = 1}
	local iblit = mkEltIndicator(comp)




	m.form = m.form or {}

















	m.form.element = eltID









	local powder = F('starlit-element-%s-powder.png', id);
	minetest.register_craftitem(eltID, {
		short_description = eltName;
		description = tt(eltName, F('Elemental %s kept in suspension by a nanide storage system, ready to be worked by a cold matter compiler', m.name), 1);
		inventory_image = iblit(powder);
		wield_image = powder;
		stack_max = 1000; -- 1kg
		groups = {element = 1, powder = 1, specialInventory = 1};
		_starlit = {
			mass = 1;
			material = {
				kind = 'element';
				element = id;
			};
			fab = starlit.type.fab {
				element = comp;
			};
		};
	});

end)


M.metal.foreach('starlit:gen-forms', {}, function(id, m)
	local baseID = F('%s:metal_%s_', minetest.get_current_modname(), id)
	local brickID, ingotID = baseID .. 'brick', baseID .. 'ingot'
	local brickName, ingotName =
		F('%s Brick', lib.str.capitalize(m.name)),
		F('%s Ingot', lib.str.capitalize(m.name))
	m.form = m.form or {}
	m.form.brick = brickID
	m.form.ingot = ingotID
	local tt = function(t, d, g)
		return starlit.ui.tooltip {
			title = t, desc = d;
			color = lib.color(0.1,0.1,0.1);
			props = {
				{title = 'Mass', desc = lib.math.si('g', g), affinity='info'}
................................................................................
		return t
	end
	local iblit = mkEltIndicator(mcomp)
	local function img(s)
		return iblit(s:colorize(m.color):render())
	end

	minetest.register_craftitem(brickID, {
		short_description = brickName;
		description = tt(brickName, F('A solid brick of %s, ready to be worked by a matter compiler', m.name), 100);
		inventory_image = img(lib.image 'starlit-item-brick.png');
		wield_image = lib.image 'starlit-item-brick.png':colorize(m.color):render();
		stack_max = 10;
		groups = {metal = 1, ingot = 1};
		_starlit = {
			mass = 100;
			material = {
				kind = 'metal';
				metal = id;
			};
			fab = starlit.type.fab {
				flag = {smelt= true};
				element = comp(1e2);
			};
		};
	});

	minetest.register_craftitem(ingotID, {
		short_description = ingotName;
		description = tt(ingotName, F('A solid ingot of %s, ready to be worked by a large matter compiler', m.name), 1e3);
		inventory_image = img(lib.image('starlit-item-ingot.png'));
		wield_image = lib.image 'starlit-item-ingot.png':colorize(m.color):render();
		groups = {metal = 1, ingot = 1};
		stack_max = 5;
................................................................................
				element = comp(1e3);
			};
		};
	});


end)







local function canisterDesc(stack, def)
	def = def or stack:get_definition()._starlit.canister
	local props = {
		{title = 'Charge Slots', affinity = 'info', desc = tostring(def.slots)};
	};
	if stack then

		local inv = starlit.item.container(stack)
		for i,e in ipairs(inv:list 'elem') do
			local comp = e:get_definition()._starlit.fab
			table.insert(props, {
				title = comp:formula();
				desc = lib.math.si('g', e:get_count());
				affinity = 'good';
			})












		end
		-- TODO list masses






	end
	return starlit.ui.tooltip {
		title = def.name, desc = def.desc or 'A canister that can store a charge of elemental powder, gas, or liquid';
		color = lib.color(0.2,0.1,0.1);
		props = props;
	};	
end

starlit.item.canister = lib.registry.mk 'starlit:canister';
starlit.item.canister.foreach('starlit:item-gen', {}, function(id, c)
................................................................................
						sz = c.slots;
					};
				};
			};
		};
	})
end)









>





>







 







>
>
>
>

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

>
|


|
|


|











>





|
<
<
|

<







 







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







 







>
>
>
>
>
>




|


>








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

<
>
>
>
>
>
>


|







 







>
>
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
..
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
128
129


130
131

132
133
134
135
136
137
138
...
148
149
150
151
152
153
154




















155
156
157
158
159
160
161
...
170
171
172
173
174
175
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
224
225
226
227
...
245
246
247
248
249
250
251
252
253
			-- for the object in question; e.g a normal chunk will be
			-- 100 $element, an ingot will be 1000 $element
		})
	elseif m.gas then
		M.gas.link(id, {
			name = m.name;
			composition = starlit.type.fab{element = {[id] = 1}};
			density = m.density;
		})
	elseif m.liquid then
		M.liquid.link(id, {
			name = m.name;
			composition = starlit.type.fab{element = {[id] = 1}};
			density = m.density;
		})
	end
end)

local F = string.format

local function mkEltIndicator(composition)
................................................................................
			props = {
				{title = 'Mass', desc = lib.math.si('g', g), affinity='info'}
			}
		}
	end
	local comp = {[id] = 1}
	local iblit = mkEltIndicator(comp)
	local function img(s)
		return iblit(s:colorize(m.color):render())
	end

	m.form = m.form or {}


	if not (m.gas or m.liquid) then
		local brickID = eltID .. '_brick'
		local brickName = F('%s Brick', lib.str.capitalize(m.name))
		m.form.brick = brickID
		minetest.register_craftitem(brickID, {
			short_description = brickName;
			description = tt(brickName, F('A small brick of %s, ready to be worked by a matter compiler', m.name), 1);
			inventory_image = img(lib.image 'starlit-item-brick.png');
			wield_image = lib.image 'starlit-item-brick.png':colorize(m.color):render();
			stack_max = 500;
			groups = {element=1, brick=1};
			_starlit = {
				mass = 1;
				material = {
					kind = 'element';
					element = id;
				};
				fab = starlit.type.fab {
					element = comp;
				};
			};
		});
	end

	--[[
	local chunk = F('starlit-element-%s-powder.png', id);
	minetest.register_craftitem(eltID, {
		short_description = eltName;
		description = tt(eltName, F('A 1g chunk of elemental %s, ready to be worked by a cold matter compiler', m.name), 1);
		inventory_image = iblit(chunk);
		wield_image = powder;
		stack_max = 1000; -- 1kg
		groups = {element = 1, chunk = 1};
		_starlit = {
			mass = 1;
			material = {
				kind = 'element';
				element = id;
			};
			fab = starlit.type.fab {
				element = comp;
			};
		};
	});
	]]
end)


M.metal.foreach('starlit:gen-forms', {}, function(id, m)
	local baseID = F('%s:metal_%s_', minetest.get_current_modname(), id)
	local ingotID = baseID .. 'ingot'


	local ingotName = F('%s Ingot', lib.str.capitalize(m.name))
	m.form = m.form or {}

	m.form.ingot = ingotID
	local tt = function(t, d, g)
		return starlit.ui.tooltip {
			title = t, desc = d;
			color = lib.color(0.1,0.1,0.1);
			props = {
				{title = 'Mass', desc = lib.math.si('g', g), affinity='info'}
................................................................................
		return t
	end
	local iblit = mkEltIndicator(mcomp)
	local function img(s)
		return iblit(s:colorize(m.color):render())
	end





















	minetest.register_craftitem(ingotID, {
		short_description = ingotName;
		description = tt(ingotName, F('A solid ingot of %s, ready to be worked by a large matter compiler', m.name), 1e3);
		inventory_image = img(lib.image('starlit-item-ingot.png'));
		wield_image = lib.image 'starlit-item-ingot.png':colorize(m.color):render();
		groups = {metal = 1, ingot = 1};
		stack_max = 5;
................................................................................
				element = comp(1e3);
			};
		};
	});


end)

local function canisterMeta(stack)
	return lib.marshal.metaStore {
		contents = {key = 'starlit:canister_contents', type = starlit.store.volume};
	} (stack)
end

local function canisterDesc(stack, def)
	def = def or stack:get_definition()._starlit.canister
	local props = {
		{title = 'Volume', affinity = 'info', desc = lib.math.si('L', def.vol,nil,nil,2)};
	};
	if stack then
	--[[
		local inv = starlit.item.container(stack)
		for i,e in ipairs(inv:list 'elem') do
			local comp = e:get_definition()._starlit.fab
			table.insert(props, {
				title = comp:formula();
				desc = lib.math.si('g', e:get_count());
				affinity = 'good';
			})
		end ]]
		local itemMeta = canisterMeta(stack)
		local e = itemMeta.read 'contents'
		local mass = lib.math.si('g', e.mass, nil, nil, 2)
		local def, meas
		if e.kind == 'liquid' then
			def = M.liquid.db[e.id]
			local vol =  lib.math.si('L', e.mass * def.composition.density, nil, nil, 2)
			meas = string.format("%s %s (%s %s)", vol, def.name, e.mass, def.composition:formula())
		elseif e.kind == 'gas' then
			def = M.gas.db[e.id]
			meas = string.format("%s %s (%s)", mass, def.name, def.composition:formula())
		end

		local comp = def.composition
		table.insert(props, {
			title = meas;
			desc = def.desc;
			affinity = 'info';
		})
	end
	return starlit.ui.tooltip {
		title = def.name, desc = def.desc or 'A canister that can store a charge of gas or liquid';
		color = lib.color(0.2,0.1,0.1);
		props = props;
	};	
end

starlit.item.canister = lib.registry.mk 'starlit:canister';
starlit.item.canister.foreach('starlit:item-gen', {}, function(id, c)
................................................................................
						sz = c.slots;
					};
				};
			};
		};
	})
end)

starlit.item.canister.meta = canisterMeta