diff --git a/scripts_examples/logout_stanza_bbsads.lua b/scripts_examples/logout_stanza_bbsads.lua new file mode 100644 index 0000000..e8d4c1e --- /dev/null +++ b/scripts_examples/logout_stanza_bbsads.lua @@ -0,0 +1,40 @@ +-- To use this with Magicka, replace the logout_stanza.lua in your +-- MagickaBBS/scripts directory. + +-- You could also git pull as a cronjob to grab the latest ansis say +-- once a week. + +-- Requirements: +-- You will need an uptodate git version of Magicka for it to work. + +function scandir(directory) + local i, t, popen = 0, {}, io.popen + local pfile = popen('find "'..directory..'" -maxdepth 1 -type f') + for filename in pfile:lines() do + if string.lower(string.sub(filename, -4)) == ".ans" then + i = i + 1 + t[i] = filename + end + end + pfile:close() + return t +end + +function logout() + -- Change this to your adverts directory... + local t = scandir("/home/andrew/bbs-ansi-adverts/adverts"); + local rand = math.random(#t); + + bbs_write_string("\027[2J"); + + bbs_display_ansi(t[rand]); + + bbs_write_string("\027[0mPress any key to continue..."); + bbs_read_char(); + + bbs_write_string("\027[2J"); + + bbs_display_ansi("goodbye"); + os.execute("sleep 1"); + return 1; +end