]> git.lizzy.rs Git - worldedit.git/blob - WorldEdit API.md
Dual-based cylinder
[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, node_name)\r
25 \r
26 Sets a region defined by positions `pos1` and `pos2` to `node_name`. To clear a region, use "air" as the value of `node_name`.\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.copy2(pos1, pos2, off)\r
49 \r
50 Copies the region defined by positions `pos1` and `pos2` by the offset vector `off`.\r
51 \r
52 Returns the number of nodes copied.\r
53 \r
54 ### count = worldedit.move(pos1, pos2, axis, amount)\r
55 \r
56 Moves the region defined by positions `pos1` and `pos2` along the `axis` axis ("x" or "y" or "z") by `amount` nodes.\r
57 \r
58 Returns the number of nodes moved.\r
59 \r
60 ### count = worldedit.stack(pos1, pos2, axis, count)\r
61 \r
62 Duplicates the region defined by positions `pos1` and `pos2` along the `axis` axis ("x" or "y" or "z") `count` times.\r
63 \r
64 Returns the number of nodes stacked.\r
65 \r
66 ### count = worldedit.stack2(pos1, pos2, direction, amount)\r
67 \r
68 Duplicates the region defined by positions `pos1` and `pos2` `amount` times with offset vector `direction`.\r
69 \r
70 Returns the number of nodes stacked.\r
71 \r
72 ### count, newpos1, newpos2 = worldedit.stretch(pos1, pos2, stretchx, stretchy, stretchz)\r
73 \r
74 Stretches the region defined by positions `pos1` and `pos2` by an factor of positive integers `stretchx`, `stretchy`. and `stretchz` along the X, Y, and Z axes, respectively, with `pos1` as the origin.\r
75 \r
76 Returns the number of nodes stretched, the new scaled position 1, and the new scaled position 2.\r
77 \r
78 ### count, newpos1, newpos2 = worldedit.transpose(pos1, pos2, axis1, axis2)\r
79 \r
80 Transposes a region defined by the positions `pos1` and `pos2` between the `axis1` and `axis2` axes ("x" or "y" or "z").\r
81 \r
82 Returns the number of nodes transposed, the new transposed position 1, and the new transposed position 2.\r
83 \r
84 ### count = worldedit.flip(pos1, pos2, axis)\r
85 \r
86 Flips a region defined by the positions `pos1` and `pos2` along the `axis` axis ("x" or "y" or "z").\r
87 \r
88 Returns the number of nodes flipped.\r
89 \r
90 ### count, newpos2, newpos2 = worldedit.rotate(pos1, pos2, angle)\r
91 \r
92 Rotates a region defined by the positions `pos1` and `pos2` by `angle` degrees clockwise around the y axis (supporting 90 degree increments only).\r
93 \r
94 Returns the number of nodes rotated, the new position 1, and the new position 2.\r
95 \r
96 ### count = worldedit.orient(pos1, pos2, angle)\r
97 \r
98 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
99 \r
100 Returns the number of nodes oriented.\r
101 \r
102 ### count = worldedit.fixlight(pos1, pos2)\r
103 \r
104 Fixes the lighting in a region defined by positions `pos1` and `pos2`.\r
105 \r
106 Returns the number of nodes updated.\r
107 \r
108 ### count = worldedit.clearobjects(pos1, pos2)\r
109 \r
110 Clears all objects in a region defined by the positions `pos1` and `pos2`.\r
111 \r
112 Returns the number of objects cleared.\r
113 \r
114 Primitives\r
115 ----------\r
116 Contained in primitives.lua, this module allows the creation of several geometric primitives.\r
117 \r
118 ### count = worldedit.sphere(pos, radius, node_name, hollow)\r
119 \r
120 Adds a sphere centered at `pos` with radius `radius`, composed of `node_name`.\r
121 \r
122 Returns the number of nodes added.\r
123 \r
124 ### count = worldedit.dome(pos, radius, node_name, hollow)\r
125 \r
126 Adds a dome centered at `pos` with radius `radius`, composed of `node_name`.\r
127 \r
128 Returns the number of nodes added.\r
129 \r
130 ### count = worldedit.cylinder(pos, axis, length, radius1, radius2, node_name, hollow)\r
131 \r
132 Adds a cylinder-like at `pos` along the `axis` axis ("x" or "y" or "z") with length `length`, base radius `radius1` and top radius `radius2`, composed of `node_name`.\r
133 \r
134 Returns the number of nodes added.\r
135 \r
136 ### count = worldedit.pyramid(pos, axis, height, node_name, hollow)\r
137 \r
138 Adds a pyramid centered at `pos` along the `axis` axis ("x" or "y" or "z") with height `height`, composed of `node_name`.\r
139 \r
140 Returns the number of nodes added.\r
141 \r
142 ### count = worldedit.spiral(pos, length, height, spacer, node_name)\r
143 \r
144 Adds a spiral centered at `pos` with side length `length`, height `height`, space between walls `spacer`, composed of `node_name`.\r
145 \r
146 Returns the number of nodes added.\r
147 \r
148 Visualization\r
149 -------------\r
150 Contained in visualization.lua, this module allows nodes to be visualized in different ways.\r
151 \r
152 ### volume = worldedit.volume(pos1, pos2)\r
153 \r
154 Determines the volume of the region defined by positions `pos1` and `pos2`.\r
155 \r
156 Returns the volume.\r
157 \r
158 ### count = worldedit.hide(pos1, pos2)\r
159 \r
160 Hides all nodes in a region defined by positions `pos1` and `pos2` by non-destructively replacing them with invisible nodes.\r
161 \r
162 Returns the number of nodes hidden.\r
163 \r
164 ### count = worldedit.suppress(pos1, pos2, node_name)\r
165 \r
166 Suppresses all instances of `node_name` 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 suppressed.\r
169 \r
170 ### count = worldedit.highlight(pos1, pos2, node_name)\r
171 \r
172 Highlights all instances of `node_name` in a region defined by positions `pos1` and `pos2` by non-destructively hiding all other nodes.\r
173 \r
174 Returns the number of nodes found.\r
175 \r
176 ### count = worldedit.restore(pos1, pos2)\r
177 \r
178 Restores all nodes hidden with WorldEdit functions in a region defined by positions `pos1` and `pos2`.\r
179 \r
180 Returns the number of nodes restored.\r
181 \r
182 Serialization\r
183 -------------\r
184 Contained in serialization.lua, this module allows regions of nodes to be serialized and deserialized to formats suitable for use outside MineTest.\r
185 \r
186 ### version, extra_fields, content = worldedit.read_header(value)\r
187 \r
188 Reads the header from serialized data `value`.\r
189 \r
190 Returns the version as a positive integer (nil for unknown versions),\r
191 extra header fields (nil if not supported), and the content after the header.\r
192 \r
193 ### data, count = worldedit.serialize(pos1, pos2)\r
194 \r
195 Converts the region defined by positions `pos1` and `pos2` into a single string.\r
196 \r
197 Returns the serialized data and the number of nodes serialized, or nil.\r
198 \r
199 ### pos1, pos2, count = worldedit.allocate(origin_pos, value)\r
200 \r
201 Determines the volume the nodes represented by string `value` would occupy if deserialized at `origin_pos`.\r
202 \r
203 Returns the two corner positions and the number of nodes, or nil.\r
204 \r
205 ### count = worldedit.deserialize(origin_pos, value)\r
206 \r
207 Loads the nodes represented by string `value` at position `origin_pos`.\r
208 \r
209 Returns the number of nodes deserialized or nil.\r
210 \r
211 Code\r
212 ----\r
213 Contained in code.lua, this module allows arbitrary Lua code to be used with WorldEdit.\r
214 \r
215 ### error = worldedit.lua(code)\r
216 \r
217 Executes `code` as a Lua chunk in the global namespace.\r
218 \r
219 Returns an error if the code fails or nil otherwise.\r
220 \r
221 ### error = worldedit.luatransform(pos1, pos2, code)\r
222 \r
223 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
224 \r
225 Returns an error if the code fails or nil otherwise.\r