-
Notifications
You must be signed in to change notification settings - Fork 1
/
mark.lua
70 lines (66 loc) · 2.2 KB
/
mark.lua
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
schematic_save.marker1 = {}
schematic_save.marker2 = {}
--marks schematic_save region position 1
schematic_save.mark_pos1 = function(name)
local pos = schematic_save.pos1[name]
if schematic_save.marker1[name] ~= nil then --marker already exists
schematic_save.marker1[name]:remove() --remove marker
schematic_save.marker1[name] = nil
end
if pos ~= nil then --add marker
schematic_save.marker1[name] = minetest.env:add_entity(pos, "schematic_save:pos1")
schematic_save.marker1[name]:get_luaentity().active = true
end
end
--marks schematic_save region position 2
schematic_save.mark_pos2 = function(name)
local pos = schematic_save.pos2[name]
if schematic_save.marker2[name] ~= nil then --marker already exists
schematic_save.marker2[name]:remove() --remove marker
schematic_save.marker2[name] = nil
end
if pos ~= nil then --add marker
schematic_save.marker2[name] = minetest.env:add_entity(pos, "schematic_save:pos2")
schematic_save.marker2[name]:get_luaentity().active = true
end
end
minetest.register_entity(":schematic_save: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_step = function(self, dtime)
if self.active == nil then
self.object:remove()
end
end,
on_punch = function(self, hitter)
self.object:remove()
local name = hitter:get_player_name()
schematic_save.marker1[name] = nil
end,
})
minetest.register_entity(":schematic_save: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_step = function(self, dtime)
if self.active == nil then
self.object:remove()
end
end,
on_punch = function(self, hitter)
self.object:remove()
local name = hitter:get_player_name()
schematic_save.marker2[name] = nil
end,
})