This repository was archived by the owner on Mar 31, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathExternal Editor API.html
More file actions
136 lines (101 loc) · 5.71 KB
/
External Editor API.html
File metadata and controls
136 lines (101 loc) · 5.71 KB
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
This page describes how our <a href="http://berserk-games.com/knowledgebase/atom-editor-plugin/">Official Atom Plugin</a> API works so that you can write your own plugin for your text editor of choice if Atom does not suit your needs. The plugin communicates with Tabletop Simulator via two localhost TCP connections - one for each system acting as a server and the other as a client and vice versa. All communication messages are JSON.
<h1>Tabletop Simulator as the Server</h1>
TTS listens for incoming localhost TCP connections on port 39999.
<h2>Get Lua Scripts</h2>
Atom sends a JSON message with an ID of 0.
<font face="monospace">
<blockquote>{
"messageID": 0
}</blockquote>
</font>
<br />TTS sends back a JSON message with an ID of 0 and an array of the Lua Scripts.
<font face="monospace">
<blockquote>{
"messageID": 0,
"scriptStates": [
{
"name": "Global",
"guid": "-1",
"script": "..."
},
{
"name": "BlackJack Dealer's Deck",
"guid": "a0b2d5",
"script": "..."
},
...
]
<br />}</blockquote>
</font>
<h2>Save & Play</h2>
Atom sends a JSON message with an ID of 1 and an array of the Lua Scripts.
<font face="monospace">
<blockquote>{
"messageID": 1,
"scriptStates": [
{
"guid": "-1",
"script": "..."
},
{
"guid": "a0b2d5",
"script": "..."
},
...
]
<br/>}</blockquote>
</font>
<h1>Atom as the Server</h1>
Atom listens for incoming localhost TCP connections on port 39998.
<h2>Pushing New Object</h2>
When clicking on "Lua Editor" in the right click contextual menu in-game for an Object that doesn't have a Lua Script yet, it will try to open a new tab in Atom for this Object before falling back to the in-game editor if Atom is not running. TTS sends a JSON message with an ID of 0 and the new Object.
<font face="monospace">
<blockquote>{
"messageID": 0,
"scriptStates": [
{
"name": "Chess Pawn",
"guid": "db3f06",
"script": ""
}
]
<br />}</blockquote>
</font>
<h2>Loading a New Game</h2>
When loading a new game in TTS, TTS will automatically send all the Lua Scripts from the new game to Atom. TTS sends a JSON message with an ID of 1 and an array of the Lua Scripts.
<font face="monospace">
<blockquote>{
"messageID": 1,
"scriptStates": [
{
"name": "Global",
"guid": "-1",
"script": "..."
},
{
"name": "BlackJack Dealer's Deck",
"guid": "a0b2d5",
"script": "..."
},
...
]
<br />}</blockquote>
</font>
<h2>Print/Debug Messages</h2>
TTS sends all <a href="http://berserk-games.com/knowledgebase/api/#print"><font face="monospace">print()</font></a> messages to Atom to be displayed in Atom's console (<font face="monospace">ctrl + alt + i</font>). TTS sends a JSON message with an ID of 2 and the message.
<font face="monospace">
<blockquote>{
"messageID": 2,
"message": "Hit player! White"
}</blockquote>
</font>
<h2>Error Messages</h2>
TTS sends all Lua error messages to Atom to be displayed in Atom's console (<font face="monospace">ctrl + alt + i</font>). TTS sends a JSON message with an ID of 3 and the error message.
<font face="monospace">
<blockquote>{
"messageID": 3,
"error": "chunk_0:(36,4-8): unexpected symbol near 'deck'",
"guid": "-1",
"errorMessagePrefix": "Error in Global Script: "
}</blockquote>
</font>