From 8596ef9bc52c62e409b7a971bb3da6614c7988fa Mon Sep 17 00:00:00 2001 From: Solderpunk Date: Sat, 8 Dec 2018 14:37:46 +0000 Subject: Declare and explain global vars at start of program. --- telem.lua | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/telem.lua b/telem.lua index cbfee7f..1d545e7 100755 --- a/telem.lua +++ b/telem.lua @@ -11,11 +11,17 @@ table = require("table") _BBS_ROOT = "/var/bbs/" - --- TODO: This is, obviously, not secure and will need to be updated -username = os.getenv("USER") - -current_board = "" +-- Global var declarations +-- (Not actually required by Lua, just here to make the design clear/explicit) + +username = os.getenv("USER") -- TODO: This is, obviously, not secure and will need to be updated +boards = {} -- Array of board names, alphaetically sorted +board_names = {} -- Set of board names, must always be consistent with boards +current_board = "" -- String, name of current board, must be in boards and board_names +current_board_threads = {} -- Array of thread tables, containing threads associated with current_board +current_thread = {} -- Active thread table, always an element of current_board_threads +current_thread_posts = {} -- Array of post tables, containing posts associated with current_thread +current_post_index = nil -- Integer index into current_thread_posts function cat_file(filename) io.input(filename) @@ -316,7 +322,6 @@ end show_welcome() -boards, board_names = {}, {} for board in lfs.dir(path.join(_BBS_ROOT, "boards")) do if string.sub(board, 1, 1) ~= "." then boards[board] = true -- cgit v1.2.3