[Resolved] Passing a variable into User Defined Displayable

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
Unin
Regular
Posts: 54
Joined: Wed Sep 01, 2010 8:08 pm
Location: Florida
Contact:

[Resolved] Passing a variable into User Defined Displayable

#1 Post by Unin »

I'd like to be able to pass a variable into a User Defined Displayable (or call an external variable from a UDD class) such that I can change a UDD on the fly without having to hard code it each time (or at least plug it in upon definition or screen initiation so I don't have to copy/paste code each time.)

For example, perhaps passing in a set of 2 coordinate pairs to draw a line displayable, such that at different points in my game the line could connect different pairs of points. I know this is trivially easy to achieve by just resizing and reorienting the line as a normal displayable, but I'd like to be able to do it as a UDD to better understand UDD and achieve more complex renders.

If anyone could explain (or better show me) how, I would be really grateful.
Last edited by Unin on Sun Feb 16, 2014 10:59 pm, edited 1 time in total.

Asceai
Eileen-Class Veteran
Posts: 1258
Joined: Fri Sep 21, 2007 7:13 am
Projects: a battle engine
Contact:

Re: Passing a variable into a User Defined Displayable

#2 Post by Asceai »

I haven't tried this, but surely you can just modify fields in the UDD object on the fly?

$udd = UDD()
$ui.add(udd)
...
$udd.variable = 1

Unin
Regular
Posts: 54
Joined: Wed Sep 01, 2010 8:08 pm
Location: Florida
Contact:

Re: Passing a variable into a User Defined Displayable

#3 Post by Unin »

interesting. I was displaying my UDD on separate screens, and did not even consider ui.add
looks like this will work. thank you.

Post Reply

Who is online

Users browsing this forum: Google [Bot]