i put flexible key assignment to a program by putting the key values on a text file and extract them into a table tKey using the code below:
Code: Select all
tKey = ()
function tKey.fLoad()
counter = 0;
for vLine in love.filesystem.lines(tMacro.keyfileName) do
if string.find(vLine, "><", 1 , 1) == 1 then break; end -- end of file indicator, don't read
if string.find(vLine, "--", 1 , 1) == nil then -- not a comment
tKey[counter] = vLine;
counter = counter + 1;
end
end
end
Code: Select all
function keypressed(key)
if (key == tKey[0]) or (key == tKey[1]) then
fNextState(); --go to the next program state
end
end
notes: i have read a previous post about "User Define keys in a game" http://love2d.org/forum/viewtopic.php?f ... 02&start=0; please note that my question is not about the user-defined keys but on how to put the extracted values in an expression [is it possible without using complicated loadstring() or am i thinking in a too complicated way?].
thank you for your time.