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
...
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
-- 🄯 EUPL v1.2
-- ?
-------------------------------
-- basic suit nano abilities --
-------------------------------
local function shredder(prop)
local function getItemsForFab(fab)
local elt
if fab then
elt = fab:elementalize()
else
elt = {}
end
local items = {}
if elt.element then
for k,v in pairs(elt.element) do
local st = ItemStack {
name = starlit.world.material.element.db[k].form.element;
count = v;
}
table.insert(items, st)
end
end
return items
end
return function(user, ctx)
local function cleanup()
user.action.prog.shred = nil
if user.action.sfx.shred then
minetest.sound_fade(user.action.sfx.shred, 1, 0)
................................................................................
user:suitSound 'starlit-success'
if fab then
local vf = fab
if vary then
local rng = (starlit.world.seedbank+0xa891f62)[minetest.hash_node_position(what)]
vf = vf + vary(rng, {})
end
local items = getItemsForFab(vf)
for i, it in ipairs(items) do user:give(it) end
end
else
user:suitSound 'starlit-error'
end
cleanup()
end
elseif ctx.how.state == 'halt' then
|
|
|
>
>
|
<
>
|
|
|
>
>
|
|
>
>
|
|
>
|
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
...
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
-- 🄯 EUPL v1.2
-- ?
-------------------------------
-- basic suit nano abilities --
-------------------------------
local function shredder(prop)
local function fabToItemsAndCharges(fab)
local elt
if fab then
elt = fab:elementalize()
else
elt = {}
end
local items,charges = {},{}
if elt.element then
for k,v in pairs(elt.element) do
local forms = starlit.world.material.element.db[k].form
if forms.brick then
local st = ItemStack {
name = forms.brick;
count = math.floor(v);
}
table.insert(items, st)
else -- gas, liquid
table.insert(charges, {id = k, mass = v})
end
end
end
print(dump(items))
return items, charges
end
return function(user, ctx)
local function cleanup()
user.action.prog.shred = nil
if user.action.sfx.shred then
minetest.sound_fade(user.action.sfx.shred, 1, 0)
................................................................................
user:suitSound 'starlit-success'
if fab then
local vf = fab
if vary then
local rng = (starlit.world.seedbank+0xa891f62)[minetest.hash_node_position(what)]
vf = vf + vary(rng, {})
end
local items, charges = fabToItemsAndCharges(vf)
for i, it in ipairs(items) do user:give(it) end
-- TODO give gasses, liquids
end
else
user:suitSound 'starlit-error'
end
cleanup()
end
elseif ctx.how.state == 'halt' then
|