]> git.lizzy.rs Git - worldedit.git/blob - WorldEdit API.md
Version information is now available via the API.
[worldedit.git] / WorldEdit API.md
1 WorldEdit API\r
2 =============\r
3 The WorldEdit API is composed of multiple modules, each of which is independent and can be used without the other. Each module is contained within a single file.\r
4 \r
5 If needed, individual modules such as visualization.lua can be removed without affecting the rest of the program. The only file that cannot be removed is init.lua, which is necessary for the mod to run.\r
6 \r
7 For more information, see the [README](README.md).\r
8 \r
9 General\r
10 -------\r
11 \r
12 ### value = worldedit.version\r
13 \r
14 Contains the current version of WorldEdit in a table of the form `{major=MAJOR_INTEGER, minor=MINOR_INTEGER}`, where `MAJOR_INTEGER` is the major version (the number before the period) as an integer, and `MINOR_INTEGER` is the minor version (the number after the period) as an integer. This is intended for version checking purposes.\r
15 \r
16 ### value = worldedit.version_string\r
17 \r
18 Contains the current version of WorldEdit in the form of a string `"MAJOR_INTEGER.MINOR_INTEGER"`, where `MAJOR_INTEGER` is the major version (the number before the period) as an integer, and `MINOR_INTEGER` is the minor version (the number after the period) as an integer. This is intended for display purposes.\r
19 \r
20 Manipulations\r
21 -------------\r
22 Contained in manipulations.lua, this module allows several node operations to be applied over a region.\r
23 \r
24 ### count = worldedit.set(pos1, pos2, nodename)\r
25 \r
26 Sets a region defined by positions `pos1` and `pos2` to `nodename`. To clear a region, use "air" as the value of `nodename`.\r
27 \r
28 Returns the number of nodes set.\r
29 \r
30 ### count = worldedit.replace(pos1, pos2, searchnode, replacenode)\r
31 \r
32 Replaces all instances of `searchnode` with `replacenode` in a region defined by positions `pos1` and `pos2`.\r
33 \r
34 Returns the number of nodes replaced.\r
35 \r
36 ### count = worldedit.replaceinverse(pos1, pos2, searchnode, replacenode)\r
37 \r
38 Replaces all nodes other than `searchnode` with `replacenode` in a region defined by positions `pos1` and `pos2`.\r
39 \r
40 Returns the number of nodes replaced.\r
41 \r
42 ### count = worldedit.copy(pos1, pos2, axis, amount)\r
43 \r
44 Copies the region defined by positions `pos1` and `pos2` along the `axis` axis ("x" or "y" or "z") by `amount` nodes.\r
45 \r
46 Returns the number of nodes copied.\r
47 \r
48 ### count = worldedit.move(pos1, pos2, axis, amount)\r
49 \r
50 Moves the region defined by positions `pos1` and `pos2` along the `axis` axis ("x" or "y" or "z") by `amount` nodes.\r
51 \r
52 Returns the number of nodes moved.\r
53 \r
54 ### count = worldedit.stack(pos1, pos2, axis, count)\r
55 \r
56 Duplicates the region defined by positions `pos1` and `pos2` along the `axis` axis ("x" or "y" or "z") `count` times.\r
57 \r
58 Returns the number of nodes stacked.\r
59 \r
60 ### count, newpos1, newpos2 = worldedit.scale(pos1, pos2, factor)\r
61 \r
62 Scales the region defined by positions `pos1` and `pos2` by an factor of positive integer `factor` with `pos1` as the origin.\r
63 \r
64 Returns the number of nodes scaled, the new scaled position 1, and the new scaled position 2.\r
65 \r
66 ### count, newpos1, newpos2 = worldedit.transpose(pos1, pos2, axis1, axis2)\r
67 \r
68 Transposes a region defined by the positions `pos1` and `pos2` between the `axis1` and `axis2` axes ("x" or "y" or "z").\r
69 \r
70 Returns the number of nodes transposed, the new transposed position 1, and the new transposed position 2.\r
71 \r
72 ### count = worldedit.flip(pos1, pos2, axis)\r
73 \r
74 Flips a region defined by the positions `pos1` and `pos2` along the `axis` axis ("x" or "y" or "z").\r
75 \r
76 Returns the number of nodes flipped.\r
77 \r
78 ### count, newpos2, newpos2 = worldedit.rotate(pos1, pos2, angle)\r
79 \r
80 Rotates a region defined by the positions `pos1` and `pos2` by `angle` degrees clockwise around the y axis (supporting 90 degree increments only).\r
81 \r
82 Returns the number of nodes rotated, the new position 1, and the new position 2.\r
83 \r
84 ### count = worldedit.orient(pos1, pos2, angle)\r
85 \r
86 Rotates all oriented nodes in a region defined by the positions `pos1` and `pos2` by `angle` degrees clockwise (90 degree increment) around the Y axis.\r
87 \r
88 Returns the number of nodes oriented.\r
89 \r
90 ### count = worldedit.fixlight(pos1, pos2)\r
91 \r
92 Fixes the lighting in a region defined by positions `pos1` and `pos2`.\r
93 \r
94 Returns the number of nodes updated.\r
95 \r
96 ### count = worldedit.clearobjects(pos1, pos2)\r
97 \r
98 Clears all objects in a region defined by the positions `pos1` and `pos2`.\r
99 \r
100 Returns the number of objects cleared.\r
101 \r
102 Primitives\r
103 ----------\r
104 Contained in primitives.lua, this module allows the creation of several geometric primitives.\r
105 \r
106 ### count = worldedit.hollow_sphere(pos, radius, nodename)\r
107 \r
108 Adds a hollow sphere centered at `pos` with radius `radius`, composed of `nodename`.\r
109 \r
110 Returns the number of nodes added.\r
111 \r
112 ### count = worldedit.sphere(pos, radius, nodename)\r
113 \r
114 Adds a sphere centered at `pos` with radius `radius`, composed of `nodename`.\r
115 \r
116 Returns the number of nodes added.\r
117 \r
118 ### count = worldedit.hollow_dome(pos, radius, nodename)\r
119 \r
120 Adds a hollow dome centered at `pos` with radius `radius`, composed of `nodename`.\r
121 \r
122 Returns the number of nodes added.\r
123 \r
124 ### count = worldedit.dome(pos, radius, nodename)\r
125 \r
126 Adds a dome centered at `pos` with radius `radius`, composed of `nodename`.\r
127 \r
128 Returns the number of nodes added.\r
129 \r
130 ### count = worldedit.hollow_cylinder(pos, axis, length, radius, nodename)\r
131 \r
132 Adds a hollow cylinder at `pos` along the `axis` axis ("x" or "y" or "z") with length `length` and radius `radius`, composed of `nodename`.\r
133 \r
134 Returns the number of nodes added.\r
135 \r
136 ### count = worldedit.cylinder(pos, axis, length, radius, nodename)\r
137 \r
138 Adds a cylinder at `pos` along the `axis` axis ("x" or "y" or "z") with length `length` and radius `radius`, composed of `nodename`.\r
139 \r
140 Returns the number of nodes added.\r
141 \r
142 ### count = worldedit.pyramid(pos, axis, height, nodename)\r
143 \r
144 Adds a pyramid centered at `pos` along the `axis` axis ("x" or "y" or "z") with height `height`.\r
145 \r
146 Returns the number of nodes added.\r
147 \r
148 ### count = worldedit.spiral(pos, length, height, spacer, nodename)\r
149 \r
150 Adds a spiral centered at `pos` with side length `length`, height `height`, space between walls `spacer`, composed of `nodename`.\r
151 \r
152 Returns the number of nodes added.\r
153 \r
154 Visualization\r
155 -------------\r
156 Contained in visualization.lua, this module allows nodes to be visualized in different ways.\r
157 \r
158 ### volume = worldedit.volume(pos1, pos2)\r
159 \r
160 Determines the volume of the region defined by positions `pos1` and `pos2`.\r
161 \r
162 Returns the volume.\r
163 \r
164 ### count = worldedit.hide(pos1, pos2)\r
165 \r
166 Hides all nodes in a region defined by positions `pos1` and `pos2` by non-destructively replacing them with invisible nodes.\r
167 \r
168 Returns the number of nodes hidden.\r
169 \r
170 ### count = worldedit.suppress(pos1, pos2, nodename)\r
171 \r
172 Suppresses all instances of `nodename` in a region defined by positions `pos1` and `pos2` by non-destructively replacing them with invisible nodes.\r
173 \r
174 Returns the number of nodes suppressed.\r
175 \r
176 ### count = worldedit.highlight(pos1, pos2, nodename)\r
177 \r
178 Highlights all instances of `nodename` in a region defined by positions `pos1` and `pos2` by non-destructively hiding all other nodes.\r
179 \r
180 Returns the number of nodes found.\r
181 \r
182 ### count = worldedit.restore(pos1, pos2)\r
183 \r
184 Restores all nodes hidden with WorldEdit functions in a region defined by positions `pos1` and `pos2`.\r
185 \r
186 Returns the number of nodes restored.\r
187 \r
188 Serialization\r
189 -------------\r
190 Contained in serialization.lua, this module allows regions of nodes to be serialized and deserialized to formats suitable for use outside MineTest.\r
191 \r
192 ### version = worldedit.valueversion(value)\r
193 \r
194 Determines the version of serialized data `value`.\r
195 \r
196 Returns the version as a positive integer or 0 for unknown versions.\r
197 \r
198 ### data, count = worldedit.serialize(pos1, pos2)\r
199 \r
200 Converts the region defined by positions `pos1` and `pos2` into a single string.\r
201 \r
202 Returns the serialized data and the number of nodes serialized.\r
203 \r
204 ### pos1, pos2, count = worldedit.allocate(originpos, value)\r
205 \r
206 Determines the volume the nodes represented by string `value` would occupy if deserialized at `originpos`.\r
207 \r
208 Returns the two corner positions and the number of nodes.\r
209 \r
210 ### count = worldedit.deserialize(originpos, value)\r
211 \r
212 Loads the nodes represented by string `value` at position `originpos`.\r
213 \r
214 Returns the number of nodes deserialized.\r
215 \r
216 Code\r
217 ----\r
218 Contained in code.lua, this module allows arbitrary Lua code to be used with WorldEdit.\r
219 \r
220 ### error = worldedit.lua(code)\r
221 \r
222 Executes `code` as a Lua chunk in the global namespace.\r
223 \r
224 Returns an error if the code fails or nil otherwise.\r
225 \r
226 ### error = worldedit.luatransform(pos1, pos2, code)\r
227 \r
228 Executes `code` as a Lua chunk in the global namespace with the variable `pos` available, for each node in a region defined by positions `pos1` and `pos2`.\r
229 \r
230 Returns an error if the code fails or nil otherwise.