-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.txt
104 lines (76 loc) · 2.83 KB
/
README.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
== Shell for Civ4 ==
This extensions expands Civ4 by a local TCP interface.
You can send arbitary python commands to the running instance.
== Short description for PBStats variant (Shell access to Pitboss server) ==
If shell is enabled in pbSettings.json type
'python [-u] Pyconsole [port]'
into a terminal to connect you to the running game instance.
== Minimal working example: Pyconsole mod ==
1. Copy Mods/Pyconsole into your Civ4:BTS Mods folder.
2. Start Civ4 with Pyconsole mod, i.e.
'wine Civ4BeyondSword.exe "mod= Pyconsole"'
3. Open terimnal window and type
> cd [..]/PBStats/test/Pyconsole
> python -u Pyconsole 3333
into a local terminal window.
4. Run 'test' in the new subshell to
send a few commands to the Civ4 instance.
5. (Optional/Win-Only) Install pyreadline for
command history, etc, https://pypi.python.org/pypi/pyreadline
Pip command: pip install pyreadline
== Integration of shell into your mod ==
1. Place Civ4ShellBackend.py into [Your mod]\Assets\Python
2. Add the following lines into your CvEventManager.py:
# At head of file:
CIV4_SHELL = True
if CIV4_SHELL:
import Civ4ShellBackend
civ4Console = Civ4ShellBackend.Server(tcp_port=3333)
# In CvEventManager.__init__:
if CIV4_SHELL:
self.glob = globals()
self.loc = locals()
civ4Console.init()
# In CvEventManager.onGameUpdate
if CIV4_SHELL:
civ4Console.update(self.glob, self.loc)
== Example usage of Pitboss variant ==
a) Call Python code directly to finish turn for Playerid X .
> python Pyconsole 3333
> print(gc.getPlayer(X).getName())
> gc.getGame().setActivePlayer(X, False)
> CyMessageControl().sendTurnComplete()
> gc.getGame().setActivePlayer(-1, False) # Default for PB Host is -1
> bye
b) Use predifined macro for above task. (Type 'help' to get a list of all commands)
> python Pyconsole 3333
> pb_end_turn X
> bye
c) List saves, edit config and restart server with new save.
> python Pyconsole 3333
> list PlayerX
> list Logoff.*P0
> config edit save/filename=Logoff_P0_PlayerX_T1507924088.CivBeyondSwordSave
> config show
> pb_start
> bye
d) List 10 saves, and restart with second save of list
> python Pyconsole 3333
> list 10
> load 2
> pb_start
> bye
e) Use 'names' to list ids of XML defined enums and
change plot feature.
> python Pyconsole 3333
> p = CyMap().plot(0,0)
> p.getFeatureType()
> names Feature
[list of features]
> doc p1.setFeatureType
> p.setFeatureType(eNewValue, iVariety)
> bye
== Known bugs ==
• If the command needs too long to forge the reply, the output
will only be printed after sending the next command.
• Not fully compatible with Python3