105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
...
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
195
196
197
198
|
for i = 1*f,M*f do
local top = L.image('sorcery_trough_top_overlay.png')
if liq then top = top:blit(
L.image('sorcery_node_liquid.png'):multiply(L.color(liq.color))
) else top=top:blit(
L.image('sorcery_trough_bottom.png')
) end
local ttlc = function(liq,i) return
liq and string.format('%s Trough', L.str.capitalize(liq.name)),
liq and string.format('%s of %s', liq.measure(i * Q), liq.name)
end
local trough_title, trough_content = ttlc(liq,i)
local function trough_caption(pos,i,l)
local trough_title, trough_content = ttlc(l or liq,i)
minetest.get_meta(pos):set_string('infotext', i > 0 and string.format(
'%s\n(%s)', trough_title, trough_content
) or 'Empty Trough')
................................................................................
type = 'bucket';
hold = 'liquid';
has = liq and liq.id;
charge = liq and Q * i;
empty = 'sorcery:trough';
max = constants.bottles_per_trough * Q;
set_node_vol = liq and function(pos, vol)
vol = math.min(M, math.max(0, math.floor(vol / Q)))
minetest.swap_node(pos, {name = lid(vol)})
trough_caption(pos, vol)
end;
set_node_liq = function(pos, liq, vol)
log.act('adding', vol, 'to trough at', liq)
vol = vol or Q * i
local idx = math.min(M, math.floor(vol/Q))
minetest.swap_node(pos, {name = trough_mkid(liq, idx)})
trough_caption(pos, idx, liq)
end
}
};
})
end
end
sorcery.liquid.mktrough()
sorcery.liquid.measure_default = sorcery.liquid.units.dram
sorcery.liquid.container = function(liq, ctr)
return liq.containers[({
bottle = 'vessels:glass_bottle';
glass = 'vessels:drinking_glass';
|
|
>
>
|
|
>
>
<
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
...
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
|
for i = 1*f,M*f do
local top = L.image('sorcery_trough_top_overlay.png')
if liq then top = top:blit(
L.image('sorcery_node_liquid.png'):multiply(L.color(liq.color))
) else top=top:blit(
L.image('sorcery_trough_bottom.png')
) end
local ttlc = function(liq,i)
if type(liq) == 'string' then liq = sorcery.register.liquid.db[liq] end
return
liq and string.format('%s Trough', L.str.capitalize(liq.name)),
liq and string.format('%s of %s', liq.measure(i * Q), liq.name)
end
local trough_title, trough_content = ttlc(liq,i)
local function trough_caption(pos,i,l)
local trough_title, trough_content = ttlc(l or liq,i)
minetest.get_meta(pos):set_string('infotext', i > 0 and string.format(
'%s\n(%s)', trough_title, trough_content
) or 'Empty Trough')
................................................................................
type = 'bucket';
hold = 'liquid';
has = liq and liq.id;
charge = liq and Q * i;
empty = 'sorcery:trough';
max = constants.bottles_per_trough * Q;
set_node_vol = liq and function(pos, vol)
log.act('putting', vol, liq, 'in trough at', pos)
vol = math.min(M, math.max(0, math.floor(vol / Q)))
minetest.swap_node(pos, {name = lid(vol)})
trough_caption(pos, vol)
return vol * Q
end;
set_node_liq = function(pos, liq, vol)
log.act('putting', vol, liq, 'in trough at', pos)
vol = vol or Q * i
local idx = math.min(M, math.floor(vol/Q))
minetest.swap_node(pos, {name = trough_mkid(liq, idx)})
trough_caption(pos, idx, liq)
return idx * Q
end
}
};
})
end
end
sorcery.liquid.mktrough()
sorcery.liquid.setctr = function(pos, liq, vol, sameliq)
local n = sorcery.lib.node.force(pos)
if minetest.get_item_group(n.name, 'sorcery_container') ~= 2 then return false end
local def = minetest.registered_items[n.name]._sorcery
if not (def and def.container and def.container.set_node_liq) then
log.err('node',n.name,'marked as liquid container but is missing container.set_node_liq callback')
return false
end
if sameliq then
if def.container.has ~= nil and def.container.has ~= liq then
return false
end
end
return def.container.set_node_liq(pos, liq, vol)
end
sorcery.liquid.measure_default = sorcery.liquid.units.dram
sorcery.liquid.container = function(liq, ctr)
return liq.containers[({
bottle = 'vessels:glass_bottle';
glass = 'vessels:drinking_glass';
|