Hey there,
i am trying to create a matching game, anyways im trying to pass the id from a ui button too a variable.
what i have is…
[lua]local choice_1
local choice_2
local choice_3
local choice_4
local choice_5
local choice_6
local checkForMatch = function()
if firstChoice == secondChoice then
print(“Success!”)
else
print(“Failure!”)
end
end
local unHideChoice = function( event )
if event.phase == “release” then
if isFirstChoiceMade == false then
firstChoice = event.id
whatToChange = choice_…(firstChoice)
whatToChange.alpha = 0
isFirstChoiceMade = true
print(firstChoice)
else
secondChoice = event.id
checkForMatch()
end
end
end
choice_1 = ui.newButton{
defaultSrc = “hidden.png”,
defaultX = 50,
defaultY = 50,
onEvent = unHideChoice,
id = 1
}
choice_2 = ui.newButton{
defaultSrc = “hidden.png”,
defaultX = 50,
defaultY = 50,
onEvent = unHideChoice,
id = 1
}
[/lua]
So i am trying to make it so the “whatToChange” variable uses “choice_” and then i want to take the id from my ui button and place it in there.
What is the correct way to do this? thanks in advance
[import]uid: 19620 topic_id: 18115 reply_id: 318115[/import]