What is the python equivalent of the Ren'Py label statement ?
I found myself in need of creating a series of dynamic label statements inside a python custom class. Is it even possible to do so ?
So what happens is that I created a custom-defined menu function that have a list of dynamic options for the player to choose. Once the player clicked a option, it will automatically jump to a label corresponding to that option. The options are all dynamic, based on variables. So the corresponding labels should also be dynamic.
I could get around this by writing all the label statements with argument inputs in Ren'Py script. But it's gonna take too much codes, and many label statements would have a bunch of repeated codes in it. I think the more elegant way to do it is to write the label statements in the python custom class. But I couldn't find out if there's a python equivalent for the label statement.
Any suggestions would be much appreciated.
How to create a label statement in a python custom class ?
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.
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.
Re: How to create a label statement in a python custom class ?
What those labels should do - some calculations, oparations with screens or..? In this case you might need to create a function, that will do all that stuff using arguments passed in.
Or they should show some npc's, their talkings, some animation? Then you either need several kinds of labels to pass in some variables (what bg and what character should be shown, what (s)he will say, etc), or need one label to pass in a bunch of statements. Either way you can achieve this with ordinary labels (like, if you pass a list of statements to the label, then you can make a loop in it to iterate through this list).
Re: How to create a label statement in a python custom class ?
Agreed that, based on OP's post, I don't see the point of dynamic label declarations. It's hard to see why that's necessary in the abstract. It would be easier to give helpful advice if this were more specific -- like, are you building a battle system? Going on dates? etc. By specific, I mean, like. Code.
Re: How to create a label statement in a python custom class ?
Per your suggestion, I've tried defining another custom class to essentially replace most of the functionality of those label statements. And the codes are indeed much cleaner, even though I still have to create a long list of label names. But it worked !Alex wrote: ↑Thu Nov 14, 2019 6:13 pmWhat those labels should do - some calculations, oparations with screens or..? In this case you might need to create a function, that will do all that stuff using arguments passed in.
Or they should show some npc's, their talkings, some animation? Then you either need several kinds of labels to pass in some variables (what bg and what character should be shown, what (s)he will say, etc), or need one label to pass in a bunch of statements. Either way you can achieve this with ordinary labels (like, if you pass a list of statements to the label, then you can make a loop in it to iterate through this list).
Thank you for your help.
A follow up question. there's not a python equivalent of the label statement, after all ?
Who is online
Users browsing this forum: No registered users