Sorry for the undescriptive title but, I am not sure what to call this?
So what I am trying to do is to use one function (named “buy”) to purchase an item. To try and keep the code shorter, I made a variable called “item” and one named “price”. When the user taps on the item to buy, it opens a ‘window’ with a purchase button and at the same time sets ‘item=“colorRed”’ and ‘price=“200”’. Then, if the user taps the purchase button it calls the “buy” function, which in turn, subtracts the price from their current coins. This function is also supposed set a variable (colorRed) to true in a table. To do this I am trying to do
(“gameData.” … item) = true
this gives me an error of “ambiguous syntax (function call x new statement) near ‘(’”
BTW, gameData is a table where I store all of the, well, game data.
So what am I doing wrong? Is this even possible?
Also, please forgive me because I am probably doing everything wrong… I am very new to programming!!
--this is not the actual code, but is a bit more simple, and hopefully helps make it easier to understand what I am trying to do item = "colorRed" price = 200 function Buy(event) if gameData.coins \>= price then gameData.coins = gameData.coins - price ("gameData." .. item) = true end end