diff options
Diffstat (limited to 'lua/helpers.lua')
| -rwxr-xr-x | lua/helpers.lua | 30 | 
1 files changed, 30 insertions, 0 deletions
diff --git a/lua/helpers.lua b/lua/helpers.lua index 374cd95..b94b0a8 100755 --- a/lua/helpers.lua +++ b/lua/helpers.lua @@ -90,6 +90,36 @@ function drawers.spawn_visuals(pos)  		if bdir.x > 0 then obj:setyaw(1.5 * math.pi) end  		drawers.last_texture = nil +	elseif drawerType == 2 then +		local bdir = core.facedir_to_dir(node.param2) + +		local fdir1 +		local fdir2 +		if node.param2 == 2 or node.param2 == 0 then +			fdir1 = vector.new(-bdir.x, 0.5, -bdir.z) +			fdir2 = vector.new(-bdir.x, -0.5, -bdir.z) +		else +			fdir1 = vector.new(-bdir.x, 0.5, -bdir.z) +			fdir2 = vector.new(-bdir.x, -0.5, -bdir.z) +		end + +		objs = {} + +		drawers.last_visual_id = 1 +		drawers.last_texture = drawers.get_inv_image(core.get_meta(pos):get_string("name1")) +		local pos1 = vector.add(pos, vector.multiply(fdir1, 0.438)) +		objs[1] = core.add_entity(pos1, "drawers:visual") + +		drawers.last_visual_id = 2 +		drawers.last_texture = drawers.get_inv_image(core.get_meta(pos):get_string("name2")) +		local pos2 = vector.add(pos, vector.multiply(fdir2, 0.438)) +		objs[2] = core.add_entity(pos2, "drawers:visual") + +		for i,obj in pairs(objs) do +			if bdir.x < 0 then obj:setyaw(0.5 * math.pi) end +			if bdir.z < 0 then obj:setyaw(math.pi) end +			if bdir.x > 0 then obj:setyaw(1.5 * math.pi) end +		end  	else -- 2x2 drawer  		local bdir = core.facedir_to_dir(node.param2)  | 
