[Extension] Animated ASCII Art

Discuss your Lua playlist, album art and interface scripts.
mederi
Big Cone-huna
Big Cone-huna
Posts: 1951
Joined: 15 Mar 2011 16:38
VLC version: 2.0.8
Operating System: Windows Vista/XP

[Extension] Animated ASCII Art

Postby mederi » 08 Dec 2013 21:54

Code: Select all

-- asciimation.lua -- VLC Extension script function descriptor() return { title = "Animated ASCII Art", version = "1.0", shortdesc = "Animated ASCII Art", description = "Plays a collection of ASCII animations. There are 95 printable characters defined in ASCII charset supported by all computers. It is possible to use these characters together with a monospace font to draw an image - ASCII art. Even animations are possible - Animated ASCII Art or ASCIImation.", capabilities = {} } end function activate() Create_dialog() end function deactivate() end function meta_changed() end --- Dialog box --- function close() vlc.deactivate() end function Create_dialog() d = vlc.dialog(descriptor().title.." v"..descriptor().version) d:add_button("Play",click_Refresh,1,1,1,1) dropdown = d:add_dropdown(2,2,1,1) for i,v in ipairs(animations) do dropdown:add_value(v[1],i) end frame_duration = d:add_text_input(fdur,2,1,1,1) label_counter = d:add_label("<div align=center>- / -</div>",1,2,1,1) label_bar = d:add_label("<table width=100% cellspacing=0 cellpadding=0><tr><td width=0% bgcolor=lightblue></td><td width=100% bgcolor=gainsboro></td></tr></table>",1,3,2,1) label_animation = d:add_label("<pre align=center style=color:red;>"..vlc.strings.convert_xml_special_chars(animations[1][2]).."</pre>",1,4,2,1) end t=0 fdur=0.2 function click_Refresh() animindex = dropdown:get_value() animation = animations[animindex] fdur = tonumber(frame_duration:get_text()) if ai~=animindex then i=1 ai=animindex --label_animation:set_text("") --d:update() d:del_widget(label_animation) label_animation = d:add_label("",1,4,2,1) t=0 end tt=os.clock() if t+fdur<tt then t=tt i=i+1 frames=#animation if i>frames then i=2 end label_bar:set_text("<table width=100% cellspacing=0 cellpadding=0><tr><td width=" .. (i-1)/(frames-1)*100 .. "% bgcolor=lightblue></td><td width=*% bgcolor=gainsboro></td></tr></table>") label_animation:set_text("<pre align=center style=color:red;>"..vlc.strings.convert_xml_special_chars(animation[i]).."</pre>") label_counter:set_text("<div align=center>"..(i-1).." / "..(frames-1).."</div>") d:update() end end animations={ {"Animated ASCII Art", [[ ANIMATED ASCII ART / ]], [[ ANIMATED ASCII ART - ]], [[ ANIMATED ASCII ART \ ]], [[ ANIMATED ASCII ART | ]], [[ ANIMATED ASCII ART / ]], [[ ANIMATED ASCII ART - ]], [[ ANIMATED ASCII ART \ ]], [[ ANIMATED ASCII ART | ]], [[ ANIMATED ASCII ART / ]], [[ ANIMATED ASCII ART - ]], [[ ANIMATED ASCII ART \ ]], [[ ANIMATED ASCII ART | ]], [[ animated ASCII ART / ]], [[ ANimated ASCII ART - ]], [[ ANIMated ASCII ART \ ]], [[ ANIMATed ASCII ART | ]] }, {"Happy feet", [[ ## ## Happyappy ]], [[ Happy# Happy ]], [[ Happy Happy ]], [[ ## Happy Happy ]], [[ ## ## HappHappy ]], [[ Happ## Happy ]], [[ ##ppy Happy ]], [[ ## Happy Happy ]] }, {"Bouncing ball", [[ o' ]], [[ __// o' ]], [[ // /` o ]], [[ // | o ]], [[ // | _ ]], [[ // /` o ]], [[ // /` o ]], [[ __// o' ]] }, { "Happy dance", [[ o <|> / \ ]], [[ o /|> / \ ]], [[ _o |> / \ ]], [[ \o |> / \ ]], [[ <o |> / \ ]], [[ <o_ | / \ ]], [[ <o/ | / \ ]], [[ <o> | / \ ]], [[ <o> ) /| ]], [[ <o> | / \ ]], [[ <o> ( |\ ]], [[ <o> | / \ ]], [[ \o/ | / \ ]], [[ \o/ ( / \ ]], [[ \o/ | / \ ]], [[ \o/ ) / \ ]], [[ \o/ | / \ ]], [[ _o_ | / \ ]], [[ _o_ < > ]], [[ \o/ | / \ ]], [[ \o/ | / \ ]], [[ \o/ _|_ ]], [[ _o_ | / \ ]], [[ _o_ | / \ ]], [[ o /|\ / \ ]] }, {"Keep walking", [[ ]], [[ \ \ ]], [[ o | | ]], [[ o /|\ / \ ]], [[ o | | ]], [[ o /|\ / \ ]], [[ o | | ]], [[ o | | ]], [[ o /|\ / \ ]], [[ o <|> / \ ]], [[ o <|> / \ ]], [[ _o |> / \ ]], [[ \o |> / \ ]], [[ io |> / \ ]], [[ io |> / \ ]], [[ _o |> / \ ]], [[ o /|\ / \ ]], [[ o | | ]], [[ o /|\ / \ ]], [[ o | | ]], [[ o /|\ / \ ]], [[ o | | ]], [[ / / ]], [[ ]], }, {"Running man", [[ ]], [[ - \ ]], [[ o + | ]], [[ o <|- - \ ]], [[ o + | ]], [[ o <|- - \ ]], [[ o + | ]], [[ o <|- - \ ]], [[ o + | ]], [[ o <|- - \ ]], [[ o + | ]], [[ o <| - ]], [[ ]], }, {"Standing ovation", [[ +-------------------+ | | | | | | | _O_ | | /| |\ | | _|\_/|_ | +-------------------+ ]], [[ +-------------------+ | | | | | | | _O_ | | /| |\ | | /_\|/_\ | +-------------------+ ]], [[ +-------------------+ | | | | | | | | | \-O-/ | | _\|/_ | +-------------------+ ]], [[ +-------------------+ | | | | | | | __O__ | | \| |/ | | _\-/_ | +-------------------+ ]], [[ +-------------------+ | | | | | _O_ | | /| |\ | | \|-|/ | | _\ /_ | +-------------------+ ]], [[ +-------------------+ | | | _O_ | | || || | | ||_|| | | | | | | _| |_ | +-------------------+ ]], [[ +-------------------+ | | | | | _O_ | | /| |\ | | / |_| \ | | _| |_ | +-------------------+ ]], [[ +-------------------+ | | | | | _O_ | | /| |\ | | \|_|/ | | _| |_ | +-------------------+ ]], [[ +-------------------+ | | | _O_ | | /| |\ | | \|_|/ | | / \ | | _/ \_ | +-------------------+ ]], [[ +-------------------+ | | | _O_ | | /| |\ | | \|_|/ | | / \ | | _\ \_ | +-------------------+ ]], [[ +-------------------+ | | | _O_ | | /| |\ | | \|_|/ | | | | | | _| |_ | +-------------------+ ]], [[ +-------------------+ | | | _O_ | | || || | | ||_|| | | | | | | _| |_ | +-------------------+ ]], [[ +-------------------+ | | | _O_ | | __/| || | | |_|| | | | | | | _| |_ | +-------------------+ ]], [[ +-------------------+ | | Hello! | | \_O_ | | | |\ | | |_| \ | | | | | | _| |_ | +-------------------+ ]], [[ +-------------------+ | / Hello! | | |O_ | | | |\ | | |_| \ | | | | | | _| |_ | +-------------------+ ]], [[ +-------------------+ | \ Hello! | | \_O_ | | | |\ | | |_|| | | | | | | _| |_ | +-------------------+ ]], [[ +-------------------+ | / Hello! | | |O_ | | | |\ | | |_| \ | | | | | | _| |_ | +-------------------+ ]], [[ +-------------------+ | \ Hello! | | \_O_ | | | |\ | | |_|| | | | | | | _| |_ | +-------------------+ ]], [[ +-------------------+ | | | _O_ | | __/| |\ | | |_|| | | | | | | _| |_ | +-------------------+ ]], [[ +-------------------+ | | | _O_ | | || || | | ||_|| | | | | | | _| |_ | +-------------------+ ]], [[ +-------------------+ | | | | | | | _O_ | | /| |\ | | _|\_/|_ | +-------------------+ ]], }, }
Can't we really have a timer(), a sleep() or anything like that in VLC Extensions? More functions, more fun!

Return to “Scripting VLC in lua”

Who is online

Users browsing this forum: No registered users and 14 guests