no meu código ncl, há o chamamento de um arquivo lua.
esse arquivo lua lê os nomes de slides (imagens) em um arquivo texto e os apresenta na tela, exatamente como no powerpoint.
pois bem, está dando um erro, pois a máquina virtual está travando e zerando quando é executado esse recurso.
abaixo, o script do lua
local images = {}
local index = 0
for line in io.lines("slides.txt") do
print(#images .. " - " .. line)
table.insert(images, line)
end
return images
end
function moveImageIndex(images, index, forward)
if forward then
index = index + 1
if index > #images then
index = 1
end
else
index = index - 1
if index <= 0 then
index = #images
end;
end
return index
end
function showImage(images, index)
if #images > 0 then
img = canvas:new(images[index])
canvas:compose(10, 10, img)
canvas:flush()
end
end
function handler(evt)
print("Evento disparado: " .. evt.class .. " " .. evt.type)
if (evt.class == 'key' and evt.type == 'press') then
print(evt.key)
if evt.key == "CURSOR_RIGHT" then
index = moveImageIndex(images, index, true)
elseif evt.key == "CURSOR_LEFT" then
index = moveImageIndex(images, index, false)
end
showImage(images, index)
elseif evt.class == "ncl" and evt.type=="presentation" and evt.action=="start" then
autoForward()
end
end
event.register(handler)
Autor: paulo machado
66 comentários
print(#images .. " - " .. line)
table.insert(images, line)
end return images -- Isso daqui está certo ? seu script vai
-- retornar aqui e nao vai fazer mais nada
-- (nem registrar o handler).
end -- Esse end está sobrando aqui..
o erro sumiu, e não encontrei nada, vasculhando. apenas apareceu: checkAnchorMonitor can't create TIMENominalEventMOnitor for -1...slides/dcSlides because next transition = 'inf' como é uma mensagem que aparece muito no Ginga, não sei se tem a ver. o código parece estar ok, a despeito do autoForward. tb eliminei a linha print("Evento disparado: " .. evt.class .. " " .. evt.type) não parece que vá fazer diferença.