Diff for "LuaScript" (#1 -> #2)
< Go back to page history
5 | 5 | "sublayer_width": 14, |
---|
6 | 6 | }) }} |
---|
7 | 7 | |
---|
8 | | Lua Script object, create your own objects by scripting them. To learn more about Lua scripting, just search Google for Lua. |
---|
9 | | |
---|
10 | | The standard Lua math library is available through the global 'math'. For example, `math.floor(x)` and `math.sin(a)`. |
---|
11 | | |
---|
12 | | For a full list of mathematical functions available, check out [the official Lua math documentation](http://www.lua.org/manual/5.2/manual.html#6.6). |
---|
13 | | |
---|
14 | | Below is a list of Principia-specific stuff. |
---|
| 8 | Lua Script object, write Lua programs that can interact with and control the level. |
---|
| 9 | |
---|
| 10 | For more information about Lua scripting in Principia, see [[Principia Lua Scripting]] |
---|
| 11 | |
---|
| 12 | Below is a reference of the Principia-specific Lua API. |
---|
15 | 13 | |
---|
16 | 14 | [toc] |
---|
17 | 15 | |
---|
18 | | # this |
---|
19 | | "this" is a reference to the script object itself. "this" is a **global** object. |
---|
20 | | |
---|
21 | | ## this:write() |
---|
| 16 | # `this` |
---|
| 17 | `this` is a reference to the unique LuaScript object itself. `this` is a **global** object. |
---|
| 18 | |
---|
| 19 | ## `this:write()` |
---|
22 | 20 | Added in **1.3** |
---|
23 | 21 | |
---|
24 | 22 | Writes the value to the given OUT-socket. Values will be clamped between 0.0 and 1.0. |
---|
… | … | |
---|
29 | 27 | this:write(socket_id, value) |
---|
30 | 28 | ``` |
---|
31 | 29 | |
---|
32 | | ## this:read() |
---|
| 30 | ## `this:read()` |
---|
33 | 31 | Added in **1.3** |
---|
34 | 32 | |
---|
35 | 33 | Reads the value from the given IN-socket. |
---|
… | … | |
---|
38 | 36 | local value = this:read(socket_id) |
---|
39 | 37 | ``` |
---|
40 | 38 | |
---|
41 | | ## this:has_plug() |
---|
| 39 | ## `this:has_plug()` |
---|
42 | 40 | Added in **1.5** |
---|
43 | 41 | |
---|
44 | 42 | Returns true if the given IN-socket has a plug attached to it. |
---|
… | … | |
---|
48 | 46 | ``` |
---|
49 | 47 | |
---|
50 | 48 | |
---|
51 | | ## this:write_frequency() |
---|
| 49 | ## `this:write_frequency()` |
---|
52 | 50 | Added in **1.3.0.2** |
---|
53 | 51 | |
---|
54 | 52 | Writes the value to the given frequency. Values will be clamped between 0.0 and 1.0. |
---|
… | … | |
---|
59 | 57 | this:write_frequency(frequency, value) |
---|
60 | 58 | ``` |
---|
61 | 59 | |
---|
62 | | ## this:listen_on_frequency() |
---|
| 60 | ## `this:listen_on_frequency()` |
---|
63 | 61 | Added in **1.4** |
---|
64 | 62 | |
---|
65 | 63 | Starts listening on the given frequency.**NOTE:** Must be called in the init-function. |
---|
… | … | |
---|
68 | 66 | this:listen_on_frequency(frequency) |
---|
69 | 67 | ``` |
---|
70 | 68 | |
---|
71 | | ## this:read_frequency() |
---|
| 69 | ## `this:read_frequency()` |
---|
72 | 70 | Added in **1.4** |
---|
73 | 71 | |
---|
74 | 72 | Reads the value from the given frequency. |
---|
… | … | |
---|
79 | 77 | local value = this:read_frequency(frequency) |
---|
80 | 78 | ``` |
---|
81 | 79 | |
---|
82 | | ## this:first_run() |
---|
| 80 | ## `this:first_run()` |
---|
83 | 81 | Added in **1.3.0.2**, deprecated since **1.5** |
---|
84 | 82 | |
---|
85 | 83 | Returns true if the current step is called in the first run. |
---|
… | … | |
---|
90 | 88 | end |
---|
91 | 89 | ``` |
---|
92 | 90 | |
---|
93 | | ## this:get_position() |
---|
| 91 | ## `this:get_position()` |
---|
94 | 92 | Added in **1.3.0.2** |
---|
95 | 93 | |
---|
96 | 94 | Returns the position of the LuaScript object. |
---|
… | … | |
---|
99 | 97 | local wx, wy = this:get_position() |
---|
100 | 98 | ``` |
---|
101 | 99 | |
---|
102 | | ## this:get_id() |
---|
| 100 | ## `this:get_id()` |
---|
103 | 101 | Added in **1.4** |
---|
104 | 102 | |
---|
105 | 103 | Returns the unique ID of the LuaScript object. |
---|
… | … | |
---|
108 | 106 | local id = this:get_id() |
---|
109 | 107 | ``` |
---|
110 | 108 | |
---|
111 | | ## this:get_resolution() |
---|
| 109 | ## `this:get_resolution()` |
---|
112 | 110 | Added in **1.4** |
---|
113 | 111 | |
---|
114 | 112 | Returns the resolution Principia is currently running at. |
---|
… | … | |
---|
117 | 115 | local width, height = this:get_resolution() |
---|
118 | 116 | ``` |
---|
119 | 117 | |
---|
120 | | ## this:get_ratio() |
---|
121 | | Added in **1.4** |
---|
122 | | |
---|
123 | | Returns the current screen ratio (window_width/window_height). |
---|
| 118 | ## `this:get_ratio()` |
---|
| 119 | Added in **1.4** |
---|
| 120 | |
---|
| 121 | Returns the current screen ratio as a fraction (`window_width / window_height`). |
---|
124 | 122 | |
---|
125 | 123 | ```lua |
---|
126 | 124 | local ratio = this:get_ratio() |
---|
127 | 125 | ``` |
---|
128 | 126 | |
---|
129 | | ## this:set_sprite_blending() |
---|
| 127 | ## `this:set_sprite_blending()` |
---|
130 | 128 | Added in **1.3.0.2** |
---|
131 | 129 | |
---|
132 | 130 | Sets the current blending mode used for drawing sprites. |
---|
133 | | |
---|
134 | | Blend modes: |
---|
135 | | - 0 = 0ff |
---|
136 | | - 1 = Mode A |
---|
137 | | - 2 = Mode B |
---|
| 131 | - `0` = 0ff |
---|
| 132 | - `1` = Mode A |
---|
| 133 | - `2` = Mode B |
---|
138 | 134 | |
---|
139 | 135 | ```lua |
---|
140 | 136 | this:set_sprite_blending(blend_mode) |
---|
141 | 137 | ``` |
---|
142 | 138 | |
---|
143 | | ## this:set_sprite_filtering() |
---|
| 139 | ## `this:set_sprite_filtering()` |
---|
144 | 140 | Added in **1.3.0.2** |
---|
145 | 141 | |
---|
146 | 142 | Sets the current filter mode used for drawing sprites. |
---|
147 | | |
---|
148 | | Filter modes: |
---|
149 | | - 0 = Nearest |
---|
150 | | - 1 = Linear |
---|
| 143 | - `0` = Nearest |
---|
| 144 | - `1` = Linear |
---|
151 | 145 | |
---|
152 | 146 | ```lua |
---|
153 | 147 | this:set_sprite_filtering(filter_mode) |
---|
154 | 148 | ``` |
---|
155 | 149 | |
---|
156 | | ## this:set_sprite_texel() |
---|
| 150 | ## `this:set_sprite_texel()` |
---|
157 | 151 | Added in **1.3.0.2** |
---|
158 | 152 | |
---|
159 | 153 | Sets the color of a sprite texel. |
---|
… | … | |
---|
162 | 156 | this:set_sprite_texel(x, y, r, g, b, a) |
---|
163 | 157 | ``` |
---|
164 | 158 | |
---|
165 | | ## this:clear_texels() |
---|
| 159 | ## `this:clear_texels()` |
---|
166 | 160 | Added in **1.4**, latest update **1.5** |
---|
167 | 161 | |
---|
168 | 162 | Clears all texels. From 1.5 it can now take a clear value. (0-255) |
---|
… | … | |
---|
171 | 165 | this:clear_texels(clear_value) |
---|
172 | 166 | ``` |
---|
173 | 167 | |
---|
174 | | ## this:set_draw_tint() |
---|
175 | | Added in **1.4** |
---|
176 | | |
---|
177 | | Sets the color for future sprite draws. (this:set_sprite_tint in 1.3.0.2) |
---|
| 168 | ## `this:set_draw_tint()` |
---|
| 169 | Added in **1.4** |
---|
| 170 | |
---|
| 171 | Sets the color for future sprite draws. (`this:set_sprite_tint` in 1.3.0.2) |
---|
178 | 172 | |
---|
179 | 173 | ```lua |
---|
180 | 174 | this:set_draw_tint(r, g, b, a) |
---|
181 | 175 | ``` |
---|
182 | 176 | |
---|
183 | | ## this:set_draw_z() |
---|
184 | | Added in **1.4** |
---|
185 | | |
---|
186 | | Sets the Z-value for future sprite draws. (this:set_sprite_z in 1.3.0.2) |
---|
| 177 | ## `this:set_draw_z()` |
---|
| 178 | Added in **1.4** |
---|
| 179 | |
---|
| 180 | Sets the Z-value for future sprite draws. (`this:set_sprite_z` in 1.3.0.2) |
---|
187 | 181 | |
---|
188 | 182 | ```lua |
---|
189 | 183 | this:set_draw_z(z_value) |
---|
190 | 184 | ``` |
---|
191 | 185 | |
---|
192 | | ## this:set_draw_coordinates() |
---|
| 186 | ## `this:set_draw_coordinates()` |
---|
193 | 187 | Added in **1.5** |
---|
194 | 188 | |
---|
195 | 189 | Sets the coordinate mode any future sprite draws will use. |
---|
196 | | - 0 = World-based coordinates |
---|
197 | | - 1 = Screen-based coordinates (0,0 to 100,100) |
---|
198 | | - 2 = Local-based coordinates (Local to LuaScript-object by default, can be changed with the optional parameter local_id) |
---|
| 190 | - `0` = World-based coordinates |
---|
| 191 | - `1` = Screen-based coordinates (0,0 to 100,100) |
---|
| 192 | - `2` = Local-based coordinates (Local to LuaScript-object by default, can be changed with the optional parameter local_id) |
---|
199 | 193 | |
---|
200 | 194 | ```lua |
---|
201 | 195 | this:set_draw_coordinates(coordinate_mode, local_id) |
---|
202 | 196 | ``` |
---|
203 | 197 | |
---|
204 | | ## this:draw_sprite() |
---|
| 198 | ## `this:draw_sprite()` |
---|
205 | 199 | Added in **1.3.0.2** |
---|
206 | 200 | |
---|
207 | 201 | Draws a sprite with the given parameters. |
---|
… | … | |
---|
210 | 204 | this:draw_sprite(x, y, rotation, width, height, texel_from_x, texel_from_y, texel_to_x, texel_to_y) |
---|
211 | 205 | ``` |
---|
212 | 206 | |
---|
213 | | ## this:draw_line() |
---|
| 207 | ## `this:draw_line()` |
---|
214 | 208 | Added in **1.4** |
---|
215 | 209 | |
---|
216 | 210 | Draws a line with the given parameters. |
---|
… | … | |
---|
219 | 213 | this:draw_line(x1, y1, x2, y2, width) |
---|
220 | 214 | ``` |
---|
221 | 215 | |
---|
222 | | ## this:draw_gradient_line() |
---|
223 | | Added in **1.5** |
---|
224 | | |
---|
225 | | Draws a gradient line with the given parameters. The color of the first point will be the one set in this:set_draw_tint(), and the second point will be the values given in the function parameters |
---|
| 216 | ## `this:draw_gradient_line()` |
---|
| 217 | Added in **1.5** |
---|
| 218 | |
---|
| 219 | Draws a gradient line with the given parameters. The color of the first point will be the one set in `this:set_draw_tint()`, and the second point will be the values given in the function parameters. |
---|
226 | 220 | |
---|
227 | 221 | ```lua |
---|
228 | 222 | this:draw_gradient_line(x1, y1, x2, y2, width, r, g, b, a) |
---|
229 | 223 | ``` |
---|
230 | 224 | |
---|
231 | | ## this:draw_line_3d() |
---|
| 225 | ## `this:draw_line_3d()` |
---|
232 | 226 | Added in **1.5** |
---|
233 | 227 | |
---|
234 | 228 | Draws a 3d line with the given parameters. |
---|
… | … | |
---|
237 | 231 | this:draw_line_3d(x1, y1, z1, x2, y2, z2, width) |
---|
238 | 232 | ``` |
---|
239 | 233 | |
---|
240 | | ## this:draw_gradient_line_3d() |
---|
241 | | Added in **1.5** |
---|
242 | | |
---|
243 | | Draws a 3d gradient line with the given parameters.The color of the first point will be the one set in this:set_draw_tint(), and the second point will be the values given in the function parameters |
---|
| 234 | ## `this:draw_gradient_line_3d()` |
---|
| 235 | Added in **1.5** |
---|
| 236 | |
---|
| 237 | Draws a 3D gradient line with the given parameters. The color of the first point will be the one set in `this:set_draw_tint()`, and the second point will be the values given in the function parameters. |
---|
244 | 238 | |
---|
245 | 239 | ```lua |
---|
246 | 240 | this:draw_gradient_line_3d(x1, y1, z1, x2, y2, z2, width, r, g, b, a) |
---|
247 | 241 | ``` |
---|
248 | 242 | |
---|
249 | | ## this:get_sprite_texel() |
---|
| 243 | ## `this:get_sprite_texel()` |
---|
250 | 244 | Added in **1.5** |
---|
251 | 245 | |
---|
252 | 246 | Returns the color for the given sprite texel. |
---|
… | … | |
---|
255 | 249 | local r, g, b, a = this:get_sprite_texel(x, y) |
---|
256 | 250 | ``` |
---|
257 | 251 | |
---|
258 | | ## this:init_draw() |
---|
| 252 | ## `this:init_draw()` |
---|
259 | 253 | Added in **1.5** |
---|
260 | 254 | |
---|
261 | 255 | Initialized the drawing functionality for the current LuaScript object with the width and height specified. |
---|
262 | 256 | - Minimum width or height: 1 |
---|
263 | 257 | - Maximum width or height: 1024 |
---|
264 | | - Width and height MUST be power-of-two. |
---|
| 258 | - Width and height MUST be a power-of-two. |
---|
265 | 259 | |
---|
266 | 260 | ```lua |
---|
267 | 261 | this:init_draw(width, height) |
---|
268 | 262 | ``` |
---|
269 | 263 | |
---|
270 | | ## this:set_static_sprite_texel() |
---|
271 | | Added in **1.5** |
---|
272 | | |
---|
273 | | Sets the color of a static sprite texel. X and Y must be within 0 and the (width/height)-1 specified in this:init_draw() |
---|
| 264 | ## `this:set_static_sprite_texel()` |
---|
| 265 | Added in **1.5** |
---|
| 266 | |
---|
| 267 | Sets the color of a static sprite texel. X and Y must be within 0 and the (width/height)-1 specified in `this:init_draw()`. |
---|
274 | 268 | |
---|
275 | 269 | ```lua |
---|
276 | 270 | this:set_static_sprite_texel(x, y, r, g, b, a) |
---|
277 | 271 | ``` |
---|
278 | 272 | |
---|
279 | | ## this:clear_static_texels() |
---|
280 | | Added in **1.5** |
---|
281 | | |
---|
282 | | Clears all static texels to the given color. If no colors are specified, 0x7F will be set for all channels. |
---|
| 273 | ## `this:clear_static_texels()` |
---|
| 274 | Added in **1.5** |
---|
| 275 | |
---|
| 276 | Clears all static texels to the given color. If no colors are specified, `0x7F` will be set for all channels. |
---|
283 | 277 | |
---|
284 | 278 | ```lua |
---|
285 | 279 | this:clear_static_texels(r, g, b, a) |
---|
286 | 280 | ``` |
---|
287 | 281 | |
---|
288 | | ## this:add_static_sprite() |
---|
| 282 | ## `this:add_static_sprite()` |
---|
289 | 283 | Added in **1.5** |
---|
290 | 284 | |
---|
291 | 285 | Adds a sprite to be rendered with the given paramters. This only needs to be called once per sprite, because it will persist until this:clear_static_sprites() is called. |
---|
… | … | |
---|
294 | 288 | this:add_static_sprite(x, y, rotation, width, height, texel_from_x, texel_from_y, texel_to_x, texel_to_y) |
---|
295 | 289 | ``` |
---|
296 | 290 | |
---|
297 | | ## this:clear_static_sprites() |
---|
298 | | Added in **1.5** |
---|
299 | | |
---|
300 | | Removes all sprites that have been previously added with this:add_static_sprite() |
---|
| 291 | ## `this:clear_static_sprites()` |
---|
| 292 | Added in **1.5** |
---|
| 293 | |
---|
| 294 | Removes all sprites that have been previously added with `this:add_static_sprite()`. |
---|
301 | 295 | |
---|
302 | 296 | ```lua |
---|
303 | 297 | this:clear_static_sprites() |
---|
304 | 298 | ``` |
---|
305 | 299 | |
---|
306 | | # game |
---|
307 | | a broad global object containing various *game*-stuff. game is a **global** object. |
---|
308 | | |
---|
309 | | ## game:show_numfeed() |
---|
| 300 | # `game` |
---|
| 301 | A global object containing various *game*-stuff. game is a **global** object. |
---|
| 302 | |
---|
| 303 | ## `game:show_numfeed()` |
---|
310 | 304 | Added in **1.3**, Latest update **1.3.0.3** |
---|
311 | 305 | |
---|
312 | 306 | Shows the given number on the screen for debugging. |
---|
313 | 307 | |
---|
314 | | From **1.3.0.3** and onward, it can take the num_decimals argument which specifies with what precision the number should be printed. |
---|
| 308 | From **1.3.0.3** and onward, it can take a `num_decimals` argument which specifies with what precision the number should be printed. |
---|
315 | 309 | |
---|
316 | 310 | ```lua |
---|
317 | 311 | local x, y = game:show_numfeed(number, num_decimals) |
---|
318 | 312 | ``` |
---|
319 | 313 | |
---|
320 | | ## game:finish() |
---|
321 | | Added in **1.3.0.2** |
---|
322 | | |
---|
323 | | Finish the game with the desired win state. |
---|
324 | | |
---|
325 | | - 1 = win |
---|
326 | | - 0 = lose. |
---|
| 314 | ## `game:finish()` |
---|
| 315 | Added in **1.3.0.2** |
---|
| 316 | |
---|
| 317 | Finish the game with the desired win state: |
---|
| 318 | - `1` = win |
---|
| 319 | - `0` = lose |
---|
327 | 320 | |
---|
328 | 321 | ```lua |
---|
329 | 322 | game:finish(win_state) |
---|
330 | 323 | ``` |
---|
331 | 324 | |
---|
332 | | ## game:add_score() |
---|
| 325 | ## `game:add_score()` |
---|
333 | 326 | Added in **1.3.0.2** |
---|
334 | 327 | |
---|
335 | 328 | Modifies the current score. Use a negative number to decrease the score. |
---|
… | … | |
---|
338 | 331 | game:add_score(score_mod) |
---|
339 | 332 | ``` |
---|
340 | 333 | |
---|
341 | | ## game:set_score() |
---|
| 334 | ## `game:set_score()` |
---|
342 | 335 | Added in **1.3.0.2** |
---|
343 | 336 | |
---|
344 | 337 | Sets the current score. |
---|
… | … | |
---|
347 | 340 | game:set_score(new_score) |
---|
348 | 341 | ``` |
---|
349 | 342 | |
---|
350 | | ## game:get_score() |
---|
| 343 | ## `game:get_score()` |
---|
351 | 344 | Added in **1.3.0.2** |
---|
352 | 345 | |
---|
353 | 346 | Returns the current score. |
---|
… | … | |
---|
356 | 349 | local score = game:get_score() |
---|
357 | 350 | ``` |
---|
358 | 351 | |
---|
359 | | ## game:activate_rc() |
---|
| 352 | ## `game:activate_rc()` |
---|
360 | 353 | Added in **1.3.0.2** |
---|
361 | 354 | |
---|
362 | 355 | Activate RC Control of an entity using its object fetched with world:get_entity(). |
---|
… | … | |
---|
365 | 358 | game:activate_rc(world:get_entity(entity_id)) |
---|
366 | 359 | ``` |
---|
367 | 360 | |
---|
368 | | ## game:activate_rc_by_id() |
---|
| 361 | ## `game:activate_rc_by_id()` |
---|
369 | 362 | Added in **1.3.0.2** |
---|
370 | 363 | |
---|
371 | 364 | Activate RC Control of an entity using its ID. |
---|
… | … | |
---|
374 | 367 | game:activate_rc_by_id(entity_id) |
---|
375 | 368 | ``` |
---|
376 | 369 | |
---|
377 | | ## game:message() |
---|
378 | | Added in **1.4** |
---|
379 | | |
---|
380 | | Outputs a message on the screen. Duration: |
---|
381 | | - 0 = Short |
---|
382 | | - 1 = Long. |
---|
| 370 | ## `game:message()` |
---|
| 371 | Added in **1.4** |
---|
| 372 | |
---|
| 373 | Outputs a toast message on the screen. Duration: |
---|
| 374 | - `0` = Short |
---|
| 375 | - `1` = Long |
---|
383 | 376 | |
---|
384 | 377 | ```lua |
---|
385 | 378 | game:message(message, duration) |
---|
386 | 379 | ``` |
---|
387 | 380 | |
---|
388 | | ## game:get_cursor() |
---|
| 381 | ## `game:get_cursor()` |
---|
389 | 382 | Added in **1.4** |
---|
390 | 383 | |
---|
391 | 384 | Gets the world coordinates for the cursor in the given layer. |
---|
… | … | |
---|
394 | 387 | local wx, wy = game:get_cursor(layer) |
---|
395 | 388 | ``` |
---|
396 | 389 | |
---|
397 | | ## game:poll_event() |
---|
398 | | Added in **1.4** |
---|
399 | | |
---|
400 | | Returns true if the given event just occured. [List of events](../World_Events) |
---|
| 390 | ## `game:poll_event()` |
---|
| 391 | Added in **1.4** |
---|
| 392 | |
---|
| 393 | Returns true if the given event just occured. See [[Event Manager]] for event IDs. |
---|
401 | 394 | |
---|
402 | 395 | **NOTE:** This function should not be used any longer, and will be deprecated soon. Instead, use the on_event function. |
---|
403 | 396 | |
---|
… | … | |
---|
405 | 398 | game:poll_event(event_id) |
---|
406 | 399 | ``` |
---|
407 | 400 | |
---|
408 | | ## game:get_screen_cursor() |
---|
| 401 | ## `game:get_screen_cursor()` |
---|
409 | 402 | Added in **1.5** |
---|
410 | 403 | |
---|
411 | 404 | Get the cursor position on the screen. (Screen-based coordinates, based on the users screen resolution) |
---|
… | … | |
---|
414 | 407 | local x, y = game:get_screen_cursor() |
---|
415 | 408 | ``` |
---|
416 | 409 | |
---|
417 | | ## game:restart() |
---|
418 | | Added in **1.5** |
---|
419 | | |
---|
420 | | Restart the level |
---|
| 410 | ## `game:restart()` |
---|
| 411 | Added in **1.5** |
---|
| 412 | |
---|
| 413 | Restart the level. |
---|
421 | 414 | |
---|
422 | 415 | ```lua |
---|
423 | 416 | game:restart() |
---|
424 | 417 | ``` |
---|
425 | 418 | |
---|
426 | | ## game:submit_score() |
---|
| 419 | ## `game:submit_score()` |
---|
427 | 420 | Added in **1.5** |
---|
428 | 421 | |
---|
429 | 422 | Submits the player last saved score. |
---|
… | … | |
---|
434 | 427 | game:submit_score() |
---|
435 | 428 | ``` |
---|
436 | 429 | |
---|
437 | | ## game:set_variable() |
---|
438 | | Added in **1.5** |
---|
439 | | |
---|
440 | | Sets the value of the given variable. |
---|
| 430 | ## `game:set_variable()` |
---|
| 431 | Added in **1.5** |
---|
| 432 | |
---|
| 433 | Sets the value of the given Principia variable. |
---|
441 | 434 | |
---|
442 | 435 | **NOTE**: Variables from Lua can contain values outside the normal 0.0-1.0 scope. |
---|
443 | 436 | |
---|
… | … | |
---|
445 | 438 | game:set_variable(varname, value) |
---|
446 | 439 | ``` |
---|
447 | 440 | |
---|
448 | | ## game:get_variable() |
---|
| 441 | ## `game:get_variable()` |
---|
449 | 442 | Added in **1.5** |
---|
450 | 443 | |
---|
451 | 444 | Gets the value of a variable. |
---|
… | … | |
---|
456 | 449 | local value = game:get_variable(varname) |
---|
457 | 450 | ``` |
---|
458 | 451 | |
---|
459 | | ## game:get_fps() |
---|
| 452 | ## `game:get_fps()` |
---|
460 | 453 | Added in **1.5** |
---|
461 | 454 | |
---|
462 | 455 | Returns the average FPS. |
---|
… | … | |
---|
465 | 458 | local fps = game:get_fps() |
---|
466 | 459 | ``` |
---|
467 | 460 | |
---|
468 | | ## game:prompt() |
---|
| 461 | ## `game:prompt()` |
---|
469 | 462 | Added in **1.5.1** |
---|
470 | 463 | |
---|
471 | 464 | Opens a [[Prompt]] with the given parameters. |
---|
… | … | |
---|
481 | 474 | The response function will only be called once, store the value if you wish. |
---|
482 | 475 | |
---|
483 | 476 | Valid responses: |
---|
484 | | - 1 = First button. |
---|
485 | | - 2 = Second button. |
---|
486 | | - 3 = Third button. |
---|
| 477 | - `1` = First button. |
---|
| 478 | - `2` = Second button. |
---|
| 479 | - `3` = Third button. |
---|
487 | 480 | |
---|
488 | 481 | ```lua |
---|
489 | 482 | local prompt_id = game:prompt("Do you want to do something?", "Yes", "No", "Maybe!") |
---|
490 | 483 | ``` |
---|
491 | 484 | |
---|
492 | | # cam |
---|
493 | | controls the players camera. cam is a **global** object. |
---|
494 | | |
---|
495 | | ## cam:get_position() |
---|
| 485 | # `cam` |
---|
| 486 | Controls the player's camera. cam is a **global** object. |
---|
| 487 | |
---|
| 488 | ## `cam:get_position()` |
---|
496 | 489 | Added in **1.3** |
---|
497 | 490 | |
---|
498 | 491 | Returns the X, Y and Z coordinates of the camera. |
---|
… | … | |
---|
501 | 494 | local x, y, z = cam:get_position() |
---|
502 | 495 | ``` |
---|
503 | 496 | |
---|
504 | | ## cam:get_velocity() |
---|
| 497 | ## `cam:get_velocity()` |
---|
505 | 498 | Added in **1.3** |
---|
506 | 499 | |
---|
507 | 500 | Returns the X, Y and Z velocity of the camera. |
---|
… | … | |
---|
510 | 503 | local x, y, z = cam:get_velocity() |
---|
511 | 504 | ``` |
---|
512 | 505 | |
---|
513 | | ## cam:set_position() |
---|
| 506 | ## `cam:set_position()` |
---|
514 | 507 | Added in **1.3** |
---|
515 | 508 | |
---|
516 | 509 | Sets the position of the camera. |
---|
… | … | |
---|
519 | 512 | cam:set_position(x, y, z) |
---|
520 | 513 | ``` |
---|
521 | 514 | |
---|
522 | | ## cam:set_velocity() |
---|
| 515 | ## `cam:set_velocity()` |
---|
523 | 516 | Added in **1.3** |
---|
524 | 517 | |
---|
525 | 518 | Sets the velocity of the camera. |
---|
… | … | |
---|
528 | 521 | cam:set_velocity(x, y, z) |
---|
529 | 522 | ``` |
---|
530 | 523 | |
---|
531 | | ## cam:follow_entity() |
---|
| 524 | ## `cam:follow_entity()` |
---|
532 | 525 | Added in **1.3** |
---|
533 | 526 | |
---|
534 | 527 | Tells the game to follow the entity using the given properties. |
---|
… | … | |
---|
537 | 530 | cam:follow_entity(world:get_entity(entity_id), do_snap, preserve_position) |
---|
538 | 531 | ``` |
---|
539 | 532 | |
---|
540 | | ## cam:follow_entity_by_id() |
---|
| 533 | ## `cam:follow_entity_by_id()` |
---|
541 | 534 | Added in **1.3** |
---|
542 | 535 | |
---|
543 | 536 | Tells the game to follow the entity using the given properties. |
---|
… | … | |
---|
546 | 539 | cam:follow_entity_by_id(entity_id, do_snap, preserve_position) |
---|
547 | 540 | ``` |
---|
548 | 541 | |
---|
549 | | ## cam:get_zoom_ratio() |
---|
550 | | Added in **1.5** |
---|
551 | | |
---|
552 | | Returns the fraction of the players current zoom. 0.0 being fully zoomed in, and 1.0 being fully zoomed out. |
---|
| 542 | ## `cam:get_zoom_ratio()` |
---|
| 543 | Added in **1.5** |
---|
| 544 | |
---|
| 545 | Returns the fraction of the players current zoom. 0.0 being fully zoomed in, 1.0 fully zoomed out. |
---|
553 | 546 | |
---|
554 | 547 | ```lua |
---|
555 | 548 | local frac = cam:get_zoom_ratio() |
---|
556 | 549 | ``` |
---|
557 | 550 | |
---|
558 | | # world |
---|
559 | | world functions.world is a **global** object. |
---|
560 | | |
---|
561 | | ## world:get_entity() |
---|
| 551 | # `world` |
---|
| 552 | World functions. world is a **global** object. |
---|
| 553 | |
---|
| 554 | ## `world:get_entity()` |
---|
562 | 555 | Added in **1.3**, Latest update **1.5**. |
---|
563 | 556 | |
---|
564 | | Returns an entity (object) reference or nil if the object does not exist. |
---|
565 | | |
---|
566 | | Renamed from world:get_entity_by_id() in 1.5. |
---|
| 557 | Returns an entity (object) reference or `nil` if the object does not exist. |
---|
| 558 | |
---|
| 559 | Renamed from `world:get_entity_by_id()` in 1.5. |
---|
567 | 560 | |
---|
568 | 561 | ```lua |
---|
569 | 562 | local my_entity = world:get_entity(entity_id) |
---|
570 | 563 | ``` |
---|
571 | 564 | |
---|
572 | | ## world:raycast() |
---|
| 565 | ## `world:raycast()` |
---|
573 | 566 | Added in **1.4** |
---|
574 | 567 | |
---|
575 | 568 | Raycasts from start to end. Returns nil if nothing was hit, otherwise returns the entity, ptx, pty, norx, nory. |
---|
… | … | |
---|
578 | 571 | local entity, ptx, pty, norx, nory = world:raycast(startx, starty, endx, endy, layer) |
---|
579 | 572 | ``` |
---|
580 | 573 | |
---|
581 | | ## world:query() |
---|
| 574 | ## `world:query()` |
---|
582 | 575 | Added in **1.4** |
---|
583 | 576 | |
---|
584 | 577 | Returns a table of entities located within the given coordinates. Layers and sublayers are optional arguments. |
---|
… | … | |
---|
587 | 580 | local entities = world:query(min_x, min_y, max_x, max_y, layer, sublayers) |
---|
588 | 581 | ``` |
---|
589 | 582 | |
---|
590 | | ## world:get_gravity() |
---|
| 583 | ## `world:get_gravity()` |
---|
591 | 584 | Added in **1.4** |
---|
592 | 585 | |
---|
593 | 586 | Returns the current X and Y gravity of the world. |
---|
… | … | |
---|
596 | 589 | local x, y = world:get_gravity() |
---|
597 | 590 | ``` |
---|
598 | 591 | |
---|
599 | | ## world:get_adventure_id() |
---|
600 | | Added in **1.5** |
---|
601 | | |
---|
602 | | Returns the ID that belongs to the Adventure robot. |
---|
| 592 | ## `world:get_adventure_id()` |
---|
| 593 | Added in **1.5** |
---|
| 594 | |
---|
| 595 | Returns the ID that belongs to the Adventure Robot, if it exists. |
---|
603 | 596 | |
---|
604 | 597 | ```lua |
---|
605 | 598 | local id = world:get_adventure_id() |
---|
606 | 599 | ``` |
---|
607 | 600 | |
---|
608 | | ## world:get_borders() |
---|
| 601 | ## `world:get_borders()` |
---|
609 | 602 | Added in **1.5** |
---|
610 | 603 | |
---|
611 | 604 | Returns the border sizes of the world. |
---|
… | … | |
---|
614 | 607 | local bup, bdown, bleft, bright = world:get_borders() |
---|
615 | 608 | ``` |
---|
616 | 609 | |
---|
617 | | ## world:get_world_point() |
---|
| 610 | ## `world:get_world_point()` |
---|
618 | 611 | Added in **1.5** |
---|
619 | 612 | |
---|
620 | 613 | Converts a global screen point to a world point. |
---|
… | … | |
---|
623 | 616 | local wx, wy = world:get_world_point(gsx, gsy) |
---|
624 | 617 | ``` |
---|
625 | 618 | |
---|
626 | | ## world:set_bg_color() |
---|
627 | | Added in **1.5** |
---|
628 | | |
---|
629 | | Sets the BG color to the given values. |
---|
| 619 | ## `world:set_bg_color()` |
---|
| 620 | Added in **1.5** |
---|
| 621 | |
---|
| 622 | Sets the background color to the given values. |
---|
630 | 623 | |
---|
631 | 624 | **NOTE:** Only works if you're using a colored background in the first place. |
---|
632 | 625 | |
---|
… | … | |
---|
634 | 627 | world:set_bg_color(r, g, b) |
---|
635 | 628 | ``` |
---|
636 | 629 | |
---|
637 | | ## world:set_ambient_light() |
---|
| 630 | ## `world:set_ambient_light()` |
---|
638 | 631 | Added in **1.5** |
---|
639 | 632 | |
---|
640 | 633 | Sets the ambient light of the world to the given value. |
---|
… | … | |
---|
643 | 636 | world:set_ambient_light(intensity) |
---|
644 | 637 | ``` |
---|
645 | 638 | |
---|
646 | | ## world:set_diffuse_light() |
---|
| 639 | ## `world:set_diffuse_light()` |
---|
647 | 640 | Added in **1.5** |
---|
648 | 641 | |
---|
649 | 642 | Sets the diffuse light of the world to the given value. |
---|
… | … | |
---|
652 | 645 | world:set_diffuse_light(intensity) |
---|
653 | 646 | ``` |
---|
654 | 647 | |
---|
655 | | # Entity |
---|
| 648 | # `Entity` |
---|
656 | 649 | A reference to a Principia object. |
---|
657 | 650 | |
---|
658 | | ## entity:get_id() |
---|
| 651 | ## `entity:get_id()` |
---|
659 | 652 | Added in **1.3** |
---|
660 | 653 | |
---|
661 | 654 | Returns the unique ID of the current entity. |
---|
… | … | |
---|
664 | 657 | entity:get_id() |
---|
665 | 658 | ``` |
---|
666 | 659 | |
---|
667 | | ## entity:get_g_id() |
---|
| 660 | ## `entity:get_g_id()` |
---|
668 | 661 | Added in **1.3** |
---|
669 | 662 | |
---|
670 | 663 | Returns the type ID of the current entity. |
---|
… | … | |
---|
673 | 666 | entity:get_g_id() |
---|
674 | 667 | ``` |
---|
675 | 668 | |
---|
676 | | ## entity:get_position() |
---|
| 669 | ## `entity:get_position()` |
---|
677 | 670 | Added in **1.3** |
---|
678 | 671 | |
---|
679 | 672 | Returns the position of the current entity. |
---|
… | … | |
---|
682 | 675 | local x, y = entity:get_position() |
---|
683 | 676 | ``` |
---|
684 | 677 | |
---|
685 | | ## entity:get_angle() |
---|
| 678 | ## `entity:get_angle()` |
---|
686 | 679 | Added in **1.3** |
---|
687 | 680 | |
---|
688 | 681 | Returns the angle of the current entity. |
---|
… | … | |
---|
691 | 684 | local angle = entity:get_angle() |
---|
692 | 685 | ``` |
---|
693 | 686 | |
---|
694 | | ## entity:get_velocity() |
---|
| 687 | ## `entity:get_velocity()` |
---|
695 | 688 | Added in **1.3** |
---|
696 | 689 | |
---|
697 | 690 | Returns the linear velocity of the current entity. |
---|
… | … | |
---|
700 | 693 | local xvel, yvel = entity:get_velocity() |
---|
701 | 694 | ``` |
---|
702 | 695 | |
---|
703 | | ## entity:get_angular_velocity() |
---|
| 696 | ## `entity:get_angular_velocity()` |
---|
704 | 697 | Added in **1.3** |
---|
705 | 698 | |
---|
706 | 699 | Returns the angular velocity of the current entity. |
---|
… | … | |
---|
709 | 702 | local avel = entity:get_angular_velocity() |
---|
710 | 703 | ``` |
---|
711 | 704 | |
---|
712 | | ## entity:get_bbox() |
---|
| 705 | ## `entity:get_bbox()` |
---|
713 | 706 | Added in **1.3** |
---|
714 | 707 | |
---|
715 | 708 | Returns the approximate width and height of the object. |
---|
… | … | |
---|
718 | 711 | local width, height = entity:get_bbox() |
---|
719 | 712 | ``` |
---|
720 | 713 | |
---|
721 | | ## entity:get_layer() |
---|
| 714 | ## `entity:get_layer()` |
---|
722 | 715 | Added in **1.4** |
---|
723 | 716 | |
---|
724 | 717 | Returns the layer of the current entity. |
---|
… | … | |
---|
727 | 720 | local layer = entity:get_layer() |
---|
728 | 721 | ``` |
---|
729 | 722 | |
---|
730 | | ## entity:local_to_world() |
---|
| 723 | ## `entity:local_to_world()` |
---|
731 | 724 | Added in **1.4** |
---|
732 | 725 | |
---|
733 | 726 | Returns the world coordinates converted from the given local coordinates from the current entity. |
---|
… | … | |
---|
736 | 729 | local wx, wy = entity:local_to_world(lx, ly) |
---|
737 | 730 | ``` |
---|
738 | 731 | |
---|
739 | | ## entity:world_to_local() |
---|
| 732 | ## `entity:world_to_local()` |
---|
740 | 733 | Added in **1.4** |
---|
741 | 734 | |
---|
742 | 735 | Returns the local coordinates converted from the given world coordinates in relation to the current entity. |
---|
… | … | |
---|
745 | 738 | local lx, ly = entity:world_to_local(wx, wy) |
---|
746 | 739 | ``` |
---|
747 | 740 | |
---|
748 | | ## entity:highlight() |
---|
| 741 | ## `entity:highlight()` |
---|
749 | 742 | Added in **1.4** |
---|
750 | 743 | |
---|
751 | 744 | Highlight the entity. |
---|
… | … | |
---|
754 | 747 | entity:highlight() |
---|
755 | 748 | ``` |
---|
756 | 749 | |
---|
757 | | ## entity:damage() |
---|
| 750 | ## `entity:damage()` |
---|
758 | 751 | Added in **1.5** |
---|
759 | 752 | |
---|
760 | 753 | Only works on destructible objects or creatures. |
---|
… | … | |
---|
765 | 758 | entity:damage(amount) |
---|
766 | 759 | ``` |
---|
767 | 760 | |
---|
768 | | ## entity:is_static() |
---|
| 761 | ## `entity:is_static()` |
---|
769 | 762 | Added in **1.5** |
---|
770 | 763 | |
---|
771 | 764 | Returns true if the entity is a static object (unable to move), otherwise false. |
---|
… | … | |
---|
776 | 769 | end |
---|
777 | 770 | ``` |
---|
778 | 771 | |
---|
779 | | ## entity:absorb() |
---|
| 772 | ## `entity:absorb()` |
---|
780 | 773 | Added in **1.5** |
---|
781 | 774 | |
---|
782 | 775 | Absorbs the entity if possible. The value returns indicates whether the absorb was completed successfully. |
---|
… | … | |
---|
785 | 778 | local success = entity:absorb(follow_connections) |
---|
786 | 779 | ``` |
---|
787 | 780 | |
---|
788 | | ## entity:apply_torque() |
---|
| 781 | ## `entity:apply_torque()` |
---|
789 | 782 | Added in **1.5** |
---|
790 | 783 | |
---|
791 | 784 | Apply torque to the entity. |
---|
… | … | |
---|
794 | 787 | entity:apply_torque(torque) |
---|
795 | 788 | ``` |
---|
796 | 789 | |
---|
797 | | ## entity:set_velocity() |
---|
| 790 | ## `entity:set_velocity()` |
---|
798 | 791 | Added in **1.5** |
---|
799 | 792 | |
---|
800 | 793 | Sets the linear velocity of the given entity. |
---|
… | … | |
---|
803 | 796 | entity:set_velocity(x, y) |
---|
804 | 797 | ``` |
---|
805 | 798 | |
---|
806 | | ## entity:warp() |
---|
| 799 | ## `entity:warp()` |
---|
807 | 800 | Added in **1.5** |
---|
808 | 801 | |
---|
809 | 802 | Warps the entity to the given x/y world coordinates and layer. If the third argument is unset(layer), the layer will not be changed. |
---|
… | … | |
---|
812 | 805 | entity:warp(wx, wy, layer = -1) |
---|
813 | 806 | ``` |
---|
814 | 807 | |
---|
815 | | ## entity:show() |
---|
| 808 | ## `entity:show()` |
---|
816 | 809 | Added in **1.5** |
---|
817 | 810 | |
---|
818 | 811 | Shows the entity if it was previously hidden. |
---|
… | … | |
---|
821 | 814 | entity:show() |
---|
822 | 815 | ``` |
---|
823 | 816 | |
---|
824 | | ## entity:hide() |
---|
| 817 | ## `entity:hide()` |
---|
825 | 818 | Added in **1.5** |
---|
826 | 819 | |
---|
827 | 820 | Hides the entity if it was previously visible. It will still interact with the world even though it's hidden. |
---|
… | … | |
---|
830 | 823 | entity:hide() |
---|
831 | 824 | ``` |
---|
832 | 825 | |
---|
833 | | ## entity:get_name() |
---|
| 826 | ## `entity:get_name()` |
---|
834 | 827 | Added in **1.5** |
---|
835 | 828 | |
---|
836 | 829 | Returns the name of the given entity. |
---|
… | … | |
---|
839 | 832 | local name = entity:get_name() |
---|
840 | 833 | ``` |
---|
841 | 834 | |
---|
842 | | ## entity:is_creature() |
---|
| 835 | ## `entity:is_creature()` |
---|
843 | 836 | Added in **1.5** |
---|
844 | 837 | |
---|
845 | 838 | Returns true if the given entity is a creature. |
---|
… | … | |
---|
850 | 843 | end |
---|
851 | 844 | ``` |
---|
852 | 845 | |
---|
853 | | ## entity:is_robot() |
---|
| 846 | ## `entity:is_robot()` |
---|
854 | 847 | Added in **1.5** |
---|
855 | 848 | |
---|
856 | 849 | Returns true if the given entity is any kind of robot. |
---|
… | … | |
---|
861 | 854 | end |
---|
862 | 855 | ``` |
---|
863 | 856 | |
---|
864 | | ## entity:is_player() |
---|
| 857 | ## `entity:is_player()` |
---|
865 | 858 | Added in **1.5** |
---|
866 | 859 | |
---|
867 | 860 | Returns true if the given entity is the current player. |
---|
… | … | |
---|
872 | 865 | end |
---|
873 | 866 | ``` |
---|
874 | 867 | |
---|
875 | | ## entity:get_mass() |
---|
| 868 | ## `entity:get_mass()` |
---|
876 | 869 | Added in **1.5** |
---|
877 | 870 | |
---|
878 | 871 | Returns the mass of the entity. |
---|
… | … | |
---|
881 | 874 | local mass = entity:get_mass() |
---|
882 | 875 | ``` |
---|
883 | 876 | |
---|
884 | | ## entity:get_density() |
---|
| 877 | ## `entity:get_density()` |
---|
885 | 878 | Added in **1.5** |
---|
886 | 879 | |
---|
887 | 880 | Returns the average density of all fixtures of the given entity. |
---|
… | … | |
---|
890 | 883 | local density = entity:get_density() |
---|
891 | 884 | ``` |
---|
892 | 885 | |
---|
893 | | ## entity:get_friction() |
---|
| 886 | ## `entity:get_friction()` |
---|
894 | 887 | Added in **1.5** |
---|
895 | 888 | |
---|
896 | 889 | Returns the average friction of all fixtures of the given entity. |
---|
… | … | |
---|
899 | 892 | local friction = entity:get_friction() |
---|
900 | 893 | ``` |
---|
901 | 894 | |
---|
902 | | ## entity:get_restitution() |
---|
| 895 | ## `entity:get_restitution()` |
---|
903 | 896 | Added in **1.5** |
---|
904 | 897 | |
---|
905 | 898 | Returns the average restitution of all fixtures of the given entity. |
---|
… | … | |
---|
908 | 901 | local restitution = entity:get_restitution() |
---|
909 | 902 | ``` |
---|
910 | 903 | |
---|
911 | | ## entity:set_color() |
---|
| 904 | ## `entity:set_color()` |
---|
912 | 905 | Added in **1.5** |
---|
913 | 906 | |
---|
914 | 907 | Sets the color of the given entity, if possible. Does not work will all entities. |
---|
… | … | |
---|
919 | 912 | entity:set_color(r, g, b) |
---|
920 | 913 | ``` |
---|
921 | 914 | |
---|
922 | | ## entity:disconnect_all() |
---|
| 915 | ## `entity:disconnect_all()` |
---|
923 | 916 | Added in **1.5** |
---|
924 | 917 | |
---|
925 | 918 | Detach all connections from the entity. |
---|
… | … | |
---|
928 | 921 | entity:disconnect_all() |
---|
929 | 922 | ``` |
---|
930 | 923 | |
---|
931 | | ## entity:set_target_id() |
---|
| 924 | ## `entity:set_target_id()` |
---|
932 | 925 | Added in **1.5** |
---|
933 | 926 | |
---|
934 | 927 | Sets the target ID of the given entity. Currently only usable with the robot manager. |
---|
… | … | |
---|
937 | 930 | entity:set_target_id(target_id) |
---|
938 | 931 | ``` |
---|
939 | 932 | |
---|
940 | | ## entity:call() |
---|
941 | | Added in **1.5** |
---|
942 | | |
---|
943 | | If the entity is a luascript object, call one of its functions.Example level: http://archive.principiagame.com/level/10140 |
---|
| 933 | ## `entity:call()` |
---|
| 934 | Added in **1.5** |
---|
| 935 | |
---|
| 936 | If the entity is a LuaScript object, call the specified function. |
---|
944 | 937 | |
---|
945 | 938 | ```lua |
---|
946 | 939 | local x, y = entity:call("my_ultracool_function", a, b, c) |
---|
947 | 940 | ``` |
---|
948 | 941 | |
---|
949 | | # Creature |
---|
950 | | A reference to a Principia creature. NOTE: Most entity-functions also work on creature, see creature as an extension to entity. |
---|
951 | | |
---|
952 | | ## creature:get_hp() |
---|
| 942 | # `Creature` |
---|
| 943 | A reference to a Principia creature. |
---|
| 944 | |
---|
| 945 | **NOTE:** Most entity-functions also work on creature, see creature as an extension to entity. |
---|
| 946 | |
---|
| 947 | ## `creature:get_hp()` |
---|
953 | 948 | Added in **1.5** |
---|
954 | 949 | |
---|
955 | 950 | Returns the HP and max HP of the creature. |
---|
… | … | |
---|
958 | 953 | local hp, max_hp = creature:get_hp() |
---|
959 | 954 | ``` |
---|
960 | 955 | |
---|
961 | | ## creature:get_armor() |
---|
| 956 | ## `creature:get_armor()` |
---|
962 | 957 | Added in **1.5** |
---|
963 | 958 | |
---|
964 | 959 | Returns the armor and max armor of the creature. |
---|
… | … | |
---|
967 | 962 | local armor, max_armor = creature:get_armor() |
---|
968 | 963 | ``` |
---|
969 | 964 | |
---|
970 | | ## creature:get_aim() |
---|
971 | | Added in **1.5** |
---|
972 | | |
---|
973 | | Returns the aim of the current creature, assuming it can aim! |
---|
| 965 | ## `creature:get_aim()` |
---|
| 966 | Added in **1.5** |
---|
| 967 | |
---|
| 968 | Returns the aim of the current creature, assuming it can aim. |
---|
974 | 969 | |
---|
975 | 970 | ```lua |
---|
976 | 971 | local aim = creature:get_aim() |
---|
977 | 972 | ``` |
---|
978 | 973 | |
---|
979 | | ## creature:set_aim() |
---|
| 974 | ## `creature:set_aim()` |
---|
980 | 975 | Added in **1.5** |
---|
981 | 976 | |
---|
982 | 977 | Sets the weapon arm angle for the creature, if applicable. |
---|
… | … | |
---|
985 | 980 | creature:set_aim(new_aim) |
---|
986 | 981 | ``` |
---|
987 | 982 | |
---|
988 | | ## creature:stop() |
---|
989 | | Added in **1.5** |
---|
990 | | |
---|
991 | | Stop the creature from walking in the given direction. If no direction is given, the creature stops moving in all directions.left = -1, right = 1, down = 0, up = 2 |
---|
| 983 | ## `creature:stop()` |
---|
| 984 | Added in **1.5** |
---|
| 985 | |
---|
| 986 | Stop the creature from walking in the given direction. If no direction is given, the creature stops moving in all directions. (left = -1, right = 1, down = 0, up = 2) |
---|
992 | 987 | |
---|
993 | 988 | ```lua |
---|
994 | 989 | creature:stop(direction = all) |
---|
995 | 990 | ``` |
---|
996 | 991 | |
---|
997 | | ## creature:move() |
---|
998 | | Added in **1.5** |
---|
999 | | |
---|
1000 | | Tell the creature to start moving in the given direction.left = -1, right = 1, down = 0, up = 2 |
---|
| 992 | ## `creature:move()` |
---|
| 993 | Added in **1.5** |
---|
| 994 | |
---|
| 995 | Tell the creature to start moving in the given direction. (left = -1, right = 1, down = 0, up = 2) |
---|
1001 | 996 | |
---|
1002 | 997 | ```lua |
---|
1003 | 998 | creature:move(direction) |
---|
1004 | 999 | ``` |
---|
1005 | 1000 | |
---|
1006 | | ## creature:is_action_active() |
---|
| 1001 | ## `creature:is_action_active()` |
---|
1007 | 1002 | Added in **1.5** |
---|
1008 | 1003 | |
---|
1009 | 1004 | Returns true if the creature has their special action activated. |
---|
… | … | |
---|
1014 | 1009 | end |
---|
1015 | 1010 | ``` |
---|
1016 | 1011 | |
---|
1017 | | ## creature:action_on() |
---|
1018 | | Added in **1.5** |
---|
1019 | | |
---|
1020 | | Toggles the creatures special action on. |
---|
| 1012 | ## `creature:action_on()` |
---|
| 1013 | Added in **1.5** |
---|
| 1014 | |
---|
| 1015 | Toggles the creature's special action on. |
---|
1021 | 1016 | |
---|
1022 | 1017 | ```lua |
---|
1023 | 1018 | creature:action_on() |
---|
1024 | 1019 | ``` |
---|
1025 | 1020 | |
---|
1026 | | ## creature:action_off() |
---|
1027 | | Added in **1.5** |
---|
1028 | | |
---|
1029 | | Toggles the creatures special action off. |
---|
| 1021 | ## `creature:action_off()` |
---|
| 1022 | Added in **1.5** |
---|
| 1023 | |
---|
| 1024 | Toggles the creature's special action off. |
---|
1030 | 1025 | |
---|
1031 | 1026 | ```lua |
---|
1032 | 1027 | creature:action_off() |
---|