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
..
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
..
90
91
92
93
94
95
96
97
98
99
100
101
102
103
...
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
174
175
176
177
178
179
180
181
...
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
|
local M = W.material
M.element.foreach('starlit:sort', {}, function(id, m)
if m.metal then
M.metal.link(id, {
name = m.name;
composition = starlit.type.fab{element = {[id] = 1}};
color = m.color;
-- n.b. this is a RATIO: it will be appropriately multiplied
-- 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)
................................................................................
indsz, indsz,
indicator);
end
end
M.element.foreach('starlit:gen-forms', {}, function(id, m)
local eltID = F('%s:element_%s', minetest.get_current_modname(), id)
local eltName = F('Elemental %s', lib.str.capitalize(m.name))
local tt = function(t, d, g)
return starlit.ui.tooltip {
title = t, desc = d;
color = lib.color(0.1,0.2,0.1);
props = {
{title = 'Mass', desc = lib.math.si('g', g), affinity='info'}
}
................................................................................
_starlit = {
mass = 1;
material = {
kind = 'element';
element = id;
};
fab = starlit.type.fab {
element = comp;
};
};
});
end
--[[
................................................................................
};
});
]]
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'}
}
}
end
local mcomp = m.composition:elementalize().element
local function comp(n)
local t = {}
for id, amt in pairs(mcomp) do
t[id] = amt * n
end
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;
_starlit = {
mass = 1e3;
material = {
kind = 'metal';
metal = id;
};
fab = starlit.type.fab {
flag = {smelt=true};
element = comp(1e3);
};
};
});
end)
local canisterMeta = lib.marshal.metaStore {
contents = {key = 'starlit:canister_contents', type = starlit.store.volume};
}
................................................................................
short_description = c.name;
description = canisterDesc(nil, c);
inventory_image = c.image or 'starlit-item-element-canister.png';
groups = {canister = 1};
stack_max = 1;
_starlit = {
canister = c;
container = {
handle = function(stack, oldstack)
stack:get_meta():set_string('description', canisterDesc(stack))
return stack
end;
list = {
elem = {
key = 'starlit:canister_elem';
accept = 'powder';
sz = c.slots;
};
};
};
};
})
end)
function starlit.item.canister.contents(st)
local m = canisterMeta(st)
return m.read 'contents'
|
<
|
>
|
>
>
|
>
>
>
>
|
|
|
|
<
>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
>
|
|
<
>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<
>
<
<
<
<
<
<
<
<
<
<
<
<
<
|
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
..
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
..
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
...
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
...
234
235
236
237
238
239
240
241
242
243
244
245
246
247
|
local M = W.material
M.element.foreach('starlit:sort', {}, function(id, m)
if m.metal then
M.metal.link(id, {
name = m.name;
composition = starlit.type.fab{element = {[id] = 1}};
-- n.b. this is a RATIO: it will be appropriately multiplied
-- for the object in question
color = m.color;
elemental = m.name;
})
elseif m.gas then
M.gas.link(id, {
name = m.name;
composition = starlit.type.fab{element = {[id] = 1}};
density = m.density;
elemental = m.name;
})
elseif m.liquid then
M.liquid.link(id, {
name = m.name;
composition = starlit.type.fab{element = {[id] = 1}};
density = m.density;
elemental = m.name;
})
end
end)
local F = string.format
local function mkEltIndicator(composition)
................................................................................
indsz, indsz,
indicator);
end
end
M.element.foreach('starlit:gen-forms', {}, function(id, m)
local eltID = F('%s:element_%s', minetest.get_current_modname(), id)
-- local eltName = F('Elemental %s', lib.str.capitalize(m.name))
local tt = function(t, d, g)
return starlit.ui.tooltip {
title = t, desc = d;
color = lib.color(0.1,0.2,0.1);
props = {
{title = 'Mass', desc = lib.math.si('g', g), affinity='info'}
}
................................................................................
_starlit = {
mass = 1;
material = {
kind = 'element';
element = id;
};
fab = starlit.type.fab {
flag = {smelt = m.metal and true or nil};
element = comp;
};
};
});
end
--[[
................................................................................
};
});
]]
end)
M.metal.foreach('starlit:gen-forms', {}, function(id, m)
if m.elemental then -- avoid multiple forms for same material
m.form = M.element.db[m.elemental].form;
else
local baseID = F('%s:metal_%s_', minetest.get_current_modname(), id)
local brickID = baseID .. 'brick'
local brickName = F('%s Brick', lib.str.capitalize(m.name))
m.form = m.form or {}
m.form.brick = brickID
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'}
}
}
end
local mcomp = m.composition:elementalize().element
local function comp(n)
local t = {}
for id, amt in pairs(mcomp) do
t[id] = amt * n
end
return t
end
local iblit = mkEltIndicator(mcomp)
local function img(s)
return iblit(s:colorize(m.color):render())
end
local mass = 1
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), mass);
inventory_image = img(lib.image('starlit-item-brick.png'));
wield_image = lib.image 'starlit-item-brick.png':colorize(m.color):render();
groups = {metal = 1, brick = 1};
stack_max = 500;
_starlit = {
mass = mass;
material = {
kind = 'metal';
metal = id;
};
fab = starlit.type.fab {
flag = {smelt=true};
element = comp(1e3);
};
};
});
end
end)
local canisterMeta = lib.marshal.metaStore {
contents = {key = 'starlit:canister_contents', type = starlit.store.volume};
}
................................................................................
short_description = c.name;
description = canisterDesc(nil, c);
inventory_image = c.image or 'starlit-item-element-canister.png';
groups = {canister = 1};
stack_max = 1;
_starlit = {
canister = c;
};
})
end)
function starlit.item.canister.contents(st)
local m = canisterMeta(st)
return m.read 'contents'
|