@@ -72,10 +72,13 @@ def __find_label(self, label_key):
7272 f"The current node `{ self .current_node } ` does not have a label named `{ label_key } " )
7373
7474 def __find_expressions (self , operand ):
75- # TODO: implement this functionality
76- if int (operand .float_value ) != 0 :
77- raise Exception (
78- f"Yarn stories with interpolated inline expressions are not yet supported." )
75+ params_amount = operand .float_value
76+
77+ params = []
78+ while params_amount > 0 :
79+ params .insert (0 , self ._vm_data_stack .pop (0 ))
80+ params_amount -= 1
81+ return params
7982
8083 def __debug_log (self , msg , ** kwargs ):
8184 if self ._enable_tracing :
@@ -202,10 +205,9 @@ def __run_line(self, instruction):
202205
203206 # if this instruction has a second operand, it's the number of expressions
204207 # on the line that need to be evaluated.
208+ line_substitutions = []
205209 if len (instruction .operands ) > 1 :
206- line_substitutions = self .__find_expressions (
207- instruction .operands [1 ])
208- # TODO: implement substitutions
210+ line_substitutions = self .__find_expressions (instruction .operands [1 ])
209211
210212 if self ._experimental_newlines :
211213 # attempt to add a newlines if the last thing we did was run a line
@@ -219,7 +221,13 @@ def __run_line(self, instruction):
219221 for _i in range (diff - 1 ):
220222 self ._line_buffer .append ('' )
221223
222- self ._line_buffer .append (self .__lookup_string (string_key ))
224+ self ._line_buffer .append (
225+ self ._make_line_substitutions (
226+ self .__lookup_string (string_key ), line_substitutions ))
227+
228+ @staticmethod
229+ def _make_line_substitutions (line , substitutions ):
230+ return line .format (* substitutions )
223231
224232 def __run_command (self , instruction ):
225233 # split the command specifier by spaces, ignoring spaces
@@ -265,7 +273,6 @@ def __add_option(self, instruction):
265273 if len (instruction .operands ) > 2 :
266274 line_substitutions = self .__find_expressions (
267275 instruction .operands [2 ])
268- # TODO: implement substitutions
269276
270277 self ._option_buffer .append ({
271278 'index' : len (self ._option_buffer ),
0 commit comments