feat: conditional "at" transforms in screens and comma-separated ATL statements
`frame at (a if cond else b)` is kept as a choice that the player resolves each time the screen is drawn. An ATL line splits at top-level commas into separate statements, so `zoom 1.2, 0.2` is a zoom followed by a 0.2s pause, as Ren'Py compiles it (two-value properties such as `pos 0.5, 0.5` stay whole). The inert events deselected/unselected, which Ren'Py never sends, are accepted. With the build profile for The Only Doe 0.05 the game now passes the strict script check. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0822c76321
commit
b3f435f416
5 files changed
+85
-3
No files matched your search
@@ -401,6 +401,21 @@ class ScreenParser:
|
||||
spec["atl"] = animation
|
||||
props["at"] = [*props.get("at", []), spec]
|
||||
|
||||
def at_ref(self, source: str, line: Line) -> Node:
|
||||
"""One `at` entry; `(a if cond else b)` picks a transform while the screen is shown."""
|
||||
text = source.strip()
|
||||
if text.startswith("(") and text.endswith(")"):
|
||||
try:
|
||||
tree = ast.parse(text, mode="eval").body
|
||||
except SyntaxError:
|
||||
tree = None
|
||||
if isinstance(tree, ast.IfExp):
|
||||
cond = self.expr(ast.unparse(tree.test), line)
|
||||
if cond is not None:
|
||||
return {"choose": {"c": cond, "then": self.at_ref(ast.unparse(tree.body), line),
|
||||
"else": self.at_ref(ast.unparse(tree.orelse), line)}}
|
||||
return self.transform_ref(source, line)
|
||||
|
||||
def properties(self, words: list[str], line: Line, lenient: bool = False) -> dict[str, Any]:
|
||||
props: dict[str, Any] = {}
|
||||
i = 0
|
||||
@@ -434,7 +449,7 @@ class ScreenParser:
|
||||
i += 1
|
||||
if not more:
|
||||
break
|
||||
props["at"] = [self.transform_ref(item, line) for item in items if item]
|
||||
props["at"] = [self.at_ref(item, line) for item in items if item]
|
||||
continue
|
||||
if glued is not None:
|
||||
source, i = glued, i + 1
|
||||
|
||||
Reference in new issue
Block a user