diff options
| author | FaceDeer <derksenmobile@gmail.com> | 2017-01-04 21:38:49 -0700 | 
|---|---|---|
| committer | FaceDeer <derksenmobile@gmail.com> | 2017-01-04 21:38:49 -0700 | 
| commit | a74d9315250d24b2c7964fb28ab08f7d117fbfea (patch) | |
| tree | eac793b2cec0a251eb7fb321df1e5cb4c7d1a78d | |
| parent | 92f775a38d205566abfe41bfda522cd51d2a178f (diff) | |
Particle effects for digger heads
| -rw-r--r-- | init.lua | 1 | ||||
| -rw-r--r-- | node_controllers.lua | 31 | ||||
| -rw-r--r-- | textures/digtron_dust.png | bin | 0 -> 201 bytes | 
3 files changed, 32 insertions, 0 deletions
@@ -8,6 +8,7 @@ dofile( minetest.get_modpath( "digtron" ) .. "/node_controllers.lua" ) -- contro  dofile( minetest.get_modpath( "digtron" ) .."/recipes.lua" )  digtron.creative_mode = false +digtron.particle_effects = true  digtron.cycle_time = 1 -- How many seconds a digtron waits between cycles. Auto-controllers can make this wait longer, but cannot make it shorter.  digtron.traction_factor = 3.0 -- How many digtron nodes can be moved for each adjacent solid node that the digtron has traction against diff --git a/node_controllers.lua b/node_controllers.lua index 4b66b71..a7f009f 100644 --- a/node_controllers.lua +++ b/node_controllers.lua @@ -1,3 +1,24 @@ +local dig_dust = function(pos, facing) +	local direction = minetest.facedir_to_dir(facing) +	return { +		amount = 10, +		time = 1.0, +		minpos = vector.subtract(pos, vector.new(0.5,0.5,0.5)), +		maxpos = vector.add(pos, vector.new(0.5,0.5,0.5)), +		minvel = vector.multiply(direction, -10), +		maxvel = vector.multiply(direction, -20), +		minacc = {x=0, y=-40, z=0}, +		maxacc = {x=0, y=-40, z=0}, +		minexptime = 0.25, +		maxexptime = 0.5, +		minsize = 2, +		maxsize = 5, +		collisiondetection = false, +		vertical = false, +		texture = "default_item_smoke.png^[colorize:#9F817080", +	} +end +  -- returns newpos, status string  local execute_cycle = function(pos, clicker)  	local meta = minetest.get_meta(pos) @@ -19,6 +40,7 @@ local execute_cycle = function(pos, clicker)  	end  	local facing = minetest.get_node(pos).param2 +	local move_dir = minetest.facedir_to_dir(facing)  	local controlling_coordinate = digtron.get_controlling_coordinate(pos, facing)  	---------------------------------------------------------------------------------------------------------------------- @@ -26,6 +48,7 @@ local execute_cycle = function(pos, clicker)  	local nodes_dug = Pointset.create()  	local items_dropped = {}  	local digging_fuel_cost = 0 +	local particle_systems = {}  	-- execute the execute_dig method on all digtron components that have one  	-- This builds a set of nodes that will be dug and returns a list of products that will be generated @@ -40,6 +63,9 @@ local execute_cycle = function(pos, clicker)  				for _, itemname in pairs(dropped) do  					table.insert(items_dropped, itemname)  				end +				if digtron.particle_effects then +					table.insert(particle_systems, dig_dust(vector.add(location, move_dir), target.param2)) +				end  			end  			digging_fuel_cost = digging_fuel_cost + fuel_cost  		else @@ -165,6 +191,11 @@ local execute_cycle = function(pos, clicker)  	if move_player then  		clicker:moveto(digtron.find_new_pos(player_pos, facing), true)  	end +	 +	-- Eyecandy +	for _, particles in pairs(particle_systems) do +		minetest.add_particlespawner(particles) +	end  	local building_fuel_cost = 0  	local strange_failure = false diff --git a/textures/digtron_dust.png b/textures/digtron_dust.png Binary files differnew file mode 100644 index 0000000..8968a9b --- /dev/null +++ b/textures/digtron_dust.png  | 
