You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: _sources/bots/programOverview.rst.txt
+15-14Lines changed: 15 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,37 +9,38 @@ At start, you are in full control of the program.
9
9
Initialization
10
10
^^^^^^^^^^^^^^
11
11
12
-
- You need to change current working directory to the ``bin`` directory in the game installation.
13
-
Without it, the game will be unable to load maps and assets (even if it might happen to load the shared library).
12
+
1) Change current working directory to the ``bin`` directory in the game installation.
13
+
Without it, the game will be unable to load maps and assets (even if it might happen to load the shared library).
14
14
15
15
.. warning::
16
-
Do *not* change current working directory from now on.
16
+
Do *not* change current working directory afterwards.
17
17
18
-
- Next, you load the shared library.
18
+
2) Load the shared library.
19
19
20
20
.. tab-set::
21
21
:sync-group: language
22
22
23
23
.. tab-item:: Python
24
24
:sync: python
25
25
26
-
TODO
26
+
Class UwapiLibrary is responsible for loading the library.
27
+
This is done in the ``main.py``.
27
28
28
29
.. tab-item:: C#
29
30
:sync: csharp
30
31
31
-
The library is automatically loaded when you first access the global ``Game`` object.
32
+
The library is automatically loaded when you first access the global ``Events`` object.
32
33
This happens inside the ``Bot`` constructor.
33
34
34
-
- Setup all your callbacks now.
35
-
You may also set some parameters for the connection.
35
+
3) Setup all callbacks now.
36
+
You may also set some parameters for the connection.
36
37
37
38
Connect
38
39
^^^^^^^
39
40
There are multiple ways to connect to a game server.
40
41
The usual approach is to first try reconnecting, in case the game has crashed previously.
41
-
Second, you connect to an existing server using the parameters provided in the environment variables, if any.
42
-
Third, you spin up your own server.
42
+
Second, you connect to an existing game server using parameters provided in the environment, if any.
43
+
Third, you spin up your own game server.
43
44
44
45
Alternatively, you may implement your own logic to determine how to connect to a server.
45
46
@@ -54,10 +55,10 @@ Notably, the ``Update`` callback is periodically called, no matter the game stat
54
55
This is where you keep track of the state of the game, and perform any of your actions.
55
56
56
57
.. warning::
57
-
The ``Update`` callback, and some others, may be called before the game has actually started (eg. in ``Session``), or when the map is not yet ``Loaded``.
58
-
Be mindful of what operations are valid in these circumstances.
58
+
The ``Update`` callback, and some others, may be called before the game has actually started (eg. in ``Session``), or when the map is not yet ``Loaded``.
59
+
Be mindful of what operations are valid in these circumstances.
59
60
60
-
You may prematurely close the connection with the ``Disconnect`` function.
61
+
You may prematurely close the connection with the ``disconnect`` function.
61
62
This will do a graceful closing of the connection, that is, you will get some additional callbacks called.
62
63
After that the connect function will return.
63
64
@@ -82,7 +83,7 @@ The construction will appear only after the game server has processed the reques
82
83
It is recommended to wait several ticks between these kinds of actions, to avoid placing same construction multiple times in different places.
83
84
84
85
.. note::
85
-
Test your program over a real network, not just localhost.
86
+
Test your program over a real network, not just localhost.
0 commit comments