Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
EnTerr
Level 9

Re: trying to print a simple array value (string), not worki

"Komag" wrote:
But removing the quotes could be very useful for me. I'd like to store an array of sprites... (part of a buildRoom function) - later, a function calls:
compositor.NewAnimatedSprite(j*64, i*64, theCurrentRoom[i][j].sprite)
but this doesn't work.

Well it could be that during initialization there is no visibility of bitmapset.animations (it is "out of scope") or it is not initialized yet. You did not specify in what way it does no work. It's also possible you might be asking for this as "unquoting":

'init phase
item = {
name: "wall",
blocker: TRUE,
sprite: "sprite_brickwall2"
}
...
'peruse phase
compositor.NewAnimatedSprite(j*64, i*64, bitmapset.animations[theCurrentRoom[i][j].sprite])
0 Kudos
Highlighted
belltown
Level 7

Re: trying to print a simple array value (string), not worki

I guess we'd need to see the code you're using to put your 'item' values in the 'theCurrentRoom' array to know why it's not working (the code as well as the debugger output of whatever you say 'doesn't work').
https://github.com/belltown/
0 Kudos
Highlighted
Komag
Level 9

Re: trying to print a simple array value (string), not worki

"EnTerr" wrote:
It's also possible you might be asking for this as "unquoting":

'init phase
item = {
name: "wall",
blocker: TRUE,
sprite: "sprite_brickwall2"
}
...
'peruse phase
compositor.NewAnimatedSprite(j*64, i*64, bitmapset.animations[theCurrentRoom[i][j].sprite])


THIS!

You nailed it, that works perfectly!

Basically this is a shortcut way to build a grid room layout with various sprites in various locations, based on a grid layout of 64 pixels per square, and since I'm going to have a lot of different possible items, I needed a procedural way to make it work without having to set up manually too many IF THEN specific matches.

I had no idea that
[theCurrentRoom.sprite]
which is defined as a string (such as "sprite_brickwall2"), could be added after
bitmapset.animations
to properly access the xml file info. I probably need to study the xml syntax and controls more, I feel like I'm probably not making use of it as I should. I'm really not a programmer, but I did a Legend of Grimrock mod project with Lua last year and BrightScript feels very similar to that language.
0 Kudos