Differences From
Artifact [d777bc86b5]:
25 25 }
26 26 table.insert(items, st)
27 27 else -- gas, liquid
28 28 table.insert(charges, {id = k, mass = v})
29 29 end
30 30 end
31 31 end
32 - print(dump(items))
33 32 return items, charges
34 33 end
35 34
36 35 return function(user, ctx)
37 36 local function cleanup()
38 37 user.action.prog.shred = nil
39 38 if user.action.sfx.shred then
................................................................................
51 50 cleanup()
52 51 return false
53 52 end
54 53 local shredTime = 1.0
55 54 local soundPitch = 1.0 -- TODO
56 55 local pdraw = prop.powerDraw or 0
57 56
57 + if minetest.is_protected(what, user.entity:get_player_name()) then return end
58 58 local node = minetest.get_node(what)
59 59 local nd = minetest.registered_nodes[node.name]
60 60 local elt, fab, vary
61 61 if nd._starlit then
62 62 fab = nd._starlit.recover or nd._starlit.fab
63 63 vary = nd._starlit.recover_vary
64 64 end
................................................................................
98 98 })
99 99 user.action.fx.shred = starlit.fx.nano.shred(user, what, prop, shredTime, node)
100 100 else
101 101 user.action.prog.shred = user.action.prog.shred + ctx.how.delta or 0
102 102 end
103 103 --print('shred progress: ', user.action.prog.shred)
104 104 if user.action.prog.shred >= shredTime then
105 - if minetest.dig_node(what) then
106 - --print('shred complete')
107 - user:suitSound 'starlit-success'
108 - if fab then
109 - local vf = fab
110 - if vary then
111 - local rng = (starlit.world.seedbank+0xa891f62)[minetest.hash_node_position(what)]
112 - vf = vf + vary(rng, {})
113 - end
114 - local items, charges = fabToItemsAndCharges(vf)
115 - for i, it in ipairs(items) do user:give(it) end
116 - -- TODO give gasses, liquids
105 + minetest.remove_node(what)
106 + --print('shred complete')
107 + user:suitSound 'starlit-success'
108 + if fab then
109 + local vf = fab
110 + if vary then
111 + local rng = (starlit.world.seedbank+0xa891f62)[minetest.hash_node_position(what)]
112 + vf = vf + vary(rng, {})
117 113 end
118 - else
119 - user:suitSound 'starlit-error'
114 + local items, charges = fabToItemsAndCharges(vf)
115 + for i, it in ipairs(items) do user:give(it) end
116 + -- TODO give gasses, liquids
120 117 end
121 118 cleanup()
122 119 end
123 120 elseif ctx.how.state == 'halt' then
124 121 cleanup()
125 122 end
126 123 return true