generated from remarkablegames/renpy-template
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(examples): add Creator-Defined Statements (CDS)
- Loading branch information
1 parent
90b94c4
commit bbc9ad6
Showing
3 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# https://www.renpy.org/doc/html/cds.html | ||
python early: | ||
def parse_random(lexer): | ||
subblock_lexer = lexer.subblock_lexer() | ||
choices = [] | ||
|
||
while subblock_lexer.advance(): | ||
with subblock_lexer.catch_error(): | ||
statement = subblock_lexer.renpy_statement() | ||
choices.append(statement) | ||
|
||
return choices | ||
|
||
|
||
def next_random(choices): | ||
return renpy.random.choice(choices) | ||
|
||
|
||
def lint_random(parsed_object): | ||
for i in parsed_object: | ||
renpy.error(renpy.check_text_tags(i.what)) | ||
|
||
|
||
renpy.register_statement( | ||
name="random", | ||
block=True, | ||
parse=parse_random, | ||
next=next_random, | ||
lint=lint_random, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
label creator_defined_statements: | ||
|
||
# see `game/examples/_creator_defined_statements.rpy` | ||
random: | ||
"Hello." | ||
"Welcome." | ||
"Can I help you?" | ||
|
||
jump start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters