]> git.lizzy.rs Git - worldedit.git/blob - worldedit_commands/mark.lua
Change all references of //dig to //fixlight, document the changes, fix a small typo.
[worldedit.git] / worldedit_commands / mark.lua
1 worldedit.marker1 = {}\r
2 worldedit.marker2 = {}\r
3 \r
4 --marks worldedit region position 1\r
5 worldedit.mark_pos1 = function(name)\r
6         local pos = worldedit.pos1[name]\r
7         if worldedit.marker1[name] ~= nil then --marker already exists\r
8                 worldedit.marker1[name]:remove() --remove marker\r
9                 worldedit.marker1[name] = nil\r
10         end\r
11         if pos ~= nil then --add marker\r
12                 worldedit.marker1[name] = minetest.env:add_entity(pos, "worldedit:pos1")\r
13                 worldedit.marker1[name]:get_luaentity().active = true\r
14         end\r
15 end\r
16 \r
17 --marks worldedit region position 2\r
18 worldedit.mark_pos2 = function(name)\r
19         local pos = worldedit.pos2[name]\r
20         if worldedit.marker2[name] ~= nil then --marker already exists\r
21                 worldedit.marker2[name]:remove() --remove marker\r
22                 worldedit.marker2[name] = nil\r
23         end\r
24         if pos ~= nil then --add marker\r
25                 worldedit.marker2[name] = minetest.env:add_entity(pos, "worldedit:pos2")\r
26                 worldedit.marker2[name]:get_luaentity().active = true\r
27         end\r
28 end\r
29 \r
30 minetest.register_entity(":worldedit:pos1", {\r
31         initial_properties = {\r
32                 visual = "cube",\r
33                 visual_size = {x=1.1, y=1.1},\r
34                 textures = {"worldedit_pos1.png", "worldedit_pos1.png",\r
35                         "worldedit_pos1.png", "worldedit_pos1.png",\r
36                         "worldedit_pos1.png", "worldedit_pos1.png"},\r
37                 collisionbox = {-0.55, -0.55, -0.55, 0.55, 0.55, 0.55},\r
38         },\r
39         on_step = function(self, dtime)\r
40                 if self.active == nil then\r
41                         self.object:remove()\r
42                 end\r
43         end,\r
44         on_punch = function(self, hitter)\r
45                 self.object:remove()\r
46                 local name = hitter:get_player_name()\r
47                 worldedit.marker1[name] = nil\r
48         end,\r
49 })\r
50 \r
51 minetest.register_entity(":worldedit:pos2", {\r
52         initial_properties = {\r
53                 visual = "cube",\r
54                 visual_size = {x=1.1, y=1.1},\r
55                 textures = {"worldedit_pos2.png", "worldedit_pos2.png",\r
56                         "worldedit_pos2.png", "worldedit_pos2.png",\r
57                         "worldedit_pos2.png", "worldedit_pos2.png"},\r
58                 collisionbox = {-0.55, -0.55, -0.55, 0.55, 0.55, 0.55},\r
59         },\r
60         on_step = function(self, dtime)\r
61                 if self.active == nil then\r
62                         self.object:remove()\r
63                 end\r
64         end,\r
65         on_punch = function(self, hitter)\r
66                 self.object:remove()\r
67                 local name = hitter:get_player_name()\r
68                 worldedit.marker2[name] = nil\r
69         end,\r
70 })