How to update graphics based on change in table?

So I just started using Corona and I’m not at all used to not refreshing the screen myself.

I have a non-graphical “array” in one file and another file that displays a grid of rectangles based on that array.  I know that I can add event listeners to the rectangles that change the integers in the array, but is it possible to “listen” to the array for changes to the integers and subsequently modify the rectangles?

I don’t want to modify the file that defines the non-graphical array, so I can’t use a game loop.  Is there any other way?

You could set a timer (or Runtime event) that would fire a routine that walks through the array looking for changes – but that’s kind of cheesy. :slight_smile:

Instead, how about setting something up in whatever routine changes the array? Maybe that’s the place where you’d modify the display object.

Kind of hard to make suggestions based on a fairly vague description. :wink: If you can describe more what you’re trying to accomplish (from an end-user standpoint, not necessarily under the hood) someone here may have some good ideas.

 Jay

Thank you very much for the quick response.  I’m sorry I didn’t respond in kind.  As a whole my project is to create a Roguelike game.  What sparked this question is that originally I intended to code the game in a completely text-based way.  (I understand this doesn’t make much sense on a phone, and that Corona probably isn’t the best tool for doing so, but that’s my project so oh well)

Anyway, from the completed text-based portions I would create a graphical overlay as an optional interface for the user.  The problem is, if I were to change every routine that changed my arrays, it would almost be like recoding the entire game to incorporate graphics.  Instead what I would like is to simply create a module or whatever that can just scan the environment’s/player’s grid on each move and display the correct information accordingly.

Edit: I suppose that can just amount to creating a whole new graphical grid on each turn, since I’m not too worried about efficiency.  Just wondering if there’s a way to instead just monitor each thing in the array and change it accordingly.  (If this sounds weird or unrealistic then I’m sorry.  Still a newbie game programmer.)

You could set a timer (or Runtime event) that would fire a routine that walks through the array looking for changes – but that’s kind of cheesy. :slight_smile:

Instead, how about setting something up in whatever routine changes the array? Maybe that’s the place where you’d modify the display object.

Kind of hard to make suggestions based on a fairly vague description. :wink: If you can describe more what you’re trying to accomplish (from an end-user standpoint, not necessarily under the hood) someone here may have some good ideas.

 Jay

Bump

Thank you very much for the quick response.  I’m sorry I didn’t respond in kind.  As a whole my project is to create a Roguelike game.  What sparked this question is that originally I intended to code the game in a completely text-based way.  (I understand this doesn’t make much sense on a phone, and that Corona probably isn’t the best tool for doing so, but that’s my project so oh well)

Anyway, from the completed text-based portions I would create a graphical overlay as an optional interface for the user.  The problem is, if I were to change every routine that changed my arrays, it would almost be like recoding the entire game to incorporate graphics.  Instead what I would like is to simply create a module or whatever that can just scan the environment’s/player’s grid on each move and display the correct information accordingly.

Edit: I suppose that can just amount to creating a whole new graphical grid on each turn, since I’m not too worried about efficiency.  Just wondering if there’s a way to instead just monitor each thing in the array and change it accordingly.  (If this sounds weird or unrealistic then I’m sorry.  Still a newbie game programmer.)

Bump