Hi everyone!
I’m very new to programming in general and only picked up Corona SDK earlier today, so apologies if I am not coming across clearly or using the wrong lingo (please correct me if I do).
I’m working on a simple card game to learn more about working with Corona and lua but eventually ran into a problem not covered in the tutorials I read and found no answers after much searching.
In short, my question is this: when you pass a parameter into a function, how do you go about manipulating/altering that parameter within the function using the label that you passed in?
If that question doesn’t make any sense, here’s what I mean by example:
[lua]
local function shuffleDeck( anyDeck )
--code
anyDeck = temporaryShufflingDeck
end
[/lua]
Obviously I’ve left out the vast majority of the code for simplification here (I can provide it if it would help, but I don’t think it’s necessary for this question). The deck I pass in here is a table called “p1Deck”. If I type:
[lua]
local function shuffleDeck( anyDeck )
--code
p1Deck = temporaryShufflingDeck
end
[/lua]
before the end instead (thus hardcoding the variable p1Deck into the function), then p1Deck is correctly set to equal temporaryShufflingDeck. However I want the function to set which ever deck I pass in to temporaryShufflingDeck so that the function will work on other potential decks that I want to pass in. Apparently simply using the parameter label (anyDeck) does not work, so how would I go about manipulating any deck passed in using the label anyDeck for versatility?
Thank you for your time and consideration.