JBenda / inkcpp

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

Implement Glue correctly #73

Closed JBenda closed 9 months ago

JBenda commented 9 months ago

Now execute after a newline until the next output is generated. Attention! This can result in the double execution of external functions and double calls from observers, since the variable changes, gets restored and changed again

LilithSilver commented 9 months ago

Seems to be working well for me!

At some point there should be an overload on thread->bind() that lets you pass lookaheadSafe = false to disable gluing past a lookahead-unsafe function, like how the C# library does it. But this works for now, for sure (and since before 1.1 or whenever lookaheadSafe was introduced, Ink required EXTERNAL functions to be pure).

JBenda commented 9 months ago

If I understand it correctly, the lookaheadSafe is a flag for a binding, which when true stops looking for a glue, if this function is encountered before execution?

Does it make sense to allow setting a default value or is this just confusing? (Like runner::setLookaheadSafeDefault)

LilithSilver commented 9 months ago

If I understand it correctly, the lookaheadSafe is a flag for a binding, which when true stops looking for a glue, if this function is encountered before execution?

Yep, exactly. If an unsafe EXTERNAL call is encountered, it doesn't run the call and gives up looking ahead, assuming there won't be any glue.

Does it make sense to allow setting a default value or is this just confusing? (Like runner::setLookaheadSafeDefault)

The C# API has lookaheadSafe = false as a default third parameter on Bind. We should probably do similar. I don't think a global default would be useful, since each bound function needs to be considered individually. (For example, a game state getter would be lookaheadSafe, but not a function that plays a sound.)

JBenda commented 9 months ago

I just revised that tags can also break glues. We support lookaheadSafe, now the interface in UE and Python must be adapted accordingly

github-actions[bot] commented 9 months ago

Ink Proof Results

These results are obtained by running the Ink-Proof Testing Suite on the compiled binaries in this pull request.

System Results
Linux x64 130/130 passed
MacOSX DISABLED
Windows x64 DISABLED