I’m trying to write a small animation for the screen.
I need visual feedback in a script when saving a table or executing another “trigger” type task (copy, paste, randomize etc).
I experimented with metro but I’m not sure that’s the best solution because inevitably at a moment I get this error message : metro.alloc: already used max number of allocated script metros
What is the best way to proceed? Can I finish the process of a metro once it has reached its maximum counter? stl: stop () stops it but does not deallocate it.
How can I do please ?
This function draws multiple / at a given fps then erases the portion of screen (redraw_portion).
function anim(x, y, z, s)
local d = 0
local x = x or 120
local y = y or 62
local z = z or 5
local s = s or 0.08
an = metro.alloc()
an.count = z
an.time = s
an.callback = function()
d = d + 1
screen.move((x - 10)+(d*3), y)
screen.level(2 + (d*2))
screen.text("/")
screen.update()
if d == z then
redraw_portion(x-10, y-10, 120, 20)
an:stop()
end
end
an:start()
end
function redraw_portion(x, y, w, h) -- mask a portion of the screen with a rectangle of level 0
screen.rect(x, y, w, h)
screen.level(0)
screen.fill()
screen.stroke()
screen.update()
end
Where can I find the startup animation ? Maybe I could use this code as an inspiration…