summaryrefslogtreecommitdiff
path: root/init.lua
blob: fd0aeb7b0d51418583011f8171e0d9ba3a5cca3e (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
local meseconrules = {
	vector.new(1,0,0),
	vector.new(-1,0,0),
	vector.new(0,0,1),
	vector.new(0,0,-1),
	vector.new(1,1,0),
	vector.new(-1,1,0),
	vector.new(0,1,1),
	vector.new(0,1,-1),
}

core.register_node("bm_to_mesecons:converter_off",{
	description = "Basic Machines to Mesecons Converter",
	tiles = {
		"bm_to_mesecons_converter_off.png",
		"bm_to_mesecons_converter_sides.png",
	},
	use_texture_alpha = "opaque",
	is_ground_content = false,
	paramtype = "light",
	drawtype = "nodebox",
	node_box = {
		type = "fixed",
		fixed = {
			{-0.5,-0.5,-0.5,0.5,-0.47,0.5},
			{-0.438,-0.47,-0.438,0.438,-0.42,0.438},
		},
	},
	groups = {
		dig_immediate = 2,
	},
	effector = {
		action_on = function(pos)
			local node = core.get_node(pos)
			node.name = "bm_to_mesecons:converter_on"
			core.swap_node(pos,node)
			mesecon.receptor_on(pos,meseconrules)
			core.get_node_timer(pos):start(0.5)
		end,
	},
	mesecons = {
		receptor = {
			state = mesecon.state.off,
			rules = meseconrules,
		},
	},
	on_construct = function(pos)
		core.get_meta(pos):set_string("infotext","Basic Machines to Mesecons Converter")
	end,
})

core.register_node("bm_to_mesecons:converter_on",{
	description = "Basic Machines to Mesecons Converter (on state - you hacker you!)",
	tiles = {
		"bm_to_mesecons_converter_on.png",
		"bm_to_mesecons_converter_sides.png",
	},
	use_texture_alpha = "opaque",
	is_ground_content = false,
	paramtype = "light",
	drawtype = "nodebox",
	node_box = {
		type = "fixed",
		fixed = {
			{-0.5,-0.5,-0.5,0.5,-0.47,0.5},
			{-0.438,-0.47,-0.438,0.438,-0.42,0.438},
		},
	},
	groups = {
		dig_immediate = 2,
		not_in_creative_inventory = 1,
	},
	drop = "bm_to_mesecons:converter_off",
	mesecons = {
		receptor = {
			state = mesecon.state.on,
			rules = meseconrules,
		},
	},
	on_timer = function(pos)
		local node = core.get_node(pos)
		if node.name ~= "bm_to_mesecons:converter_on" then return end
		node.name = "bm_to_mesecons:converter_off"
		core.swap_node(pos,node)
		mesecon.receptor_off(pos,meseconrules)
	end,
})

core.register_craft({
	output = "bm_to_mesecons:converter_off",
	type = "shapeless",
	recipe = {"basic_machines:mesecon_adapter"},
})