Creating a label in a user-defined statement

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
User avatar
valeatory
Regular
Posts: 36
Joined: Mon Apr 23, 2007 3:01 pm
Projects: Nightglove Institute, Monstrata Fracture
Organization: Astralore Games
Tumblr: valeatory
itch: astralore
Location: America
Contact:

Creating a label in a user-defined statement

#1 Post by valeatory »

I'm making an event system for our project and thought it would be easier on the people writing the events if they could put all of the information on an event in a header at the top of it, rather than away from the event in a separate event selection method - so I've tried out making that work with a user defined statement.

I think I've mostly gotten it working (and I've attached the project at the bottom for anyone who's interested in checking out how it's set up) but one thing I'd prefer is to remove the redundancy in the event and label names by having the event header create the label itself.

Currently, the event looks like this, with the would-be generated label name typed manually by the writer:

Code: Select all

event eileen meeting1:
    option "Talk to Eileen"
    desc "She seems to be available right now."
    conditions:
        location in ("common room", "library")
        is_before_class or is_free_time

label event_eileen_meeting1:
    "You talk with Eileen for a while."
However, I'd prefer to get the event to look like this, with the label name typed only once.

Code: Select all

event eileen meeting1:
    option "Talk to Eileen"
    desc "She seems to be available right now."
    conditions:
        location in ("common room", "library")
        is_before_class or is_free_time
    label:
        "You talk with Eileen for a while."
Is something like that possible?
Attachments
x Event System.zip
(753.64 KiB) Downloaded 20 times
Nightglove Institute - Kidnapped students, forced to train to be secret agents and assassins!
Monstrata Fracture - Date cute monsters! But will you risk destabilizing the human plane of existence?

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: Creating a label in a user-defined statement

#2 Post by Remix »

Weird, you are doing something rather similar to what I just started doing within an old time-of-day event handler review and improve.
I had actually opted to go with registering the events during the 'parse' call rather than 'execute' because I thought Ren'py might not execute them all prior to the player actually reaching them... might change that.

Anyway, my thoughts:

Code: Select all

label some_label:
    register event: <--- creator defined block - just a call to start the parse - all others vals in the block
         # various conditions and values
Putting the Creator Defined Statement inside the label *should* allow us to use renpy translate features to basically determine the label name where the line exists using something like:

Code: Select all

label_name = "_".join( renpy.game.context().translate_identifier.split("_")[:-1] )
# everything up to the last underscore should be the label name

# within the parse call, renpy.game.context().translate_identifier *should* hold a string identifier for the line
# that ren'py was reading (the register event: line) when it made the call, something like:
# some_label_6557f7a44 
Still Ren'py-esque and feasibly should work though still not tested
Frameworks & Scriptlets:

Post Reply

Who is online

Users browsing this forum: IrisColt