|
| 1 | +syntax = "proto3"; |
| 2 | +package Yarn; |
| 3 | + |
| 4 | +// Copyright (c) 2015-2017 Secret Lab Pty. Ltd. and Yarn Spinner contributors. |
| 5 | +// This file is copied from YarnSpinner/YarnSpinner@fb2d6db, which is licensed MIT. |
| 6 | +// It should be updated if Yarn makes any changes to their protocol for compiled code. |
| 7 | + |
| 8 | +// A complete Yarn program. |
| 9 | +message Program { |
| 10 | + |
| 11 | + // The name of the program. |
| 12 | + string name = 1; |
| 13 | + |
| 14 | + // The collection of nodes in this program. |
| 15 | + map<string, Node> nodes = 2; |
| 16 | +} |
| 17 | + |
| 18 | +// A collection of instructions |
| 19 | +message Node { |
| 20 | + // The name of this node. |
| 21 | + string name = 1; |
| 22 | + |
| 23 | + // The list of instructions in this node. |
| 24 | + repeated Instruction instructions = 2; |
| 25 | + |
| 26 | + // A jump table, mapping the names of labels to positions in the |
| 27 | + // instructions list. |
| 28 | + map<string, int32> labels = 3; |
| 29 | + |
| 30 | + // The tags associated with this node. |
| 31 | + repeated string tags = 4; |
| 32 | + |
| 33 | + // the entry in the program's string table that contains the original |
| 34 | + // text of this node; null if this is not available |
| 35 | + string sourceTextStringID = 5; |
| 36 | +} |
| 37 | + |
| 38 | +// A single Yarn instruction. |
| 39 | +message Instruction { |
| 40 | + |
| 41 | + // The operation that this instruction will perform. |
| 42 | + OpCode opcode = 1; |
| 43 | + |
| 44 | + // The list of operands, if any, that this instruction uses. |
| 45 | + repeated Operand operands = 2; |
| 46 | + |
| 47 | + // The type of instruction that this is. |
| 48 | + enum OpCode { |
| 49 | + |
| 50 | + // Jumps to a named position in the node. |
| 51 | + // opA = string: label name |
| 52 | + JUMP_TO = 0; |
| 53 | + |
| 54 | + // Peeks a string from stack, and jumps to that named position in |
| 55 | + // the node. |
| 56 | + // No operands. |
| 57 | + JUMP = 1; |
| 58 | + |
| 59 | + // Delivers a string ID to the client. |
| 60 | + // opA = string: string ID |
| 61 | + RUN_LINE = 2; |
| 62 | + |
| 63 | + // Delivers a command to the client. |
| 64 | + // opA = string: command text |
| 65 | + RUN_COMMAND = 3; |
| 66 | + |
| 67 | + // Adds an entry to the option list (see ShowOptions). |
| 68 | + // opA = string: string ID for option to add |
| 69 | + ADD_OPTION = 4; |
| 70 | + |
| 71 | + // Presents the current list of options to the client, then clears |
| 72 | + // the list. The most recently selected option will be on the top |
| 73 | + // of the stack when execution resumes. |
| 74 | + // No operands. |
| 75 | + SHOW_OPTIONS = 5; |
| 76 | + |
| 77 | + // Pushes a string onto the stack. |
| 78 | + // opA = string: the string to push to the stack. |
| 79 | + PUSH_STRING = 6; |
| 80 | + |
| 81 | + // Pushes a floating point number onto the stack. |
| 82 | + // opA = float: number to push to stack |
| 83 | + PUSH_FLOAT = 7; |
| 84 | + |
| 85 | + // Pushes a boolean onto the stack. |
| 86 | + // opA = bool: the bool to push to stack |
| 87 | + PUSH_BOOL = 8; |
| 88 | + |
| 89 | + // Pushes a null value onto the stack. |
| 90 | + // No operands. |
| 91 | + PUSH_NULL = 9; |
| 92 | + |
| 93 | + // Jumps to the named position in the the node, if the top of the |
| 94 | + // stack is not null, zero or false. |
| 95 | + // opA = string: label name |
| 96 | + JUMP_IF_FALSE = 10; |
| 97 | + |
| 98 | + // Discards top of stack. |
| 99 | + // No operands. |
| 100 | + POP = 11; |
| 101 | + |
| 102 | + // Calls a function in the client. Pops as many arguments as the |
| 103 | + // client indicates the function receives, and the result (if any) |
| 104 | + // is pushed to the stack. |
| 105 | + |
| 106 | + // opA = string: name of the function |
| 107 | + CALL_FUNC = 12; |
| 108 | + |
| 109 | + // Pushes the contents of a variable onto the stack. |
| 110 | + // opA = name of variable |
| 111 | + PUSH_VARIABLE = 13; |
| 112 | + |
| 113 | + // Stores the contents of the top of the stack in the named |
| 114 | + // variable. |
| 115 | + // opA = name of variable |
| 116 | + STORE_VARIABLE = 14; |
| 117 | + |
| 118 | + // Stops execution of the program. |
| 119 | + // No operands. |
| 120 | + STOP = 15; |
| 121 | + |
| 122 | + // Run the node whose name is at the top of the stack. |
| 123 | + // No operands. |
| 124 | + RUN_NODE = 16; |
| 125 | + } |
| 126 | +} |
| 127 | + |
| 128 | +// A value used by an Instruction. |
| 129 | +message Operand { |
| 130 | + |
| 131 | + // The type of operand this is. |
| 132 | + oneof value { |
| 133 | + |
| 134 | + // A string. |
| 135 | + string string_value = 1; |
| 136 | + |
| 137 | + // A boolean (true or false). |
| 138 | + bool bool_value = 2; |
| 139 | + |
| 140 | + // A floating point number. |
| 141 | + float float_value = 3; |
| 142 | + } |
| 143 | +} |
0 commit comments