I'm stuck.
I tried doing some code, but cannot see how to make it work.
What I want is what I said in the title: Start a loop when I press a key, stop it when I press another. However it seems that it queues the next key until the loop is over.
This is what I tried:
Code: Select all
lmc_device_set_name('KBD2', 'MYUSBNUMPADHERE')
lmc_print_devices()
lmc_set_handler('KBD2',function(button, direction)
print('Callback for whole keyboard 2: button ' .. button .. ', direction '..direction)
if (direction == 0) then
if (button == 97) then
for i = 100,1,-1 do
print('a pressed')
end
end
if (button == 98) then
i = 1
end
end
end)
Code: Select all
lmc_device_set_name('KBD2', 'MYUSBNUMPADHERE')
lmc_print_devices()
i = 0
while (i < 3) do
lmc_set_handler('KBD2',function(button, direction)
print('Callback for whole keyboard 2: button ' .. button .. ', direction '..direction)
if (direction == 0) then
if (button == 97) then
i = 1
end
if (button == 98) then
i = 0
end
if (button == 99) then
i = 3
end
end
end)
if (i == 1) then
print('LOL')
end
end
Thanks!