Differences From
Artifact [25b10aa9d6]:
3 3 local M = W.material
4 4
5 5 M.element.foreach('starlit:sort', {}, function(id, m)
6 6 if m.metal then
7 7 M.metal.link(id, {
8 8 name = m.name;
9 9 composition = starlit.type.fab{element = {[id] = 1}};
10 - color = m.color;
11 10 -- n.b. this is a RATIO: it will be appropriately multiplied
12 - -- for the object in question; e.g a normal chunk will be
13 - -- 100 $element, an ingot will be 1000 $element
11 + -- for the object in question
12 + color = m.color;
13 + elemental = m.name;
14 14 })
15 15 elseif m.gas then
16 16 M.gas.link(id, {
17 17 name = m.name;
18 18 composition = starlit.type.fab{element = {[id] = 1}};
19 19 density = m.density;
20 + elemental = m.name;
20 21 })
21 22 elseif m.liquid then
22 23 M.liquid.link(id, {
23 24 name = m.name;
24 25 composition = starlit.type.fab{element = {[id] = 1}};
25 26 density = m.density;
27 + elemental = m.name;
26 28 })
27 29 end
28 30 end)
29 31
30 32 local F = string.format
31 33
32 34 local function mkEltIndicator(composition)
................................................................................
53 55 indsz, indsz,
54 56 indicator);
55 57 end
56 58 end
57 59
58 60 M.element.foreach('starlit:gen-forms', {}, function(id, m)
59 61 local eltID = F('%s:element_%s', minetest.get_current_modname(), id)
60 - local eltName = F('Elemental %s', lib.str.capitalize(m.name))
62 +-- local eltName = F('Elemental %s', lib.str.capitalize(m.name))
61 63 local tt = function(t, d, g)
62 64 return starlit.ui.tooltip {
63 65 title = t, desc = d;
64 66 color = lib.color(0.1,0.2,0.1);
65 67 props = {
66 68 {title = 'Mass', desc = lib.math.si('g', g), affinity='info'}
67 69 }
................................................................................
90 92 _starlit = {
91 93 mass = 1;
92 94 material = {
93 95 kind = 'element';
94 96 element = id;
95 97 };
96 98 fab = starlit.type.fab {
99 + flag = {smelt = m.metal and true or nil};
97 100 element = comp;
98 101 };
99 102 };
100 103 });
101 104 end
102 105
103 106 --[[
................................................................................
121 124 };
122 125 });
123 126 ]]
124 127 end)
125 128
126 129
127 130 M.metal.foreach('starlit:gen-forms', {}, function(id, m)
128 - local baseID = F('%s:metal_%s_', minetest.get_current_modname(), id)
129 - local ingotID = baseID .. 'ingot'
130 - local ingotName = F('%s Ingot', lib.str.capitalize(m.name))
131 - m.form = m.form or {}
132 - m.form.ingot = ingotID
133 - local tt = function(t, d, g)
134 - return starlit.ui.tooltip {
135 - title = t, desc = d;
136 - color = lib.color(0.1,0.1,0.1);
137 - props = {
138 - {title = 'Mass', desc = lib.math.si('g', g), affinity='info'}
131 + if m.elemental then -- avoid multiple forms for same material
132 + m.form = M.element.db[m.elemental].form;
133 + else
134 + local baseID = F('%s:metal_%s_', minetest.get_current_modname(), id)
135 + local brickID = baseID .. 'brick'
136 + local brickName = F('%s Brick', lib.str.capitalize(m.name))
137 + m.form = m.form or {}
138 + m.form.brick = brickID
139 + local tt = function(t, d, g)
140 + return starlit.ui.tooltip {
141 + title = t, desc = d;
142 + color = lib.color(0.1,0.1,0.1);
143 + props = {
144 + {title = 'Mass', desc = lib.math.si('g', g), affinity='info'}
145 + }
139 146 }
140 - }
141 - end
142 - local mcomp = m.composition:elementalize().element
143 - local function comp(n)
144 - local t = {}
145 - for id, amt in pairs(mcomp) do
146 - t[id] = amt * n
147 + end
148 + local mcomp = m.composition:elementalize().element
149 + local function comp(n)
150 + local t = {}
151 + for id, amt in pairs(mcomp) do
152 + t[id] = amt * n
153 + end
154 + return t
147 155 end
148 - return t
149 - end
150 - local iblit = mkEltIndicator(mcomp)
151 - local function img(s)
152 - return iblit(s:colorize(m.color):render())
153 - end
156 + local iblit = mkEltIndicator(mcomp)
157 + local function img(s)
158 + return iblit(s:colorize(m.color):render())
159 + end
154 160
155 - minetest.register_craftitem(ingotID, {
156 - short_description = ingotName;
157 - description = tt(ingotName, F('A solid ingot of %s, ready to be worked by a large matter compiler', m.name), 1e3);
158 - inventory_image = img(lib.image('starlit-item-ingot.png'));
159 - wield_image = lib.image 'starlit-item-ingot.png':colorize(m.color):render();
160 - groups = {metal = 1, ingot = 1};
161 - stack_max = 5;
162 - _starlit = {
163 - mass = 1e3;
164 - material = {
165 - kind = 'metal';
166 - metal = id;
161 + local mass = 1
162 + minetest.register_craftitem(brickID, {
163 + short_description = brickName;
164 + description = tt(brickName, F('A small brick of %s, ready to be worked by a matter compiler', m.name), mass);
165 + inventory_image = img(lib.image('starlit-item-brick.png'));
166 + wield_image = lib.image 'starlit-item-brick.png':colorize(m.color):render();
167 + groups = {metal = 1, brick = 1};
168 + stack_max = 500;
169 + _starlit = {
170 + mass = mass;
171 + material = {
172 + kind = 'metal';
173 + metal = id;
174 + };
175 + fab = starlit.type.fab {
176 + flag = {smelt=true};
177 + element = comp(1e3);
178 + };
167 179 };
168 - fab = starlit.type.fab {
169 - flag = {smelt=true};
170 - element = comp(1e3);
171 - };
172 - };
173 - });
174 -
180 + });
181 + end
175 182
176 183 end)
177 184
178 185 local canisterMeta = lib.marshal.metaStore {
179 186 contents = {key = 'starlit:canister_contents', type = starlit.store.volume};
180 187 }
181 188
................................................................................
227 234 short_description = c.name;
228 235 description = canisterDesc(nil, c);
229 236 inventory_image = c.image or 'starlit-item-element-canister.png';
230 237 groups = {canister = 1};
231 238 stack_max = 1;
232 239 _starlit = {
233 240 canister = c;
234 - container = {
235 - handle = function(stack, oldstack)
236 - stack:get_meta():set_string('description', canisterDesc(stack))
237 - return stack
238 - end;
239 - list = {
240 - elem = {
241 - key = 'starlit:canister_elem';
242 - accept = 'powder';
243 - sz = c.slots;
244 - };
245 - };
246 - };
247 241 };
248 242 })
249 243 end)
250 244
251 245 function starlit.item.canister.contents(st)
252 246 local m = canisterMeta(st)
253 247 return m.read 'contents'