improving the function

Hello I am trying to optimize this function as its my move function that is very important and I wanna start to learn how to optimize my code better.

Right now it uses string comparisons and I am trying to turn them into integers.

Part of the function is below:

if player.sequence ~= sequence then     if (sequence == "u") then         game.Dpad\_Up.alpha = 0.85; game.Dpad\_Right.alpha = 0.4; game.Dpad\_Left.alpha = 0.4; game.Dpad\_Down.alpha = 0.4;     elseif (sequence == "d") then         game.Dpad\_Up.alpha = 0.4; game.Dpad\_Right.alpha = 0.4; game.Dpad\_Left.alpha = 0.4; game.Dpad\_Down.alpha = 0.85;     elseif (sequence == "l") then         game.Dpad\_Up.alpha = 0.4; game.Dpad\_Right.alpha = 0.4; game.Dpad\_Left.alpha = 0.85; game.Dpad\_Down.alpha = 0.4;     elseif (sequence == "r") then         game.Dpad\_Up.alpha = 0.4; game.Dpad\_Right.alpha = 0.85; game.Dpad\_Left.alpha = 0.4; game.Dpad\_Down.alpha = 0.4;     end    player:setSequence(sequence) end player:play()

I would like to change to: if sequence == 1, elseif sequence == 2, elseif sequence == 3, etc.

But this throws off my if statement being player.sequence because it uses strings, this is probably a simple question but I am having troubles wrapping my head around it for some reason…

At the start of the program I declare with:

{sheet = game.azSheet, frames = {1, 2, 3, 4, 5, 6}, name = "d", time = 650},--down

I wouldn’t mind changing the name also to an integer as everything in my code uses strings.

Thanks for your time.