25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
..
51
52
53
54
55
56
57
58
59
60
61
62
63
64
..
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
|
}
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
................................................................................
cleanup()
return false
end
local shredTime = 1.0
local soundPitch = 1.0 -- TODO
local pdraw = prop.powerDraw or 0
local node = minetest.get_node(what)
local nd = minetest.registered_nodes[node.name]
local elt, fab, vary
if nd._starlit then
fab = nd._starlit.recover or nd._starlit.fab
vary = nd._starlit.recover_vary
end
................................................................................
})
user.action.fx.shred = starlit.fx.nano.shred(user, what, prop, shredTime, node)
else
user.action.prog.shred = user.action.prog.shred + ctx.how.delta or 0
end
--print('shred progress: ', user.action.prog.shred)
if user.action.prog.shred >= shredTime then
if minetest.dig_node(what) then
--print('shred complete')
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
cleanup()
end
return true
|
<
>
|
|
|
|
|
|
|
|
|
|
|
|
<
<
<
|
25
26
27
28
29
30
31
32
33
34
35
36
37
38
..
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
..
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
|
}
table.insert(items, st)
else -- gas, liquid
table.insert(charges, {id = k, mass = v})
end
end
end
return items, charges
end
return function(user, ctx)
local function cleanup()
user.action.prog.shred = nil
if user.action.sfx.shred then
................................................................................
cleanup()
return false
end
local shredTime = 1.0
local soundPitch = 1.0 -- TODO
local pdraw = prop.powerDraw or 0
if minetest.is_protected(what, user.entity:get_player_name()) then return end
local node = minetest.get_node(what)
local nd = minetest.registered_nodes[node.name]
local elt, fab, vary
if nd._starlit then
fab = nd._starlit.recover or nd._starlit.fab
vary = nd._starlit.recover_vary
end
................................................................................
})
user.action.fx.shred = starlit.fx.nano.shred(user, what, prop, shredTime, node)
else
user.action.prog.shred = user.action.prog.shred + ctx.how.delta or 0
end
--print('shred progress: ', user.action.prog.shred)
if user.action.prog.shred >= shredTime then
minetest.remove_node(what)
--print('shred complete')
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
cleanup()
end
elseif ctx.how.state == 'halt' then
cleanup()
end
return true
|