summaryrefslogtreecommitdiff
path: root/digistuff/internal.lua
blob: 494a206ac1edba2e139b7aa8db1a47f82933e326 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
digistuff.rotate_rules = function(rulesin,dir)
	local rules = {}
	for k,v in ipairs(rulesin) do rules[k] = v end
	if dir.z > 0 then
		return rules
	elseif dir.z < 0 then
		for _,i in ipairs(rules) do
			i.x = -i.x
			i.z = -i.z
		end
		return rules
	elseif dir.x > 0 then
		for _,i in ipairs(rules) do
			local z = i.x
			i.x = i.z
			i.z = -z
		end
		return rules
	elseif dir.x < 0 then
		for _,i in ipairs(rules) do
			local z = i.x
			i.x = -i.z
			i.z = z
		end
		return rules
	elseif dir.y > 0 then
		for _,i in ipairs(rules) do
			local z = i.y
			i.y = i.z
			i.z = z
		end
		return rules
	elseif dir.y < 0 then
		for _,i in ipairs(rules) do
			local z = i.y
			i.y = -i.z
			i.z = -z
		end
		return rules
	else
		minetest.log("warning",string.format("digistuff.rotate_rules() called with invalid direction %s,%s,%s",dir.x,dir.y,dir.z))
		return {}
	end
end