summaryrefslogtreecommitdiff
path: root/mesecons_pressureplates/init.lua
blob: 78389a4bf297bcf4b41ce1bfd8b80426d3cc471a (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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
-- PRESSURE PLATE WOOD

minetest.register_node("mesecons_pressureplates:pressure_plate_wood_off", {
	drawtype = "nodebox",
	tiles = {"jeija_pressure_plate_wood_off.png"},
	inventory_image = "jeija_pressure_plate_wood_off.png",
	wield_image = "jeija_pressure_plate_wood_off.png",
	paramtype = "light",
	is_ground_content = true,
	walkable = true,
	selection_box = {
		type = "fixed",
		fixed = { -7/16, -8/16, -7/16, 7/16, -7/16, 7/16 },
	},
	node_box = {
		type = "fixed",
		fixed = { -7/16, -8/16, -7/16, 7/16, -7/16, 7/16 },
	},
	groups = {snappy=2,choppy=2,oddly_breakable_by_hand=3},
    	description="Wood Pressure Plate",
	
	on_timer = function(pos, elapsed)
		local objs = minetest.env:get_objects_inside_radius(pos, 1)
		for k, obj in pairs(objs) do
			local objpos=obj:getpos()
			if objpos.y>pos.y-1 and objpos.y<pos.y then
				minetest.env:add_node(pos, {name="mesecons_pressureplates:pressure_plate_wood_on"})
				mesecon:receptor_on(pos)
			end
		end
		return true
	end,
	mesecons = {receptor = {
		state = mesecon.state.off
	}},
	on_construct = function(pos)
		minetest.env:get_node_timer(pos):start(PRESSURE_PLATE_INTERVAL)
	end,
})

minetest.register_node("mesecons_pressureplates:pressure_plate_wood_on", {
	drawtype = "nodebox",
	tiles = {"jeija_pressure_plate_wood_on.png"},
	paramtype = "light",
	is_ground_content = true,
	walkable = true,
	selection_box = {
		type = "fixed",
		fixed = { -7/16, -8/16, -7/16, 7/16, -7/16, 7/16 },
	},
	node_box = {
		type = "fixed",
		fixed = { -7/16, -8/16, -7/16, 7/16, -31/64, 7/16 },
	},
	groups = {snappy=2,choppy=2,oddly_breakable_by_hand=3,not_in_creative_inventory=1},
	drop='"mesecons_pressureplates:pressure_plate_wood_off" 1',
	
	on_timer = function(pos, elapsed)
		local objs = minetest.env:get_objects_inside_radius(pos, 1)
		if objs[1]==nil then
			minetest.env:add_node(pos, {name="mesecons_pressureplates:pressure_plate_wood_off"})
			mesecon:receptor_off(pos)
		end
		return true
	end,
	mesecons = {receptor = {
		state = mesecon.state.on
	}},
	on_construct = function(pos)
		minetest.env:get_node_timer(pos):start(PRESSURE_PLATE_INTERVAL)
	end,
})

minetest.register_craft({
	output = '"mesecons_pressureplates:pressure_plate_wood_off" 1',
	recipe = {
		{'"default:wood"', '"default:wood"'},
	}
})

-- PRESSURE PLATE STONE

minetest.register_node("mesecons_pressureplates:pressure_plate_stone_off", {
	drawtype = "nodebox",
	tiles = {"jeija_pressure_plate_stone_off.png"},
	inventory_image = "jeija_pressure_plate_stone_off.png",
	wield_image = "jeija_pressure_plate_stone_off.png",
	paramtype = "light",
	is_ground_content = true,
	walkable = true,
	selection_box = {
		type = "fixed",
		fixed = { -7/16, -8/16, -7/16, 7/16, -7/16, 7/16 },
	},
	node_box = {
		type = "fixed",
		fixed = { -7/16, -8/16, -7/16, 7/16, -7/16, 7/16 },
	},
	groups = {snappy=2,choppy=2,oddly_breakable_by_hand=3},
    	description="Stone Pressure Plate",
	
	on_timer = function(pos, elapsed)
		local objs = minetest.env:get_objects_inside_radius(pos, 1)
		for k, obj in pairs(objs) do
			local objpos=obj:getpos()
			if objpos.y>pos.y-1 and objpos.y<pos.y then
				minetest.env:add_node(pos, {name="mesecons_pressureplates:pressure_plate_stone_on"})
				mesecon:receptor_on(pos)
			end
		end
		return true
	end,
	mesecons = {receptor = {
		state = mesecon.state.off
	}},
	on_construct = function(pos)
		minetest.env:get_node_timer(pos):start(PRESSURE_PLATE_INTERVAL)
	end,
})

minetest.register_node("mesecons_pressureplates:pressure_plate_stone_on", {
	drawtype = "nodebox",
	tiles = {"jeija_pressure_plate_stone_on.png"},
	paramtype = "light",
	is_ground_content = true,
	walkable = true,
	selection_box = {
		type = "fixed",
		fixed = { -7/16, -8/16, -7/16, 7/16, -7/16, 7/16 },
	},
	node_box = {
		type = "fixed",
		fixed = { -7/16, -8/16, -7/16, 7/16, -31/64, 7/16 },
	},
	groups = {snappy=2,choppy=2,oddly_breakable_by_hand=3,not_in_creative_inventory=1},
	drop='"mesecons_pressureplates:pressure_plate_stone_off" 1',
	
	on_timer = function(pos, elapsed)
		local objs = minetest.env:get_objects_inside_radius(pos, 1)
		if objs[1]==nil then
			minetest.env:add_node(pos, {name="mesecons_pressureplates:pressure_plate_stone_off"})
			mesecon:receptor_off(pos)
		end
		return true
	end,
	mesecons = {receptor = {
		state = mesecon.state.on
	}},
	on_construct = function(pos)
		minetest.env:get_node_timer(pos):start(PRESSURE_PLATE_INTERVAL)
	end,
})

minetest.register_craft({
	output = '"mesecons_pressureplates:pressure_plate_stone_off" 1',
	recipe = {
		{'"default:cobble"', '"default:cobble"'},
	}
})