summaryrefslogtreecommitdiff
path: root/mark.lua
blob: 42a0b19e83ebfceae769ed8a0a30dfcecc3da0fb (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
worldedit.marker1 = {}
worldedit.marker2 = {}

--marks worldedit region position 1
worldedit.mark_pos1 = function(name)
	local pos = worldedit.pos1[name]
	if worldedit.marker1[name] ~= nil then --marker already exists
		worldedit.marker1[name]:remove() --remove marker
		worldedit.marker1[name] = nil
	end
	if pos ~= nil then --add marker
		worldedit.marker1[name] = minetest.env:add_entity(pos, "worldedit:pos1")
	end
end

--marks worldedit region position 2
worldedit.mark_pos2 = function(name)
	local pos = worldedit.pos2[name]
	if worldedit.marker2[name] ~= nil then --marker already exists
		worldedit.marker2[name]:remove() --remove marker
		worldedit.marker2[name] = nil
	end
	if pos ~= nil then --add marker
		worldedit.marker2[name] = minetest.env:add_entity(pos, "worldedit:pos2")
	end
end

minetest.register_entity("worldedit:pos1", {
	initial_properties = {
		visual = "cube",
		visual_size = {x=1.1, y=1.1},
		textures = {"worldedit_pos1.png", "worldedit_pos1.png",
			"worldedit_pos1.png", "worldedit_pos1.png",
			"worldedit_pos1.png", "worldedit_pos1.png"},
		collisionbox = {-0.55, -0.55, -0.55, 0.55, 0.55, 0.55},
	},
	on_punch = function(self, hitter)
		self.object:remove()
		local name = hitter:get_player_name()
		worldedit.marker1[name] = nil
	end,
})

minetest.register_entity("worldedit:pos2", {
	initial_properties = {
		visual = "cube",
		visual_size = {x=1.1, y=1.1},
		textures = {"worldedit_pos2.png", "worldedit_pos2.png",
			"worldedit_pos2.png", "worldedit_pos2.png",
			"worldedit_pos2.png", "worldedit_pos2.png"},
		collisionbox = {-0.55, -0.55, -0.55, 0.55, 0.55, 0.55},
	},
	on_punch = function(self, hitter)
		self.object:remove()
		local name = hitter:get_player_name()
		worldedit.marker2[name] = nil
	end,
})