starlit  Diff

Differences From Artifact [1c1e9dd876]:

To Artifact [922972e287]:


32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
..
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
..
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
...
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
		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.action.sfx.shred = nil
			end
			if user.action.fx.shred then
				user.action.fx.shred.abort()
			end
		end

................................................................................
			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
		if fab then
			if fab.flag then
................................................................................
			if p < pdx then
				cleanup()
				return false
			elseif not user.action.prog.shred then
				cleanup() -- kill danglers
				-- begin
				user.action.prog.shred = 0
				user.action.sfx.shred = minetest.sound_play('starlit-nano-shred', {
					object = user.entity;
					max_hear_distance = prop.range*2;
					loop = true;
					pitch = soundPitch;
				})
				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)
				minetest.check_for_falling(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()
................................................................................
		run = function(user, ctx)
		end;
		--[[
		bgProc = function(user, ctx, interval, runState)
			if runState.flags.compiled == true then return false end
			-- only so many nanides to go around
			runState.flags.compiled = true
			local time = minetest.get_gametime()
			local cyclesLeft = ctx.comp.cycles * interval

			for id, e in ipairs(ctx.file.body.conf) do
				if e.key == 'job' then
					local t = J.dec(e.value)
					local remove = false
					local r = starlit.item.sw.db[t.schematic]







|







 







|
|
|







 







|











|
|





|







 







|







32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
..
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
..
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
...
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
		return items, charges
	end

	return function(user, ctx)
		local function cleanup()
			user.action.prog.shred = nil
			if user.action.sfx.shred then
				core.sound_fade(user.action.sfx.shred, 1, 0)
				user.action.sfx.shred = nil
			end
			if user.action.fx.shred then
				user.action.fx.shred.abort()
			end
		end

................................................................................
			cleanup()
			return false
		end
		local shredTime = 1.0
		local soundPitch = 1.0 -- TODO
		local pdraw = prop.powerDraw or 0

		if core.is_protected(what, user.entity:get_player_name()) then return end
		local node = core.get_node(what)
		local nd = core.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
		if fab then
			if fab.flag then
................................................................................
			if p < pdx then
				cleanup()
				return false
			elseif not user.action.prog.shred then
				cleanup() -- kill danglers
				-- begin
				user.action.prog.shred = 0
				user.action.sfx.shred = core.sound_play('starlit-nano-shred', {
					object = user.entity;
					max_hear_distance = prop.range*2;
					loop = true;
					pitch = soundPitch;
				})
				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
				core.remove_node(what)
				core.check_for_falling(what)
				--print('shred complete')
				user:suitSound 'starlit-success'
				if fab then
					local vf = fab
					if vary then
						local rng = (starlit.world.seedbank+0xa891f62)[core.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()
................................................................................
		run = function(user, ctx)
		end;
		--[[
		bgProc = function(user, ctx, interval, runState)
			if runState.flags.compiled == true then return false end
			-- only so many nanides to go around
			runState.flags.compiled = true
			local time = core.get_gametime()
			local cyclesLeft = ctx.comp.cycles * interval

			for id, e in ipairs(ctx.file.body.conf) do
				if e.key == 'job' then
					local t = J.dec(e.value)
					local remove = false
					local r = starlit.item.sw.db[t.schematic]