Merge lp:~widelands-dev/widelands/document_worker_program into lp:widelands
- document_worker_program
- Merge into trunk
Status: | Merged |
---|---|
Merged at revision: | 8441 |
Proposed branch: | lp:~widelands-dev/widelands/document_worker_program |
Merge into: | lp:widelands |
Diff against target: |
1096 lines (+566/-146) 12 files modified
data/tribes/workers/atlanteans/armorsmith/init.lua (+21/-1) data/tribes/workers/atlanteans/carrier/init.lua (+3/-3) data/tribes/workers/atlanteans/soldier/init.lua (+3/-3) doc/sphinx/extract_rst.py (+3/-0) doc/sphinx/source/animations.rst (+1/-1) doc/sphinx/source/conf.py (+2/-0) doc/sphinx/source/implementation.rst (+18/-16) doc/sphinx/source/lua_tribes_workers.rst.org (+6/-15) doc/sphinx/source/map_object_programs.rst (+14/-0) doc/sphinx/source/map_objects.rst (+1/-0) doc/sphinx/source/productionsite_program.rst (+1/-0) src/logic/map_objects/tribes/worker_program.cc (+493/-107) |
To merge this branch: | bzr merge lp:~widelands-dev/widelands/document_worker_program |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
GunChleoc | Needs Resubmitting | ||
Review via email: mp+329696@code.launchpad.net |
Commit message
Added documentation for worker programs.
Description of the change
This documentation is to replace https:/
Also hooked the production program reference into the TOC.
The changes in implementation.rst are just fixed line endings, plus a code highlighting command at the top of the file.
bunnybot (widelandsofficial) wrote : | # |
kaputtnik (franku) wrote : | # |
For code examples there should be either a highlight directive used or the code-block directive. So comments are shown properly and some keywords in the comments (e.g.: and, or) are shown correctly.
If we are using only code examples in language lua, we could define the config var 'highlight_
https:/
This has to be set in doc/sphinx/
One inline comment :-)
kaputtnik (franku) wrote : | # |
Forgot to save the inline comment...
GunChleoc (gunchleoc) wrote : | # |
Thanks!
GunChleoc (gunchleoc) wrote : | # |
This is ready now.
kaputtnik (franku) wrote : | # |
Did not read completely, just stumbled over 'Common Worker Properties':
I think this part is explained vice versa as other parts...
"Workers are defined with Lua functions called new_worker_
Shouldn't be the function name (new_worker_
"Worker programs are defined in the programs subtable specified in calls to tribes:
Currently the link to tribes:
Formatting looks good so far (testing with local website) :-)
GunChleoc (gunchleoc) wrote : | # |
Sphinx won't link to :any:`tribes:
bunnybot (widelandsofficial) wrote : | # |
Continuous integration builds have changed state:
Travis build 2604. State: passed. Details: https:/
Appveyor build 2426. State: success. Details: https:/
kaputtnik (franku) wrote : | # |
Regarding the types of workers
https:/
it should be added that the common worker properties do also apply to these special workers. Something like:
"In addition to the basic worker type, see below, Widelands knows about the following sub types, which should have also the Common Worker Properties:"
Can't find the right wording here :-S
Two comments, otherwise looks good to me.
Clashing of developer and user :-D
kaputtnik (franku) wrote : | # |
Sidenote: Just found http://
Is there a reason why this is not inside the lua scripting? http://
GunChleoc (gunchleoc) wrote : | # |
> it should be added that the common worker properties do also apply to these special workers.
That's already documented in the subclasses themselves, like this:
"This table contains all the data that the game engine will add to this carrier. It contains the Common Worker Properties, plus the following additional property:"
https:/
> Clashing of developer and user :-D
The documentation is for the user, so your feedback is invaluable :)
kaputtnik (franku) wrote : | # |
Looks good :-)
> > it should be added that the common worker properties do also apply to these
> special workers.
>
> That's already documented in the subclasses themselves, like this:
>
> "This table contains all the data that the game engine will add to this
> carrier. It contains the Common Worker Properties, plus the following
> additional property:"
I read this and this is fine. The problem (for me) is that the function definition of new_worker_
From my point of view it would be much logical to have 'new_worker_type{}' in section "Types of Workers"
https:/
and add a sentence like: "All types of workers have the same Common worker Properties"
Backlinks to "Common Worker Properties" are the not that confusing then.
GunChleoc (gunchleoc) wrote : | # |
I think I have found a solution now. I have added a subpage for the basic worker type.
Regarding the productionsite programs, I haven't touched them at all yet, because that would make the diff too big.
kaputtnik (franku) wrote : | # |
That's perfect :-)
Maybe the sentence shown with each worker type regarding the helptext could then be omitted in each worker-type-page and placed in the 'Workers' section.
"Each type of worker will also need its help texts, which are defined in data/tribes/
And linking to http://
Feel free to merge... Otherwise i get caught up in the details ;)
GunChleoc (gunchleoc) wrote : | # |
Good idea about the link. I have kept the phrasing though.
Thanks for the review :)
@bunnybot merge
Preview Diff
1 | === modified file 'data/tribes/workers/atlanteans/armorsmith/init.lua' |
2 | --- data/tribes/workers/atlanteans/armorsmith/init.lua 2017-02-20 13:53:01 +0000 |
3 | +++ data/tribes/workers/atlanteans/armorsmith/init.lua 2017-08-30 16:47:36 +0000 |
4 | @@ -1,5 +1,18 @@ |
5 | -- The basic worker documentation is located in /doc/sphinx/lua_tribes_workers_rst.org |
6 | |
7 | +-- RST |
8 | +-- .. _lua_tribes_basic_workers: |
9 | +-- |
10 | +-- Workers |
11 | +-- -------- |
12 | +-- |
13 | +-- Workers of this basic type work in buildings. Their function is defined either |
14 | +-- through the :ref:`buildings' programs <productionsite_programs>`, or through their :ref:`own programs <tribes_worker_programs>`. |
15 | +-- |
16 | +-- Workers are defined in |
17 | +-- ``data/tribes/workers/<tribe name>/<worker_name>/init.lua``. |
18 | +-- The worker will also need its :ref:`help texts <lua_tribes_workers_helptexts>`, |
19 | +-- which are defined in ``data/tribes/wares/<tribe name>/<worker_name>/helptexts.lua``. |
20 | dirname = path.dirname(__file__) |
21 | |
22 | animations = { |
23 | @@ -11,7 +24,14 @@ |
24 | add_walking_animations(animations, "walk", dirname, "walk", {8, 23}, 10) |
25 | add_walking_animations(animations, "walkload", dirname, "walkload", {8, 23}, 10) |
26 | |
27 | - |
28 | +-- RST |
29 | +-- .. function:: new_worker_type{table} |
30 | +-- |
31 | +-- This function adds the definition of a worker to the engine. |
32 | +-- |
33 | +-- :arg table: This table contains all the data that the game engine will add |
34 | +-- to this worker. It contains the properties in |
35 | +-- :ref:`lua_tribes_workers_common`. |
36 | tribes:new_worker_type { |
37 | msgctxt = "atlanteans_worker", |
38 | name = "atlanteans_armorsmith", |
39 | |
40 | === modified file 'data/tribes/workers/atlanteans/carrier/init.lua' |
41 | --- data/tribes/workers/atlanteans/carrier/init.lua 2017-04-21 23:04:00 +0000 |
42 | +++ data/tribes/workers/atlanteans/carrier/init.lua 2017-08-30 16:47:36 +0000 |
43 | @@ -10,8 +10,8 @@ |
44 | -- |
45 | -- Carriers, like workers, are defined in |
46 | -- ``data/tribes/workers/<tribe name>/<worker_name>/init.lua``. |
47 | --- The carrier will also need its help texts, which are defined in |
48 | --- ``data/tribes/wares/<tribe name>/<worker_name>/helptexts.lua`` |
49 | +-- The carrier will also need its :ref:`help texts <lua_tribes_workers_helptexts>`, |
50 | +-- which are defined in ``data/tribes/wares/<tribe name>/<worker_name>/helptexts.lua`` |
51 | |
52 | dirname = path.dirname(__file__) |
53 | |
54 | @@ -26,7 +26,7 @@ |
55 | add_walking_animations(animations, "walkload", dirname, "walkload", {8, 25}, 10) |
56 | |
57 | -- RST |
58 | --- .. function:: new_carrier_type(table) |
59 | +-- .. function:: new_carrier_type{table} |
60 | -- |
61 | -- This function adds the definition of a carrier to the engine. |
62 | -- |
63 | |
64 | === modified file 'data/tribes/workers/atlanteans/soldier/init.lua' |
65 | --- data/tribes/workers/atlanteans/soldier/init.lua 2017-02-20 13:53:01 +0000 |
66 | +++ data/tribes/workers/atlanteans/soldier/init.lua 2017-08-30 16:47:36 +0000 |
67 | @@ -9,8 +9,8 @@ |
68 | -- |
69 | -- Soldiers, like workers, are defined in |
70 | -- ``data/tribes/workers/<tribe name>/soldier/init.lua``. |
71 | --- The soldier will also need its help texts, which are defined in |
72 | --- ``data/tribes/wares/<tribe name>/soldier/helptexts.lua`` |
73 | +-- The soldier will also need its :ref:`help texts <lua_tribes_workers_helptexts>`, |
74 | +-- which are defined in ``data/tribes/wares/<tribe name>/soldier/helptexts.lua`` |
75 | |
76 | dirname = path.dirname(__file__) |
77 | |
78 | @@ -74,7 +74,7 @@ |
79 | add_walking_animations(animations, "walk", dirname, "walk", {20, 34}, 10) |
80 | |
81 | -- RST |
82 | --- .. function:: new_soldier_type(table) |
83 | +-- .. function:: new_soldier_type{table} |
84 | -- |
85 | -- This function adds the definition of a soldier to the engine. |
86 | -- |
87 | |
88 | === modified file 'doc/sphinx/extract_rst.py' |
89 | --- doc/sphinx/extract_rst.py 2017-02-20 13:53:01 +0000 |
90 | +++ doc/sphinx/extract_rst.py 2017-08-30 16:47:36 +0000 |
91 | @@ -20,6 +20,7 @@ |
92 | ('src/scripting/lua_game.cc', 'autogen_wl_game.rst'), |
93 | ('src/scripting/lua_ui.cc', 'autogen_wl_ui.rst'), |
94 | ('src/scripting/lua_globals.cc', 'autogen_globals.rst'), |
95 | + ('src/logic/map_objects/tribes/worker_program.cc', 'autogen_tribes_worker_programs.rst'), |
96 | ) |
97 | |
98 | # These directories are scanned without knowing which file |
99 | @@ -53,6 +54,8 @@ |
100 | 'ships', 'lua_tribes_units'), |
101 | ('data/tribes/wares/armor', |
102 | 'wares', 'lua_tribes_units'), |
103 | + ('data/tribes/workers/atlanteans/armorsmith', |
104 | + 'basic_workers', 'lua_tribes_workers'), |
105 | ('data/tribes/workers/atlanteans/carrier', |
106 | 'carriers', 'lua_tribes_workers'), |
107 | ('data/tribes/workers/atlanteans/soldier', |
108 | |
109 | === modified file 'doc/sphinx/source/animations.rst' |
110 | --- doc/sphinx/source/animations.rst 2017-08-27 08:21:51 +0000 |
111 | +++ doc/sphinx/source/animations.rst 2017-08-30 16:47:36 +0000 |
112 | @@ -122,7 +122,7 @@ |
113 | **walkload** |
114 | *Optional*. A directional animation. The worker is walking while carrying something. |
115 | |
116 | -Any further animations like e.g. "plant", "harvest", or "breed" will be referenced in the ``programs table``, under the ``animation`` command. |
117 | +Any further animations like e.g. "plant", "harvest", or "breed" will be referenced in the :ref:`tribes_worker_programs`, under the ``animation`` command. |
118 | |
119 | For example, a fisher could look like this:: |
120 | |
121 | |
122 | === modified file 'doc/sphinx/source/conf.py' |
123 | --- doc/sphinx/source/conf.py 2017-07-04 19:17:39 +0000 |
124 | +++ doc/sphinx/source/conf.py 2017-08-30 16:47:36 +0000 |
125 | @@ -86,6 +86,8 @@ |
126 | # A list of ignored prefixes for module index sorting. |
127 | #modindex_common_prefix = [] |
128 | |
129 | +highlight_language = 'lua' |
130 | + |
131 | |
132 | # -- Options for HTML output --------------------------------------------------- |
133 | |
134 | |
135 | === modified file 'doc/sphinx/source/implementation.rst' |
136 | --- doc/sphinx/source/implementation.rst 2013-10-19 10:42:47 +0000 |
137 | +++ doc/sphinx/source/implementation.rst 2017-08-30 16:47:36 +0000 |
138 | @@ -1,11 +1,13 @@ |
139 | +.. highlight:: default |
140 | + |
141 | Implementation Notes |
142 | ==================== |
143 | |
144 | This section is for developers who want to add more features to the Lua |
145 | support in widelands (or that want to track down bugs). This contains notes |
146 | -about how certain things are implemented and how to add to it. |
147 | +about how certain things are implemented and how to add to it. |
148 | |
149 | -.. Note:: |
150 | +.. Note:: |
151 | |
152 | This section is not for scenario designers, only for developers |
153 | working directly on widelands. |
154 | @@ -17,7 +19,7 @@ |
155 | The scripting interface is defined in ``scripting/scripting.h``. It consists |
156 | of the two classes LuaInterface for running scripts and LuaCouroutine which |
157 | wraps a Lua coroutine. The Lua interface is accessed via the lua() function in |
158 | -Editor_Game_Base. |
159 | +Editor_Game_Base. |
160 | |
161 | There are two game commands for lua: ``Cmd_LuaScript`` and |
162 | ``Cmd_LuaCoroutine``. The first one is only used to enqueue the initial |
163 | @@ -58,7 +60,7 @@ |
164 | |
165 | const char L_Player::className[] = "Player"; // Name of this class |
166 | const MethodType<L_Player> L_Player::Methods[] = { |
167 | - METHOD(L_Player, __eq), // compare operator |
168 | + METHOD(L_Player, __eq), // compare operator |
169 | METHOD(L_Player, place_flag), // a method called place_flag |
170 | {0, 0}, // end of methods table |
171 | }; |
172 | @@ -85,18 +87,18 @@ |
173 | Luna Classes need even more boilerplate to work correctly. Firstly, they must |
174 | define a function ``get_modulename`` that returns a ``const char *`` which |
175 | will be the submodule name where this class is registered. For our example, |
176 | -Player would return ``"game"`` because it is defined in ``wl.game``. |
177 | +Player would return ``"game"`` because it is defined in ``wl.game``. |
178 | |
179 | The class must also define two constructors, one that takes no arguments and |
180 | is only used to create a empty class that is created for unpersisting. And a |
181 | second one that takes a ``lua_State *`` that is called when the construction |
182 | is requested from Lua, that is if ``wl.game.Player()`` is called. Some (most?) |
183 | classes can't be constructed from Lua and should then answer with |
184 | -``report_error()``. |
185 | +``report_error()``. |
186 | |
187 | En plus, a function ``__persist(lua_State *)`` and a function |
188 | ``__unpersist(lua_State *)`` must be defined. They are discussed in the next |
189 | -section. |
190 | +section. |
191 | |
192 | .. _Luna: http://lua-users.org/wiki/SimplerCppBinding |
193 | |
194 | @@ -104,10 +106,10 @@ |
195 | ----------- |
196 | |
197 | When a savegame is created, the current environment of Lua is persisted. For |
198 | -this, I used a library called Eris_. |
199 | +this, I used a library called Eris_. |
200 | |
201 | .. _Eris: https://github.com/fnuecke |
202 | - |
203 | + |
204 | The global environment is persisted into the file map/globals.dump. Everything |
205 | is persisted except of the Lua build-in functions and everything in the ``wl`` |
206 | table and some of our own global functions. Those are c-functions that can not |
207 | @@ -115,7 +117,7 @@ |
208 | everything in the auxiliary scripts are saved to disk, so save games only |
209 | depend on the API defined inside the Widelands. |
210 | |
211 | -Coroutines are persisted in their ``Cmd_LuaCoroutine`` package. |
212 | +Coroutines are persisted in their ``Cmd_LuaCoroutine`` package. |
213 | |
214 | Luna classes have to implement two functions to be properly persistable: |
215 | |
216 | @@ -139,20 +141,20 @@ |
217 | *)`` to the Map_Map_Object_Loader and ``get_mos(lua_State *)`` to the |
218 | Map_Map_Object_Saver. These function return 0 when not called in |
219 | ``__persist`` and ``__unpersist``. |
220 | - |
221 | + |
222 | Testing |
223 | ------- |
224 | |
225 | Lua support is currently tested in two different scenarios. Both life in |
226 | ``src/scripting/test`` and they work essentially the same: they are normal |
227 | -scenarios which contain a Lua unittest framework named lunit_ that the |
228 | +scenarios which contain a Lua unittest framework named lunit_ that the |
229 | author agreed to be used in widelands like that. The scripts than use various |
230 | -Lua functions and check that they do the expected things. |
231 | +Lua functions and check that they do the expected things. |
232 | |
233 | If you add new features to the Lua support of Widelands, consider also adding |
234 | tests in the appropriate places in the test suite. This guarantees that nothing |
235 | unexpected happens in scenarios and it will show the most common bugs quite |
236 | -easily. |
237 | +easily. |
238 | |
239 | .. _lunit: http://www.nessie.de/mroth/lunit/ |
240 | |
241 | @@ -173,7 +175,7 @@ |
242 | #### Test Suite finished. |
243 | |
244 | 353 Assertions checked. All Tests passed! |
245 | - |
246 | + |
247 | If the test suite fails, widelands will be kept running and the error message |
248 | of the failed test will be visible in the output. This is then a bug and |
249 | should be reported. |
250 | @@ -185,7 +187,7 @@ |
251 | between different versions. First, you need to run it as scenario:: |
252 | |
253 | $ ./widelands --scenario=src/scripting/test/persistence.wmf |
254 | - |
255 | + |
256 | This will result in the creation of various Lua objects. Widelands will then |
257 | immediately safe the game as ``lua_persistence.wgf`` and exit. You can then |
258 | load this game:: |
259 | |
260 | === modified file 'doc/sphinx/source/lua_tribes_workers.rst.org' |
261 | --- doc/sphinx/source/lua_tribes_workers.rst.org 2017-07-03 10:16:59 +0000 |
262 | +++ doc/sphinx/source/lua_tribes_workers.rst.org 2017-08-30 16:47:36 +0000 |
263 | @@ -1,16 +1,9 @@ |
264 | -.. _workers: |
265 | - |
266 | Workers |
267 | ======= |
268 | |
269 | -Workers are defined in their ``init.lua`` file. They also have a corresponding |
270 | -``helptexts.lua`` file that contains their help text. |
271 | -Worker files are placed in ``data/tribes/workers/<tribe_name>/<worker_name>/``. |
272 | - |
273 | -Types of Workers |
274 | ----------------- |
275 | - |
276 | -In addition to the basic worker type, Widelands knows about the following sub types: |
277 | +Workers are created in a warehouse or recruited by a building. Most workers will work in buildings, while special worker types will act as carriers or soldiers. |
278 | + |
279 | +Widelands knows about the following worker types: |
280 | |
281 | .. toctree:: |
282 | :maxdepth: 3 |
283 | @@ -19,11 +12,10 @@ |
284 | |
285 | .. _lua_tribes_workers_common: |
286 | |
287 | - |
288 | Common Worker Properties |
289 | ------------------------ |
290 | |
291 | -Workers are defined with Lua functions called ``new_worker_type{table}``. The contents of ``table`` depend on the type of worker that you are defining. The common properties shared by all workers are: |
292 | +Workers are defined with Lua functions called ``new_<worker_type>_type{table}``. The contents of ``table`` depend on the type of worker that you are defining. The common properties shared by all workers are: |
293 | |
294 | **msgctxt**: The context that Gettext will use to disambiguate the |
295 | translations for strings in this table. |
296 | @@ -69,12 +61,11 @@ |
297 | worker programs. The "idle" and "walk" animations are mandatory. |
298 | |
299 | **programs**: |
300 | - *Optional*. If the worker leaves the building to do his work, the worker |
301 | - programs that define which type of space or resource the worker has to find |
302 | + *Optional*. If the worker leaves the building to do his work, the :ref:`tribes_worker_programs` that define which type of space or resource the worker has to find |
303 | on the map in order to do his work, and what that work is, including any |
304 | animations and sounds played. |
305 | |
306 | -TODO(GunChleoc): create Worker Program Reference |
307 | +.. _lua_tribes_workers_helptexts: |
308 | |
309 | Help Texts |
310 | ---------- |
311 | |
312 | === added file 'doc/sphinx/source/map_object_programs.rst' |
313 | --- doc/sphinx/source/map_object_programs.rst 1970-01-01 00:00:00 +0000 |
314 | +++ doc/sphinx/source/map_object_programs.rst 2017-08-30 16:47:36 +0000 |
315 | @@ -0,0 +1,14 @@ |
316 | +Programs |
317 | +======== |
318 | + |
319 | +Some map object will have special programs that define their behavior. |
320 | +You can describe these programs in their ``init.lua`` files, in the ``programs`` |
321 | +table. Map objects that can have programs are: |
322 | + |
323 | +.. toctree:: |
324 | + :maxdepth: 3 |
325 | + |
326 | + Production Sites <productionsite_program> |
327 | + Workers <autogen_tribes_worker_programs> |
328 | + |
329 | +The programs for Immovables haven't been documented yet. |
330 | |
331 | === modified file 'doc/sphinx/source/map_objects.rst' |
332 | --- doc/sphinx/source/map_objects.rst 2016-10-14 07:02:10 +0000 |
333 | +++ doc/sphinx/source/map_objects.rst 2017-08-30 16:47:36 +0000 |
334 | @@ -7,3 +7,4 @@ |
335 | animations |
336 | autogen_toc_lua_world |
337 | lua_tribes |
338 | + map_object_programs |
339 | |
340 | === modified file 'doc/sphinx/source/productionsite_program.rst' |
341 | --- doc/sphinx/source/productionsite_program.rst 2017-08-27 08:21:51 +0000 |
342 | +++ doc/sphinx/source/productionsite_program.rst 2017-08-30 16:47:36 +0000 |
343 | @@ -76,6 +76,7 @@ |
344 | |
345 | The different command types and the parameters that they take are explained below. |
346 | |
347 | +.. highlight:: default |
348 | |
349 | Command Types |
350 | ^^^^^^^^^^^^^ |
351 | |
352 | === modified file 'src/logic/map_objects/tribes/worker_program.cc' |
353 | --- src/logic/map_objects/tribes/worker_program.cc 2017-01-25 18:55:59 +0000 |
354 | +++ src/logic/map_objects/tribes/worker_program.cc 2017-08-30 16:47:36 +0000 |
355 | @@ -30,6 +30,54 @@ |
356 | #include "sound/sound_handler.h" |
357 | |
358 | namespace Widelands { |
359 | +/* RST |
360 | +.. _tribes_worker_programs: |
361 | + |
362 | +Worker Programs |
363 | +=============== |
364 | + |
365 | +Worker programs are defined in the ``programs`` subtable specified in the worker's :ref:`lua_tribes_workers_common`. |
366 | +Each worker program is a Lua table in itself and defined as a series of command strings. |
367 | +Commands can also have parameters, which are separated from each other by a blank space. |
368 | +These parameters can also have values, which are separated from the parameter name by a colon (:). Finally, programs can call other programs. |
369 | +The table looks like this:: |
370 | + |
371 | + programs = { |
372 | + program_name1 = { |
373 | + "program_name2", |
374 | + "program_name3", |
375 | + } |
376 | + program_name2 = { |
377 | + "command1 parameter1:value1 parameter2:value2", |
378 | + "command2 parameter1", |
379 | + }, |
380 | + program_name3 = { |
381 | + "command3", |
382 | + "command4 parameter1 parameter2 parameter3", |
383 | + } |
384 | + }, |
385 | + |
386 | +The available commands are: |
387 | + |
388 | +- `createware`_ |
389 | +- `mine`_ |
390 | +- `breed`_ |
391 | +- `setbobdescription`_ |
392 | +- `findobject`_ |
393 | +- `findspace`_ |
394 | +- `walk`_ |
395 | +- `animation`_ |
396 | +- `return`_ |
397 | +- `object`_ |
398 | +- `plant`_ |
399 | +- `create_bob`_ |
400 | +- `object remove`_ |
401 | +- `geologist`_ |
402 | +- `geologist_find`_ |
403 | +- `scout`_ |
404 | +- `play_sound`_ |
405 | +- `construct`_ |
406 | +*/ |
407 | |
408 | const WorkerProgram::ParseMap WorkerProgram::parsemap_[] = { |
409 | {"mine", &WorkerProgram::parse_mine}, |
410 | @@ -93,11 +141,27 @@ |
411 | } |
412 | } |
413 | |
414 | +/* RST |
415 | +createware |
416 | +^^^^^^^^^^ |
417 | +.. function:: createware \<ware_name\> |
418 | + |
419 | + :arg string ware_name: The ware type to create, e.g. ``wheat``. |
420 | + |
421 | + The worker will create and carry a ware of the given type. Example:: |
422 | + |
423 | + harvest = { |
424 | + "findobject attrib:ripe_wheat radius:2", |
425 | + "walk object", |
426 | + "play_sound sound/farm scythe 220", |
427 | + "animation harvesting 10000", |
428 | + "object harvest", |
429 | + "animation gathering 4000", |
430 | + "createware wheat", -- Create 1 wheat and start carrying it |
431 | + "return" |
432 | + }, |
433 | +*/ |
434 | /** |
435 | - * createware \<waretype\> |
436 | - * |
437 | - * The worker will create and carry a ware of the given type. |
438 | - * |
439 | * iparam1 = ware index |
440 | */ |
441 | void WorkerProgram::parse_createware(Worker::Action* act, const std::vector<std::string>& cmd) { |
442 | @@ -108,12 +172,30 @@ |
443 | act->iparam1 = tribes_.safe_ware_index(cmd[1]); |
444 | } |
445 | |
446 | +/* RST |
447 | +mine |
448 | +^^^^ |
449 | +.. function:: mine \<resource_name\> \<area\> |
450 | + |
451 | + :arg string resource_name: The map resource to mine, e.g. ``fish``. |
452 | + |
453 | + :arg int area: The radius that is scanned for decreasing the map resource, e.g. ``1``. |
454 | + |
455 | + Mine on the current coordinates that the worker has walked to for resources decrease. |
456 | + Example:: |
457 | + |
458 | + fish = { |
459 | + "findspace size:any radius:7 resource:fish", |
460 | + "walk coords", |
461 | + "play_sound sound/fisher fisher_throw_net 192", |
462 | + "mine fish 1", -- Remove a fish in an area of 1 |
463 | + "animation fishing 3000", |
464 | + "play_sound sound/fisher fisher_pull_net 192", |
465 | + "createware fish", |
466 | + "return" |
467 | + }, |
468 | +*/ |
469 | /** |
470 | - * mine \<resource\> \<area\> |
471 | - * |
472 | - * Mine on the current coordinates (from walk or so) for resources decrease, |
473 | - * go home |
474 | - * |
475 | * iparam1 = area |
476 | * sparam1 = resource |
477 | */ |
478 | @@ -130,12 +212,27 @@ |
479 | throw wexception("Bad area '%s'", cmd[2].c_str()); |
480 | } |
481 | |
482 | +/* RST |
483 | +breed |
484 | +^^^^^ |
485 | +.. function:: breed \<resource_name\> \<area\> |
486 | + |
487 | + :arg string resource_name: The map resource to breed, e.g. ``fish``. |
488 | + |
489 | + :arg int area: The radius that is scanned for increasing the map resource, e.g. ``1``. |
490 | + |
491 | + Breed a resource on the current coordinates that the worker has walked to for |
492 | + resources increase. Example:: |
493 | + |
494 | + breed = { |
495 | + "findspace size:any radius:7 breed resource:fish", |
496 | + "walk coords", |
497 | + "animation freeing 3000", |
498 | + "breed fish 1", -- Add a fish in an area of 1 |
499 | + "return" |
500 | + }, |
501 | +*/ |
502 | /** |
503 | - * breed \<resource\> \<area\> |
504 | - * |
505 | - * Breed on the current coordinates (from walk or so) for resource increase, |
506 | - * go home |
507 | - * |
508 | * iparam1 = area |
509 | * sparam1 = resource |
510 | */ |
511 | @@ -152,12 +249,28 @@ |
512 | throw wexception("Bad area '%s'", cmd[2].c_str()); |
513 | } |
514 | |
515 | +/* RST |
516 | +setbobdescription |
517 | +^^^^^^^^^^^^^^^^^ |
518 | +.. function:: setbobdescription \<bob_name\> [\<bob_name\> ...] |
519 | + |
520 | + :arg string bob_name: The bob type to add to the selection. Specify as many bob |
521 | + types as you want. |
522 | + |
523 | + Randomly select a bob name that can be used in subsequent commands, |
524 | + e.g. create_bob. Used for releasing animals. Example:: |
525 | + |
526 | + release = { |
527 | + "setbobdescription wildboar stag sheep", -- A wildboar, stag or sheep will be selected |
528 | + "findspace size:any radius:3", |
529 | + "walk coords", |
530 | + "animation releasein 2000", |
531 | + "create_bob", |
532 | + "animation releaseout 2000", |
533 | + "return" |
534 | + }, |
535 | +*/ |
536 | /** |
537 | - * setbobdescription \<bob name\> \<bob name\> ... |
538 | - * |
539 | - * Randomly select a bob name that can be used in subsequent commands |
540 | - * (e.g. create_bob). |
541 | - * |
542 | * sparamv = possible bobs |
543 | */ |
544 | void WorkerProgram::parse_setbobdescription(Worker::Action* act, |
545 | @@ -171,22 +284,39 @@ |
546 | act->sparamv.push_back(cmd[i]); |
547 | } |
548 | |
549 | +/* RST |
550 | +findobject |
551 | +^^^^^^^^^^ |
552 | +.. function:: findobject radius:\<distance\> [type:\<map_object_type\>] [attrib:\<attribute\>] |
553 | + |
554 | + :arg int radius: Search for an object within the given radius around the worker. |
555 | + :arg string type: The type of map object to search for. Defaults to ``immovable``. |
556 | + :arg string attrib: The attribute that the map object should possess. |
557 | + |
558 | + Find and select an object based on a number of predicates, which can be specified |
559 | + in arbitrary order. The object can then be used in other commands like ``walk`` |
560 | + or ``object``. Examples:: |
561 | + |
562 | + cut_granite = { |
563 | + "findobject attrib:rocks radius:6", -- Find rocks on the map within a radius of 6 from your building |
564 | + "walk object", -- Now walk to those rocks |
565 | + "play_sound sound/atlanteans/cutting stonecutter 192", |
566 | + "animation hacking 12000", |
567 | + "object shrink", |
568 | + "createware granite", |
569 | + "return" |
570 | + }, |
571 | + |
572 | + hunt = { |
573 | + "findobject type:bob radius:13 attrib:eatable", -- Find an eatable bob (animal) within a radius of 13 from your building |
574 | + "walk object", -- Walk to where the animal is |
575 | + "animation idle 1500", |
576 | + "object remove", |
577 | + "createware meat", |
578 | + "return" |
579 | + }, |
580 | +*/ |
581 | /** |
582 | - * findobject key:value key:value ... |
583 | - * |
584 | - * Find and select an object based on a number of predicates. |
585 | - * The object can be used in other commands like walk or object. |
586 | - * |
587 | - * Predicates: |
588 | - * radius:\<dist\> |
589 | - * Find objects within the given radius |
590 | - * |
591 | - * attrib:\<attribute\> (optional) |
592 | - * Find objects with the given attribute |
593 | - * |
594 | - * type:\<what\> (optional, defaults to immovable) |
595 | - * Find only objects of this type |
596 | - * |
597 | * iparam1 = radius predicate |
598 | * iparam2 = attribute predicate (if >= 0) |
599 | * sparam1 = type |
600 | @@ -226,36 +356,68 @@ |
601 | workarea_info_[act->iparam1].insert(" findobject"); |
602 | } |
603 | |
604 | +/* RST |
605 | +findspace |
606 | +^^^^^^^^^ |
607 | +.. function:: findspace size:\<plot\> radius:\<distance\> [breed] [resource:\<name\>] [avoid:\<immovable_attribute\>] [space] |
608 | + |
609 | + :arg string size: The size or building plot type of the free space. |
610 | + The possible values are: |
611 | + |
612 | + * ``any``: Any size will do. |
613 | + * ``build``: Any building plot. |
614 | + * ``small``: Small building plots only. |
615 | + * ``medium``: Medium building plots only. |
616 | + * ``big``: Big building plots only. |
617 | + * ``mine``: Mining plots only. |
618 | + * ``port``: Port spaces only. |
619 | + |
620 | + :arg int radius: Search for map fields within the given radius around the worker. |
621 | + |
622 | + :arg empty breed: Used in front of ``resource`` only: Also accept fields where the |
623 | + resource has been depleted. Use this when looking for a place for breeding. |
624 | + |
625 | + :arg string resource: A resource to search for. This is mainly intended for |
626 | + fishers and suchlike, for non-detectable resources and default resources. |
627 | + |
628 | + :arg string avoid: A field containing an immovable that has this attribute will |
629 | + not be used. |
630 | + |
631 | + :arg empty space: Find only fields that are walkable in such a way that all |
632 | + neighbors are also walkable (an exception is made if one of the neighboring |
633 | + fields is owned by this worker's location). |
634 | + |
635 | + Find a map field based on a number of predicates. |
636 | + The field can then be used in other commands like ``walk``. Examples:: |
637 | + |
638 | + breed = { |
639 | + "findspace size:any radius:7 breed resource:fish", -- Find any field that can have fish in it for adding a fish to it below |
640 | + "walk coords", |
641 | + "animation freeing 3000", |
642 | + "breed fish 1", |
643 | + "return" |
644 | + }, |
645 | + |
646 | + plant = { |
647 | + "findspace size:any radius:5 avoid:field", -- Don't get in the way of the farmer's crops when planting trees |
648 | + "walk coords", |
649 | + "animation dig 2000", |
650 | + "animation planting 1000", |
651 | + "plant attrib:tree_sapling", |
652 | + "animation water 2000", |
653 | + "return" |
654 | + }, |
655 | + |
656 | + plant = { |
657 | + "findspace size:any radius:2 space", -- The farmer will want to walk to this field again later for harvesting his crop |
658 | + "walk coords", |
659 | + "animation planting 4000", |
660 | + "plant tribe:field_tiny", |
661 | + "animation planting 4000", |
662 | + "return", |
663 | + }, |
664 | +*/ |
665 | /** |
666 | - * findspace key:value key:value ... |
667 | - * |
668 | - * Find a field based on a number of predicates. |
669 | - * The field can later be used in other commands, e.g. walk. |
670 | - * |
671 | - * Predicates: |
672 | - * radius:\<dist\> |
673 | - * Search for fields within the given radius around the worker. |
674 | - * |
675 | - * size:[any|build|small|medium|big|mine|port] |
676 | - * Search for fields with the given amount of space. |
677 | - * |
678 | - * breed |
679 | - * in resource:\<resname\>, also accept fields where the resource has been |
680 | - * depleted. Use this when looking for a place for breeding. Should be used |
681 | - * before resource:\<resname\> |
682 | - * |
683 | - * resource:\<resname\> |
684 | - * Resource to search for. This is mainly intended for fisher and |
685 | - * therelike (non detectable Resources and default resources) |
686 | - * |
687 | - * avoid:\<immovable attribute> |
688 | - * a field containing an immovable with that immovable should not be used |
689 | - * |
690 | - * space |
691 | - * Find only fields that are walkable such that all neighbours |
692 | - * are also walkable (an exception is made if one of the neighbouring |
693 | - * fields is owned by this worker's location). |
694 | - * |
695 | * iparam1 = radius |
696 | * iparam2 = FindNodeSize::sizeXXX |
697 | * iparam3 = whether the "space" flag is set |
698 | @@ -325,15 +487,50 @@ |
699 | workarea_info_[act->iparam1].insert(" findspace"); |
700 | } |
701 | |
702 | +/* RST |
703 | +walk |
704 | +^^^^ |
705 | +.. function:: walk \<destination_type\> |
706 | + |
707 | + :arg string destination_type: Defines where to walk to. Possible destinations are: |
708 | + |
709 | + * ``object``: Walk to a previously found and selected object. |
710 | + * ``coords``: Walk to a previously found and selected field/coordinate. |
711 | + * ``object-or-coords``: Walk to a previously found and selected object if present; |
712 | + otherwise to previously found and selected field/coordinate. |
713 | + |
714 | + Walk to a previously selected destination. Examples:: |
715 | + |
716 | + plant = { |
717 | + "findspace size:any radius:2", |
718 | + "walk coords", -- Walk to the space found by the command above |
719 | + "animation planting 4000", |
720 | + "plant tribe:blackrootfield_tiny", |
721 | + "animation planting 4000", |
722 | + "return" |
723 | + }, |
724 | + |
725 | + harvest = { |
726 | + "findobject attrib:ripe_blackroot radius:2", |
727 | + "walk object", -- Walk to the blackroot field found by the command above |
728 | + "animation harvesting 10000", |
729 | + "object harvest", |
730 | + "animation gathering 2000", |
731 | + "createware blackroot", |
732 | + "return" |
733 | + }, |
734 | + |
735 | + buildship = { |
736 | + "walk object-or-coords", -- Walk to coordinates from 1. or to object from 2. |
737 | + "plant tribe:barbarians_shipconstruction unless object", -- 2. This will create an object for us if we don't have one yet |
738 | + "play_sound sound/sawmill sawmill 230", |
739 | + "animation work 500", |
740 | + "construct", -- 1. This will find a space for us if no object has been planted yet |
741 | + "animation work 5000", |
742 | + "return" |
743 | + }, |
744 | +*/ |
745 | /** |
746 | - * walk \<where\> |
747 | - * |
748 | - * Walk to a previously selected destination. where can be one of: |
749 | - * object walk to a previously found and selected object |
750 | - * coords walk to a previously found and selected field/coordinate |
751 | - * object-or-coords walk to a previously found and selected object if |
752 | - * present; otherwise to previously found and selected coordinate |
753 | - * |
754 | * iparam1 = walkXXX |
755 | */ |
756 | void WorkerProgram::parse_walk(Worker::Action* act, const std::vector<std::string>& cmd) { |
757 | @@ -352,14 +549,28 @@ |
758 | throw wexception("Bad walk destination '%s'", cmd[1].c_str()); |
759 | } |
760 | |
761 | +/* RST |
762 | +animation |
763 | +^^^^^^^^^ |
764 | +.. function:: animation \<name\> \<duration\> |
765 | + |
766 | + :arg string name: The name of the animation. |
767 | + :arg int duration: The time in milliseconds for which the animation will be played. |
768 | + |
769 | + Play the given animation for the given duration. Example:: |
770 | + |
771 | + plantvine = { |
772 | + "findspace size:any radius:1", |
773 | + "walk coords", |
774 | + "animation dig 2000", -- Play a digging animation for 2 seconds. |
775 | + "plant tribe:grapevine_tiny", |
776 | + "animation planting 3000", -- Play a planting animation for 3 seconds. |
777 | + "return" |
778 | + }, |
779 | +*/ |
780 | /** |
781 | - * animation \<name\> \<duration\> |
782 | - * |
783 | - * Play the given animation for the given amount of time. |
784 | - * |
785 | * iparam1 = anim id |
786 | * iparam2 = duration |
787 | - * |
788 | */ |
789 | void WorkerProgram::parse_animation(Worker::Action* act, const std::vector<std::string>& cmd) { |
790 | char* endp; |
791 | @@ -383,9 +594,19 @@ |
792 | throw GameDataError("animation duration must be positive"); |
793 | } |
794 | |
795 | +/* RST |
796 | +return |
797 | +^^^^^^ |
798 | +.. function:: return |
799 | + |
800 | + Return home and then drop any ware we're carrying onto our building's flag. Example:: |
801 | + |
802 | + scout = { |
803 | + "scout 15 75000", |
804 | + "return" -- Go home |
805 | + } |
806 | +*/ |
807 | /** |
808 | - * Return home, drop an ware we're carrying onto our building's flag. |
809 | - * |
810 | * iparam1 = 0: don't drop ware on flag, 1: do drop ware on flag |
811 | */ |
812 | void WorkerProgram::parse_return(Worker::Action* act, const std::vector<std::string>&) { |
813 | @@ -393,11 +614,28 @@ |
814 | act->iparam1 = 1; // drop a ware on our owner's flag |
815 | } |
816 | |
817 | +/* RST |
818 | +object |
819 | +^^^^^^ |
820 | +.. function:: object \<program_name\> |
821 | + |
822 | + :arg string program_name: The name of the program to be executed. |
823 | + |
824 | + Cause the currently selected object to execute its given program. Example:: |
825 | + |
826 | + chop = { |
827 | + "findobject attrib:tree radius:10", |
828 | + "walk object", |
829 | + "play_sound sound/woodcutting fast_woodcutting 250", |
830 | + "animation hacking 10000", |
831 | + "play_sound sound/woodcutting tree-falling 130", |
832 | + "object fall", -- Cause the tree to fall |
833 | + "animation idle 2000", |
834 | + "createware log", |
835 | + "return" |
836 | + } |
837 | +*/ |
838 | /** |
839 | - * object \<command\> |
840 | - * |
841 | - * Cause the currently selected object to execute the given program. |
842 | - * |
843 | * sparam1 = object command name |
844 | */ |
845 | void WorkerProgram::parse_object(Worker::Action* act, const std::vector<std::string>& cmd) { |
846 | @@ -408,12 +646,53 @@ |
847 | act->sparam1 = cmd[1]; |
848 | } |
849 | |
850 | +/* RST |
851 | +plant |
852 | +^^^^^ |
853 | +.. function:: plant \<immmovable_type\> [\<immovable_type\> ...] [unless object] |
854 | + |
855 | + :arg string immovable_type: The immovable to be planted. This can be specified |
856 | + in two different ways: |
857 | + |
858 | + * ``attrib:<attribute>``: Select at random any immovable that has this attribute. |
859 | + * ``tribe:<immovable_name>``: Name a specific immovable to be planted. |
860 | + |
861 | + :arg empty unless object: Do not plant the immovable if it already exists at |
862 | + the current position. |
863 | + |
864 | + Plant one of the given immovables on the current position, taking into account |
865 | + the fertility of the area. Examples:: |
866 | + |
867 | + plant = { |
868 | + "findspace size:any radius:5 avoid:field", |
869 | + "walk coords", |
870 | + "animation dig 2000", |
871 | + "animation planting 1000", |
872 | + "plant attrib:tree_sapling", -- Plant any random sapling tree |
873 | + "animation water 2000", |
874 | + "return" |
875 | + }, |
876 | + |
877 | + plant = { |
878 | + "findspace size:any radius:2 space", |
879 | + "walk coords", |
880 | + "animation planting 4000", |
881 | + "plant tribe:field_tiny", -- Plant the tiny field immovable that the worker's tribe knows about |
882 | + "animation planting 4000", |
883 | + "return", |
884 | + }, |
885 | + |
886 | + buildship = { |
887 | + "walk object-or-coords", |
888 | + "plant tribe:empire_shipconstruction unless object", -- Only create a shipconstruction if we don't already have one |
889 | + "play_sound sound/sawmill sawmill 230", |
890 | + "animation work 500", |
891 | + "construct", |
892 | + "animation work 5000", |
893 | + "return" |
894 | + } |
895 | +*/ |
896 | /** |
897 | - * plant \<immmovable type\> \<immovable type\> ... [unless object] |
898 | - * |
899 | - * Plant one of the given immovables on the current position taking into |
900 | - * account the fertility of the area. |
901 | - * |
902 | * sparamv list of object names |
903 | * iparam1 one of plantXXX |
904 | */ |
905 | @@ -456,27 +735,66 @@ |
906 | } |
907 | } |
908 | |
909 | -/** |
910 | - * Plants a bob (critter usually, maybe also worker later on). The immovable |
911 | - * type must have been selected by a previous command (i.e. setbobdescription). |
912 | - */ |
913 | +/* RST |
914 | +create_bob |
915 | +^^^^^^^^^^ |
916 | +.. function:: create_bob |
917 | + |
918 | + Adds a bob (usually an animal) to the map at the worker's current location. |
919 | + The list of possible bobs must have been selected by a previous command. Example:: |
920 | + |
921 | + release = { |
922 | + "setbobdescription wildboar stag sheep", -- We want to release a wildboar, stag or sheep into the wild |
923 | + "findspace size:any radius:3", |
924 | + "walk coords", |
925 | + "animation releasein 2000", |
926 | + "create_bob", -- Now release a wildboar, stag or sheep into the wild |
927 | + "animation releaseout 2000", |
928 | + "return" |
929 | + } |
930 | +*/ |
931 | void WorkerProgram::parse_create_bob(Worker::Action* act, const std::vector<std::string>&) { |
932 | act->function = &Worker::run_create_bob; |
933 | } |
934 | |
935 | -/** |
936 | - * Simply remove the currently selected object - make no fuss about it. |
937 | - */ |
938 | +/* RST |
939 | +object remove |
940 | +^^^^^^^^^^^^^ |
941 | +.. function:: object remove |
942 | + |
943 | + Remove the currently selected object. Example:: |
944 | + |
945 | + hunt = { |
946 | + "findobject type:bob radius:13 attrib:eatable", -- Select an object to remove |
947 | + "walk object", |
948 | + "animation idle 1000", |
949 | + "object remove", -- The selected eatable map object has been hunted, so remove it from the map |
950 | + "createware meat", |
951 | + "return" |
952 | + } |
953 | +*/ |
954 | void WorkerProgram::parse_removeobject(Worker::Action* act, const std::vector<std::string>&) { |
955 | act->function = &Worker::run_removeobject; |
956 | } |
957 | |
958 | +/* RST |
959 | +geologist |
960 | +^^^^^^^^^ |
961 | +.. function:: geologist \<repetitions\> \<radius\> \<program_name\> |
962 | + |
963 | + :arg int repetitions: The number of times that the geologist will move to a |
964 | + different spot on the map to execute ``program_name``. |
965 | + |
966 | + :arg int radius: The radius of map fields for the geologist not to stray from. |
967 | + |
968 | + Walk around the starting point randomly within a certain radius, and execute |
969 | + your ``program_name`` for some of the fields. Example:: |
970 | + |
971 | + expedition = { |
972 | + "geologist 15 5 search" |
973 | + }, |
974 | +*/ |
975 | /** |
976 | - * geologist \<repeat #\> \<radius\> \<subcommand\> |
977 | - * |
978 | - * Walk around the starting point randomly within a certain radius, |
979 | - * and execute the subcommand for some of the fields. |
980 | - * |
981 | * iparam1 = maximum repeat # |
982 | * iparam2 = radius |
983 | * sparam1 = subcommand |
984 | @@ -500,10 +818,22 @@ |
985 | act->sparam1 = cmd[3]; |
986 | } |
987 | |
988 | -/** |
989 | - * Check resources at the current position, and plant a marker object |
990 | - * when possible. |
991 | - */ |
992 | +/* RST |
993 | +geologist_find |
994 | +^^^^^^^^^^^^^^ |
995 | +.. function:: geologist_find |
996 | + |
997 | + Check the current position for map resources (e.g. coal or water), and plant |
998 | + a marker object when possible. Example:: |
999 | + |
1000 | + search = { |
1001 | + "animation hacking 5000", |
1002 | + "animation idle 2000", |
1003 | + "play_sound sound/hammering geologist_hammer 192", |
1004 | + "animation hacking 3000", |
1005 | + "geologist_find" -- Plant a resource marker at the current location, according to what has been found. |
1006 | + } |
1007 | +*/ |
1008 | void WorkerProgram::parse_geologist_find(Worker::Action* act, const std::vector<std::string>& cmd) { |
1009 | if (cmd.size() != 1) |
1010 | throw wexception("Usage: geologist_find"); |
1011 | @@ -511,11 +841,23 @@ |
1012 | act->function = &Worker::run_geologist_find; |
1013 | } |
1014 | |
1015 | +/* RST |
1016 | +scout |
1017 | +^^^^^ |
1018 | +.. function:: scout \<radius\> \<time\> |
1019 | + |
1020 | + :arg int radius: The radius of map fields for the scout to explore. |
1021 | + |
1022 | + :arg int time: The time in milliseconds that the scout will spend scouting. |
1023 | + |
1024 | + Sends a scout out to run around scouting the area. Example:: |
1025 | + |
1026 | + scout = { |
1027 | + "scout 15 75000", -- Scout within a radius of 15 for 75 seconds |
1028 | + "return" |
1029 | + }, |
1030 | +*/ |
1031 | /** |
1032 | - * scout \<radius\> \<time\> |
1033 | - * |
1034 | - * Sends the scout out to run around scouting the area |
1035 | - * |
1036 | * iparam1 = radius |
1037 | * iparam2 = time |
1038 | */ |
1039 | @@ -528,6 +870,32 @@ |
1040 | act->function = &Worker::run_scout; |
1041 | } |
1042 | |
1043 | +/* RST |
1044 | +play_sound |
1045 | +^^^^^^^^^^ |
1046 | +.. function:: play_sound \<sound_dir\> \<sound_name\> [priority] |
1047 | + |
1048 | + :arg string sound_dir: The directory (folder) that the sound files are in, |
1049 | + relative to the data directory. |
1050 | + :arg string sound_name: The name of the particular sound to play. |
1051 | + There can be multiple sound files to select from at random, e.g. |
1052 | + for `scythe`, we can have `scythe_00.ogg`, `scythe_01.ogg` ... |
1053 | + |
1054 | + :arg int priority: The priority to give this sound. Maximum priority is 255. |
1055 | + |
1056 | + Play a sound effect. Example:: |
1057 | + |
1058 | + harvest = { |
1059 | + "findobject attrib:ripe_wheat radius:2", |
1060 | + "walk object", |
1061 | + "play_sound sound/farm scythe 220", -- Almost certainly play a swishy harvesting sound |
1062 | + "animation harvesting 10000", |
1063 | + "object harvest", |
1064 | + "animation gathering 4000", |
1065 | + "createware wheat", |
1066 | + "return" |
1067 | + } |
1068 | +*/ |
1069 | void WorkerProgram::parse_play_sound(Worker::Action* act, const std::vector<std::string>& cmd) { |
1070 | if (cmd.size() < 3 || cmd.size() > 4) |
1071 | throw wexception("Usage: play_sound <sound_dir> <sound_name> [priority]"); |
1072 | @@ -541,6 +909,24 @@ |
1073 | atoi(cmd[3].c_str()); |
1074 | } |
1075 | |
1076 | +/* RST |
1077 | +construct |
1078 | +^^^^^^^^^ |
1079 | +.. function:: construct |
1080 | + |
1081 | + Give the ware currently held by the worker to the immovable object for construction. |
1082 | + This is used in ship building. Example:: |
1083 | + |
1084 | + buildship = { |
1085 | + "walk object-or-coords", -- Walk to coordinates from 1. or to object from 2. |
1086 | + "plant tribe:barbarians_shipconstruction unless object", -- 2. This will create an object for us if we don't have one yet |
1087 | + "play_sound sound/sawmill sawmill 230", |
1088 | + "animation work 500", |
1089 | + "construct", -- 1. Add the current ware to the shipconstruction. This will find a space for us if no shipconstruction object has been planted yet |
1090 | + "animation work 5000", |
1091 | + "return" |
1092 | + }, |
1093 | +*/ |
1094 | /** |
1095 | * construct |
1096 | * |
Continuous integration builds have changed state:
Travis build 2599. State: passed. Details: https:/ /travis- ci.org/ widelands/ widelands/ builds/ 268974597. /ci.appveyor. com/project/ widelands- dev/widelands/ build/_ widelands_ dev_widelands_ document_ worker_ program- 2421.
Appveyor build 2421. State: success. Details: https:/