-
Notifications
You must be signed in to change notification settings - Fork 3
/
yarn_spinner.proto
161 lines (123 loc) · 4.78 KB
/
yarn_spinner.proto
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
syntax = "proto3";
package Yarn;
// Copyright (c) 2015-2023 Secret Lab Pty. Ltd. and Yarn Spinner contributors.
// This file is copied from YarnSpinner/YarnSpinner@20036dc, which is licensed MIT.
// It should be updated if Yarn makes any changes to their protocol for compiled code.
// A complete Yarn program.
message Program {
// The name of the program.
string name = 1;
// The collection of nodes in this program.
map<string, Node> nodes = 2;
// The collection of initial values for variables; if a PUSH_VARIABLE
// instruction is run, and the value is not found in the storage, this
// value will be used
map<string, Operand> initial_values = 3;
}
// A collection of instructions
message Node {
// The name of this node.
string name = 1;
// The list of instructions in this node.
repeated Instruction instructions = 2;
// A jump table, mapping the names of labels to positions in the
// instructions list.
map<string, int32> labels = 3;
// The tags associated with this node.
repeated string tags = 4;
// the entry in the program's string table that contains the original
// text of this node; null if this is not available
string sourceTextStringID = 5;
repeated Header headers = 6;
}
message Header {
string key = 1;
string value = 2;
}
// A single Yarn instruction.
message Instruction {
// The operation that this instruction will perform.
OpCode opcode = 1;
// The list of operands, if any, that this instruction uses.
repeated Operand operands = 2;
// The type of instruction that this is.
enum OpCode {
// Jumps to a named position in the node.
// opA = string: label name
JUMP_TO = 0;
// Peeks a string from stack, and jumps to that named position in
// the node.
// No operands.
JUMP = 1;
// Delivers a string ID to the client.
// opA = string: string ID
RUN_LINE = 2;
// Delivers a command to the client.
// opA = string: command text
RUN_COMMAND = 3;
// Adds an entry to the option list (see ShowOptions).
// - opA = string: string ID for option to add
// - opB = string: destination to go to if this option is selected
// - opC = number: number of expressions on the stack to insert
// into the line
// - opD = bool: whether the option has a condition on it (in which
// case a value should be popped off the stack and used to signal
// the game that the option should be not available)
ADD_OPTION = 4;
// Presents the current list of options to the client, then clears
// the list. The most recently selected option will be on the top
// of the stack when execution resumes.
// No operands.
SHOW_OPTIONS = 5;
// Pushes a string onto the stack.
// opA = string: the string to push to the stack.
PUSH_STRING = 6;
// Pushes a floating point number onto the stack.
// opA = float: number to push to stack
PUSH_FLOAT = 7;
// Pushes a boolean onto the stack.
// opA = bool: the bool to push to stack
PUSH_BOOL = 8;
// Pushes a null value onto the stack.
// No operands.
PUSH_NULL = 9;
// Jumps to the named position in the the node, if the top of the
// stack is not null, zero or false.
// opA = string: label name
JUMP_IF_FALSE = 10;
// Discards top of stack.
// No operands.
POP = 11;
// Calls a function in the client. Pops as many arguments as the
// client indicates the function receives, and the result (if any)
// is pushed to the stack.
// opA = string: name of the function
CALL_FUNC = 12;
// Pushes the contents of a variable onto the stack.
// opA = name of variable
PUSH_VARIABLE = 13;
// Stores the contents of the top of the stack in the named
// variable.
// opA = name of variable
STORE_VARIABLE = 14;
// Stops execution of the program.
// No operands.
STOP = 15;
// Pops a string off the top of the stack, and runs the node with
// that name.
// No operands.
RUN_NODE = 16;
}
}
// A value used by an Instruction.
message Operand {
// The type of operand this is.
oneof value {
// A string.
string string_value = 1;
// A boolean (true or false).
bool bool_value = 2;
// A floating point number.
float float_value = 3;
}
}