Checking if a label will accept an argument

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
goldo
Regular
Posts: 124
Joined: Mon Jan 23, 2017 8:23 am
Contact:

Checking if a label will accept an argument

#1 Post by goldo »

Hi,

I want to make a renpy call to a label with an argument as error-proof as possible. The labels will be written by other people, so I have no way to make sure they include an argument or not.

I am trying to work around the following not working in renpy:

Code: Select all

python:
	try:
		renpy.call(lbl, arg)
	except ScriptError:
		renpy.say("", "Label not found or doesn't accept arguments.")
I can use this to make sure the label exists:

Code: Select all

if renpy.has_label(lbl):
	call expression lbl pass arg
else:
	"This label doesn't exist."
But how can I check if the label allows for an argument without throwing an error?

goldo
Regular
Posts: 124
Joined: Mon Jan 23, 2017 8:23 am
Contact:

Re: Checking if a label will accept an argument

#2 Post by goldo »

I guess it can't be done then?

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Checking if a label will accept an argument

#3 Post by trooper6 »

Why are other people writing labels that you don't know what they are?
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

goldo
Regular
Posts: 124
Joined: Mon Jan 23, 2017 8:23 am
Contact:

Re: Checking if a label will accept an argument

#4 Post by goldo »

I am trying to enable some simple form of modding in the shape of adding events written in Ren'py. I don't have to block potential errors and push that responsibility onto the modders, but some of them are new to this stuff and one of them will most likely forget to use the argument... Breaking things when I 'd rather keep the game flow going.

Post Reply

Who is online

Users browsing this forum: Google [Bot]