Python containing renpy.input, narrator("..."), character calls, renpy.say,
renpy.pause, renpy.display_menu, renpy.with_statement or renpy.call_screen now
runs through loops, try, functions, methods and expressions.
Player
- python.ts: execG/evalG/callG run only the code that may wait (mayBlock);
everything else stays on the synchronous fast path. A waiting call returns a
BlockingCall; outside the generator interpreter it is an explicit error. The
interpreter scope is set aside while the player decides
- engine: drives the generator and answers requests (dialogue, text input with
length/allow/exclude, pause, choice menu, transition, call screen)
- renpy.show/hide/scene, transitions and transforms as Python values,
Character(...) objects, Borders, set_tag_attributes
Converter
- blocking_names() lists game functions that may wait, transitively, and ships
them as game.json "blocking"; character calls are allowed
- hide screen of an unknown screen is harmless; images defined by a parenthesised
expression are supported
Hooked now passes the strict compatibility check (with Tomie and Twisted-Thoughts).
Tests: waiting.py fixture run through the generator interpreter; blocking-name analysis.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
37 lines
776 B
Python
37 lines
776 B
Python
# Source of waiting.ir.json (Python that waits for the player through ask()). Regenerate from backend/ with:
|
|
# python -m tests.make_ir ../frontend/tests/fixtures/waiting.py ../frontend/tests/fixtures/waiting.ir.json
|
|
|
|
|
|
def greet(n):
|
|
name = ask("name?")
|
|
while len(name) < 2:
|
|
name = ask("again")
|
|
return "hi " + name
|
|
|
|
|
|
def helper(k):
|
|
total = 0
|
|
for i in range(k):
|
|
try:
|
|
v = ask("v")
|
|
total += int(v)
|
|
except ValueError:
|
|
continue
|
|
return total
|
|
|
|
|
|
class Q(object):
|
|
def __init__(self):
|
|
self.v = ask("init")
|
|
|
|
def twice(self):
|
|
return ask("x") + ask("y")
|
|
|
|
|
|
result = greet(1) + "!"
|
|
t = helper(3)
|
|
q = Q()
|
|
r2 = q.twice()
|
|
cond = "a" if ask("c") == "yes" else "b"
|
|
plain = len("abc") + 1
|