Combining items

Hi!

I’m trying to have a square grid with lets say 9 items(or more) and I want the user to combine one of these items with another item in the grid. First I thought the user could drag one object onto another but it might be easier to just mark two objects and press a button that says combine?

I’m guessing I should do something with arrays or tables…? But then I’m lost. I’m not sure where to begin and need a push in the right direction. Any logic help, code help or anything and I’d be extremely grateful!

Thanks [import]uid: 21652 topic_id: 32846 reply_id: 332846[/import]

Have you written multi-dimensional arrays in Lua before? I’d begin by setting up your table array. I suppose for a grid, it would look something like this:

local grid = {  
 { {row1:col1}, {row1:col2}, {row1:col3} },  
 { {row2:col1}, etc... }  
  
}  
  
print ( grid[1][3] ). --prints value of row 1, column 3  

Brent

[import]uid: 9747 topic_id: 32846 reply_id: 130585[/import]

Have you written multi-dimensional arrays in Lua before? I’d begin by setting up your table array. I suppose for a grid, it would look something like this:

local grid = {  
 { {row1:col1}, {row1:col2}, {row1:col3} },  
 { {row2:col1}, etc... }  
  
}  
  
print ( grid[1][3] ). --prints value of row 1, column 3  

Brent

[import]uid: 9747 topic_id: 32846 reply_id: 130585[/import]

No, I have not. I think the combining bit is the most confusing now though. I imagine having the grid and filling it with certain objects wouldn’t be the hard part. [import]uid: 21652 topic_id: 32846 reply_id: 130598[/import]

No, I have not. I think the combining bit is the most confusing now though. I imagine having the grid and filling it with certain objects wouldn’t be the hard part. [import]uid: 21652 topic_id: 32846 reply_id: 130598[/import]

Hi again,
By “combining” do you mean mathematical things, or like a table of “ingredients” that you mix to make new things? That would all just have to be hard-coded I suppose. Maybe you could make another internal chart with all of the ingredients down the side and also across the top, and for each one you cross-reference it to make something new. Not knowing exactly the kind of “combining” you have in mind, I can’t provide a specific idea on how to accomplish it. :slight_smile:

Best regards,
Brent
[import]uid: 9747 topic_id: 32846 reply_id: 130616[/import]

Ah sorry. You’re right, I forgot to specify that. It’s easy when you have it all in your mind.

I meant as in combining items to make a new. Like ingredients. I thought I would hard code that as well. Would it be possible to make a button of each cell perhaps and highlight it somehow? [import]uid: 21652 topic_id: 32846 reply_id: 130619[/import]

Hi again,
By “combining” do you mean mathematical things, or like a table of “ingredients” that you mix to make new things? That would all just have to be hard-coded I suppose. Maybe you could make another internal chart with all of the ingredients down the side and also across the top, and for each one you cross-reference it to make something new. Not knowing exactly the kind of “combining” you have in mind, I can’t provide a specific idea on how to accomplish it. :slight_smile:

Best regards,
Brent
[import]uid: 9747 topic_id: 32846 reply_id: 130616[/import]

Ah sorry. You’re right, I forgot to specify that. It’s easy when you have it all in your mind.

I meant as in combining items to make a new. Like ingredients. I thought I would hard code that as well. Would it be possible to make a button of each cell perhaps and highlight it somehow? [import]uid: 21652 topic_id: 32846 reply_id: 130619[/import]

Hi again,
I suppose there are several ways to actually implement this, in terms of user-interface, visual display, touch/tap/drag functionality, etc. What is your approximate skill level and experience in Corona and Lua? I might be able to point you toward some tutorials if you’re somewhat new to the platform.

Brent
[import]uid: 9747 topic_id: 32846 reply_id: 130867[/import]

Hi again,
I suppose there are several ways to actually implement this, in terms of user-interface, visual display, touch/tap/drag functionality, etc. What is your approximate skill level and experience in Corona and Lua? I might be able to point you toward some tutorials if you’re somewhat new to the platform.

Brent
[import]uid: 9747 topic_id: 32846 reply_id: 130867[/import]