JBenda / inkcpp

Inkle Ink C++ Runtime with JSON>Binary Compiler
MIT License
70 stars 13 forks source link

Variables are not re-evaluated after lookahead #70

Closed LilithSilver closed 9 months ago

LilithSilver commented 9 months ago

Got another one!

It seems variables might not be re-evaluated properly after a lookahead. For example:

EXTERNAL GET_LINE_COUNT()

Line count: {GET_LINE_COUNT()}

Line count: {GET_LINE_COUNT()}

~ temp should_execute_before = GET_LINE_COUNT()

Line count: {should_execute_before}

-> DONE

Given a GET_LINE_COUNT which prints however many lines have been consumed, inkcpp prints:

Line count: 0
Line count: 1
Line count: 1

Where the C# package prints:

Line count: 0
Line count: 1
Line count: 2

(even with the function bound as lookahead-safe). This can cause issues in games which have a state change after a line is printed.

Here's a unit test.. I've replicated the unit test in C# and confirmed that it produces the second output.

Many thanks for your hard work on this package, by the way!

JBenda commented 9 months ago

Thanks for providing a test case :+1

JBenda commented 9 months ago

The problem was that we only returned one instruction after a look ahead ... Now we do as Inkle specifies, with double external execution and an observer who gets called multiple times for the same change ^^

You are welcome to check the PR #73