Can you create custom "on" statements for transforms?

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
Tess
Regular
Posts: 59
Joined: Thu Aug 04, 2022 3:43 pm
Projects: The Songbird Guild
Organization: Yurisoft
Github: wainwt2
Discord: Tess#7782
Contact:

Can you create custom "on" statements for transforms?

#1 Post by Tess »

I have a screen with a handful of characters on it and a display I'd like to move from character to character as the player selects them.

Right now I have something kinda working, the process goes like this:
  • Create an instance of a class I made called Moving_Value,
  • Create a transform with a function call that updates the Moving_Value with its st,
  • Place the displayable I want to manipulate "at" that transform,
  • When the Select_Character() function is called, it also calls a function in Moving_Value called Set_Target(), which takes the new position and a time to take as arguments
It works, but I've found it hard to scale as I try to add more features due to the number of steps involved, so I'm trying to find a way to simplify the process.

Which gets back to the original question. Idk if this is even possible, but I've noticed that if I add events like "on new_char_selected" to a transform it technically doesn't throw any errors.

Code: Select all

transform display_trans:
	on idle:
		#Do thing
	on hover:
		#Do thing
	on new_char_selected:
		#Is it even possible to get here?
The thing I'm not sure of is how you'd call those extra events beyond "idle", "hover", etc or if it's even possible. I noticed the Transform class has a function called "set_transform_event", but calling that on a transform passed through a function doesn't seem to do anything, at least not the way I was using it.

Post Reply

Who is online

Users browsing this forum: voluorem