From 1b0335c069d5b54bb43d5111a3a4af046bc5e88e Mon Sep 17 00:00:00 2001 From: Nathan Schneider Date: Tue, 28 Dec 2021 14:39:34 -0700 Subject: [PATCH] Bugfix on copy_table and added refresh command to CLI --- README.md | 4 ++-- login.lua | 3 --- modpol_core/interactions/interactions.lua | 16 ++++++++++++++-- modpol_core/util/misc.lua | 6 +----- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 28152e1..16f96c2 100644 --- a/README.md +++ b/README.md @@ -39,11 +39,11 @@ The command-line version is in the `modpol` subdirectory. To run the program on $ lua[jit] login.lua ``` -You can also interact with the interpreter by starting it this way: +Alternatively, to test arbitrary functions in the interpreter outside of the interactive dashboards, load Modpol with: ``` $ lua[jit] -> dofile("login.lua") +> dofile("modpol_core/modpol.lua") ``` In the interpreter, for a list of global functions and tables, use `modpol.menu()`. diff --git a/login.lua b/login.lua index 3c51fe6..a29a58c 100644 --- a/login.lua +++ b/login.lua @@ -1,8 +1,5 @@ dofile("modpol_core/modpol.lua") -modpol.instance.members = {} -modpol.orgs.reset() - print("Log in as which user?") local username = io.read() diff --git a/modpol_core/interactions/interactions.lua b/modpol_core/interactions/interactions.lua index f8447fc..451d7fd 100644 --- a/modpol_core/interactions/interactions.lua +++ b/modpol_core/interactions/interactions.lua @@ -1,6 +1,6 @@ -- INTERACTIONS.LUA (CLI) --- User interaction functions for Modular Politics +-- User interaction functions for Modpol -- Called by modpol.lua modpol.interactions = {} @@ -49,7 +49,7 @@ function modpol.interactions.dashboard(user) print('All users: ' .. table.concat(all_users, ', ')) print() - print("Commands: (O)rg, (U)ser, Enter to close") + print("Commands: (O)rg, (U)ser, (R)eset, Enter to close") local sel = io.read() @@ -76,10 +76,22 @@ function modpol.interactions.dashboard(user) modpol.interactions.dashboard(user) end ) + + elseif sel == "" then + return + else print("User name not found") modpol.interactions.dashboard(user) end + elseif sel == "R" or sel == "r" then + modpol.instance.members = {} + modpol.orgs.reset() + print("Orgs and users reset") + modpol.interactions.dashboard(user) + else + print("Invalid input, try again") + modpol.interactions.dashboard(user) end end diff --git a/modpol_core/util/misc.lua b/modpol_core/util/misc.lua index 1707dab..aa4ba47 100644 --- a/modpol_core/util/misc.lua +++ b/modpol_core/util/misc.lua @@ -5,11 +5,7 @@ modpol.util = {} -- Returns a copy of the table inputted function modpol.util.copy_table(t) local t2 = {} - if ipairs(t) then - for i,v in ipairs(t) do - t2[i] = v - end - elseif pairs(t) then + if pairs(t) then for k,v in pairs(t) do t2[k] = v end