summaryrefslogtreecommitdiff
path: root/mesecons/presets.lua
blob: 8c3ed67bdd31ee9c6804afd11057f6f3fd5dd5dd (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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
mesecon.rules = {}
mesecon.state = {}

mesecon.rules.default =
{{x=0,  y=0,  z=-1},
 {x=1,  y=0,  z=0},
 {x=-1, y=0,  z=0},
 {x=0,  y=0,  z=1},
 {x=1,  y=1,  z=0},
 {x=1,  y=-1, z=0},
 {x=-1, y=1,  z=0},
 {x=-1, y=-1, z=0},
 {x=0,  y=1,  z=1},
 {x=0,  y=-1, z=1},
 {x=0,  y=1,  z=-1},
 {x=0,  y=-1, z=-1}}

mesecon.rules.pplate = mesecon.mergetable(mesecon.rules.default, {{x=0, y=-2, z=0}})

mesecon.rules.buttonlike =
{{x = 1,  y = 0, z = 0},
 {x = 1,  y = 1, z = 0},
 {x = 1,  y =-1, z = 0},
 {x = 1,  y =-1, z = 1},
 {x = 1,  y =-1, z =-1},
 {x = 2,  y = 0, z = 0}}

mesecon.rules.flat =
{{x = 1, y = 0, z = 0},
 {x =-1, y = 0, z = 0},
 {x = 0, y = 0, z = 1},
 {x = 0, y = 0, z =-1}}

mesecon.rules.alldirs =
{{x= 1, y= 0,  z= 0},
 {x=-1, y= 0,  z= 0},
 {x= 0, y= 1,  z= 0},
 {x= 0, y=-1,  z= 0},
 {x= 0, y= 0,  z= 1},
 {x= 0, y= 0,  z=-1}}

mesecon.rules.buttonlike_get = function(node)
	local rules = mesecon.rules.buttonlike
	local dir = minetest.facedir_to_dir(node.param2)
	if dir.x == 1 then
		-- No action needed
	elseif dir.z == -1 then
		rules=mesecon.rotate_rules_left(rules)
	elseif dir.x == -1 then
		rules=mesecon.rotate_rules_right(mesecon.rotate_rules_right(rules))
	elseif dir.z == 1 then
		rules=mesecon.rotate_rules_right(rules)
	elseif dir.y == -1 then
		rules=mesecon.rotate_rules_up(rules)
	elseif dir.y == 1 then
		rules=mesecon.rotate_rules_down(rules)
	end
	return rules
end

mesecon.state.on = "on"
mesecon.state.off = "off"