Hello again everyone. I’m working on my in game shop functions, and to facilitate that, I’m creating a table, like in an external file called, waffleTableData.lua, currently, it looks like this:
--table for waffle purchasable items. local shop = require( "src.waffle\_shop") local waffleTable = { [1]= {cost = 5, func = shop:addLives}, } return waffleTable;
I’ve got two issues, first, I’m having no problem referencing the table by numerical value, such as
local cost = waffleTable[event.target.id]["cost"]
and passing the number 1 as my event.target.id. However, I’d prefer to pass it the same id as we will for the actual cash shop, in the form of
id = "com.mybundle.myapp.1Life"
however, no matter how i format the ID in the table file (as a string only, as a string encased in [], or as just the literal com.mybundle.myapp.1Life, I always get some form of error. I suspect it’s because of the dot notation, but is there a way around it?
The second, and perhaps more pressing issue, involves the calling of a function from within the table.Right now, since I only have one item being set up, I have an if statement, but I’d like to change that a a for(event.target.id) do statement, and have it call all of the required information and function to make that happen. However, with the current setup (with those functions in yet another separate file, it doesn’t seem to work. I don’t get any errors generated, but it just doesn’t seem to take me to the function as I expect. am I better off just including all the functions in the table file?