I’m attempting to make it so, depending on how long a string is; the script will format it accordingly.
Goal:
local string1 = {"Enum.KeyCode.F","Enum.KeyCode.Z"}
local string2 = {"Enum.KeyCode.E","Enum.KeyCode.R","Enum.KeyCode.T"}
local inputKeys = string.format("%s,%s",string1[1],string1[2])
local inputKeys2 = string.format("%s,%s,%s",string2[1],string2[2],string2[3])
My Attempt:
local inputKeys = ""
local fakeLength = length
for i = fakeLength, 1, -1 do
if i == 1 then
print(i, "is one")
inputKeys = inputKeys..COMBO_INPUT[i]
else
print(i, "is not one")
inputKeys = COMBO_INPUT[i]..","..inputKeys
end
fakeLength -= 1
end
print(inputKeys)
--returned something like "Enum.KeyCode.R,Enum.KeyCode.T,Enum.KeyCode.E"
How could I do this automatically? Thanks in advanced;
It’s for a 2.5D fighter-esq game. It’s easier to check if string1 is the same as inputKeys than a table for me. It’s to make it so you can press R,T,E as example; all in order within a certain period of time & then execute the special attack.
For reference, if a attack required 2 keys pressed consecutively, length = 2, and the string would be Enum.KeyCode.E,Enum.KeyCode.R, as example.
I would try concatenating a string with the inputs the user presses, comparing that to a string of the KeyCode names directly (e.g: R, E, etc.)
local attack1 = {"R", "E", "T"}
local currentAttack = ""
local function onInput(inputObject)
currentAttack = currentAttack..inputObject.KeyCode.Name
if currentAttack == table.concat(attack1) then
print'combo worked'
end
end
Very rough draft of what I was thinking. Not sure if I missed something you said, and there might also be logical stuff that I missed. Hope this helps a bit