Page 1 of 1

[Resolved] Passing a variable into User Defined Displayable

Posted: Tue Feb 11, 2014 10:26 pm
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.

Re: Passing a variable into a User Defined Displayable

Posted: Tue Feb 11, 2014 10:32 pm
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

Re: Passing a variable into a User Defined Displayable

Posted: Sun Feb 16, 2014 10:59 pm
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.