diff --git a/modpol_minetest/chatcommands/chatcommands.lua b/modpol_minetest/chatcommands/chatcommands.lua index ff93f7d..f691b82 100644 --- a/modpol_minetest/chatcommands/chatcommands.lua +++ b/modpol_minetest/chatcommands/chatcommands.lua @@ -21,8 +21,7 @@ regchat( "dashboard", { privs = {}, func = function(user) - local result = modpol.dashboard(user) - return true, result + modpol.dashboard(user) end, }) diff --git a/modpol_minetest/overrides/interactions/interactions.lua b/modpol_minetest/overrides/interactions/interactions.lua index 01ed4ff..54ac989 100644 --- a/modpol_minetest/overrides/interactions/interactions.lua +++ b/modpol_minetest/overrides/interactions/interactions.lua @@ -6,11 +6,27 @@ -- Output: Displays a menu of commands to the user -- TKTK currently a manually curated list---needs major improvement modpol.dashboard = function(user) - local output = "Command list:" + -- prepare data + -- to add: my orgs, nested orgs map + local commands = "Command list: " for key,value in pairs(command_list) do - output = output .. "/" .. value .. " " + commands = commands .. "/" .. value .. " " end - return output + local orgs = "Orgs: " .. modpol.orgs.list_all() + local users = "Players: " + .. table.concat(modpol.list_users(), ", ") + -- set up formspec + local formspec = { + "formspec_version[4]", + "size[10,8]", + "label[0.5,0.5;", minetest.formspec_escape(commands), "]", + "label[0.5,1.5;", minetest.formspec_escape(orgs), "]", + "label[0.5,2.5;", minetest.formspec_escape(users), "]", + "button[0.5,7;1,0.8;yes;Done]", + } + local formspec_string = table.concat(formspec, "") + -- present to player + minetest.show_formspec(user, "modpol:dashboard", formspec_string) end -- =================================================================== @@ -33,11 +49,17 @@ modpol.binary_poll_user = function(user, question) local formspec_string = table.concat(formspec, "") -- present to player minetest.show_formspec(user, "modpol:binary_poll", formspec_string) - end - ---what to do - minetest.register_on_player_receive_fields(function (player, formname, fields) - -- modpol:poll +end + +-- =================================================================== +-- Register input fields from forms +-- Minetest-specific; does not overwrite +-- separate this out into discrete functions? +-- how do we ensure this is maximally modular? +-- Perhaps create a table of possible formnames and their associated functions +-- Then we can easily add to the table of possible options +minetest.register_on_player_receive_fields(function (player, formname, fields) + -- modpol:binary_poll if formname == "modpol:binary_poll" then local pname = player:get_player_name() local vote = nil