Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
btpoole
Channel Surfer

Pass variable to translation

Trying to pass a calculated value in a variable to the transition of a rectangle. I have something like the following

y=250
for i=0 to 5 step 1
y=y+100
x=0
m.bground.translation="[x,y]"
end for

 The above will not work, nothing shows up and I suspect it has to do with the "" that are absent around the array. I can't seem to get the quotations or [] to work. Always get an error or warning. Is there a special way to pass a variable in array format?
0 Kudos
3 REPLIES 3
Komag
Roku Guru

Re: Pass variable to translation

Not sure how your background system works, but passing a variable should be straightforward, just consider the variable IS what it stands for, in this case, an integer.

m.bground.translation=[x,y]


You wouldn't put quotation marks in there or else you're creating a string.

But what is m.bground.translation? Is it already an array with two elements that you simply want to redefine here?

In your example, the For loop is pointless, since it will just run six times. You might as well simply set
m.bground.translation=[0, 850]
since that's all you end up with anyway. So I suspect what you have going on and what you really want to do is not set up right way.
0 Kudos
EnTerr
Roku Guru

Re: Pass variable to translation

"Komag" wrote:
You wouldn't put quotation marks in there or else you're creating a string.

But what is m.bground.translation? Is it already an array with two elements that you simply want to redefine here?

He's probably doing RSG. All visual Nodes descend from Group and as such have a .translation property.

The quoting confusion is understandable because when describing scene in XML, properties have to be spec'd in quoted like so
<blah deblah='7' translation="[0, 0]"/>

Numbers are strings, arrays are strings, dictionaries... everybody is a string! Yes, XML sucks. Now that we got that of the way - after a scene is loaded in memory, the node field values are proper data (no more quotes!). If you think assigning a wrong type (string) to a field of type array would cause an error,  then you sir clearly don't know RSG 😛 - it is silent but deadly.

In your example, the For loop is pointless, since it will just run six times. You might as well simply set
m.bground.translation=[0, 850]
since that's all you end up with anyway. So I suspect what you have going on and what you really want to do is not set up right way.

Quite. To do RSG animations, one has to use sdkdoc/Animation+Markup
0 Kudos
btpoole
Channel Surfer

Re: Pass variable to translation

Thanks for both looking over. The m.bground is a rectangle. I am attempting to draw stripes across the screen to make a markupgrid area look different from just a black backgroud.  I guess I could create 5 different rectangles using 5 diffent translations.
Unless there is a way to set a background color of a markupgrid.
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.