diff --git a/custom_commands.lua b/custom_commands.lua index 62ac94b6..232b3c6a 100644 --- a/custom_commands.lua +++ b/custom_commands.lua @@ -15,7 +15,7 @@ function cant_run(name) end local function invoke(cmd) - if not game.player or not (game.player.admin or UserGroups.is_mod(game.player.name)) then + if not game.player or not game.player.admin then cant_run(cmd.name) return end @@ -30,7 +30,7 @@ local function invoke(cmd) end local function teleport_player(cmd) - if not game.player or not (game.player.admin or UserGroups.is_mod(game.player.name)) then + if not game.player or not game.player.admin then cant_run(cmd.name) return end @@ -46,7 +46,7 @@ local function teleport_player(cmd) end local function teleport_location(cmd) - if not game.player or not (game.player.admin or UserGroups.is_mod(game.player.name)) then + if not game.player or not game.player.admin then cant_run(cmd.name) return end @@ -66,7 +66,7 @@ end global.walking = {} local function walkabout(cmd) - if not ((not game.player) or game.player.admin or UserGroups.is_mod(game.player.name)) then + if not ((not game.player) game.player.admin then cant_run(cmd.name) return end @@ -134,7 +134,7 @@ function custom_commands_return_player(args) end local function regular(cmd) - if not ((not game.player) or game.player.admin or UserGroups.is_mod(game.player.name)) then + if not ((not game.player) or game.player.admin then cant_run(cmd.name) return end @@ -157,30 +157,6 @@ local function regular(cmd) end end -local function mod(cmd) - if game.player and not game.player.admin then - cant_run(cmd.name) - return - end - - if cmd.parameter == nil then - player_print("Command failed. Usage: /mod , ") - return - end - local params = {} - for param in string.gmatch(cmd.parameter, "%S+") do table.insert(params, param) end - if params[2] == nil then - player_print("Command failed. Usage: /mod , ") - return - elseif (params[1] == "promote") then - UserGroups.add_mod(params[2]) - elseif (params[1] == "demote") then - UserGroups.remove_mod(params[2]) - else - player_print("Command failed. Usage: /mod , ") - end -end - local function afk() for _,v in pairs (game.players) do if v.afk_time > 300 then @@ -280,7 +256,7 @@ end global.old_force = {} global.force_toggle_init = true local function forcetoggle(cmd) - if not game.player or not (game.player.admin or UserGroups.is_mod(game.player.name)) or (not game.player.character) then + if not game.player or not game.player.admin or (not game.player.character) then cant_run(cmd.name) return end @@ -371,7 +347,7 @@ function custom_commands_untempban(param) end local function tempban(cmd) - if (not game.player) or not (game.player.admin or UserGroups.is_mod(game.player.name)) then + if (not game.player) or not game.player.admin then cant_run(cmd.name) return end @@ -464,22 +440,20 @@ local function reactor_toggle() end end commands.add_command("kill", "Will kill you.", kill) -commands.add_command("tpplayer", " - Teleports you to the player. (Admins and moderators)", teleport_player) -commands.add_command("invoke", " - Teleports the player to you. (Admins and moderators)", invoke) +commands.add_command("tpplayer", " - Teleports you to the player. (Admins only)", teleport_player) +commands.add_command("invoke", " - Teleports the player to you. (Admins only)", invoke) commands.add_command("tppos", "Teleports you to a selected entity. (Admins only)", teleport_location) -commands.add_command("walkabout", ' - Send someone on a walk. (Admins and moderators)', walkabout) +commands.add_command("walkabout", ' - Send someone on a walk. (Admins only)', walkabout) commands.add_command("market", 'Places a fish market near you. (Admins only)', spawn_market) commands.add_command("regulars", 'Prints a list of game regulars.', UserGroups.print_regulars) -commands.add_command("regular", ', Change regular status of a player. (Admins and moderators)', regular) -commands.add_command("mods", 'Prints a list of game mods.', UserGroups.print_mods) -commands.add_command("mod", ', Changes moderator status of a player. (Admins only)', mod) +commands.add_command("regular", ', Change regular status of a player. (Admins only)', regular) commands.add_command("afk", 'Shows how long players have been afk.', afk) commands.add_command("tag", ' Sets a players tag. (Admins only)', tag) commands.add_command("follow", ' makes you follow the player. Use /unfollow to stop following a player.', follow) commands.add_command("unfollow", 'stops following a player.', unfollow) -commands.add_command("tpmode", "Toggles tp mode. When on place a ghost entity to teleport there (Admins and moderators)", toggle_tp_mode) -commands.add_command("forcetoggle", "Toggles the players force between player and enemy (Admins and moderators)", forcetoggle) -commands.add_command("tempban", " Temporarily bans a player (Admins and moderators)", tempban) +commands.add_command("tpmode", "Toggles tp mode. When on place a ghost entity to teleport there (Admins only)", toggle_tp_mode) +commands.add_command("forcetoggle", "Toggles the players force between player and enemy (Admins only)", forcetoggle) +commands.add_command("tempban", " Temporarily bans a player (Admins only)", tempban) commands.add_command("spyshot", " Sends a screenshot of player to discord. (If a host is online. If no host is online, you can become one yourself. Ask on discord :))", spyshot) commands.add_command("zoom", " Sets your zoom.", zoom) commands.add_command("all-tech", "researches all technologies", function() if game.player and game.player.admin then game.player.force.research_all_technologies() end end) diff --git a/user_groups.lua b/user_groups.lua index 79555895..70fa2778 100644 --- a/user_groups.lua +++ b/user_groups.lua @@ -1,4 +1,3 @@ -global.mods = {} global.regualrs = {} local Event = require "utils.event" @@ -21,26 +20,8 @@ Module.get_actor = function() return "" end -local function cast_bool(value) - if value then - return true - else - return false - end -end - -Module.is_mod = function(player_name) - if global.mods[player_name] then - return cast_bool(global.mods[player_name:lower()]) --to make it backwards compatible - end - return true -end - local is_regular = function(player_name) - if not global.regulars[player_name] then - return cast_bool(global.regulars[player_name:lower()]) --to make it backwards compatible - end - return true + return cast_bool(global.regulars[player_name] or global.regulars[player_name:lower()]) --to make it backwards compatible end Module.add_regular = function(player_name) @@ -57,20 +38,6 @@ Module.add_regular = function(player_name) end end -Module.add_mod = function(player_name) - local actor = get_actor() - if is_mod(player_name) then player_print(player_name .. " is already a moderator.") - else - if game.players[player_name] then - game.print(actor .. " promoted " .. player_name .. " to moderator.") - global.mods[player_name] = true - update_group("mods") - else - player_print(player_name .. " does not exist.") - end - end -end - Module.remove_regular = function(player_name) local actor = get_actor() if is_regular(player_name) then game.print(player_name .. " was demoted from regular by " .. actor .. ".") end @@ -78,33 +45,14 @@ Module.remove_regular = function(player_name) update_group("regulars") end -Module.remove_mod = function(player_name) - local actor = get_actor() - if is_mod(player_name) then game.print(player_name .. " was demoted from mod by " .. actor .. ".") end - global.mods[player_name] = nil - update_group("mods") -end - Module.print_regulars = function() for k,_ in pairs(global.regulars) do player_print(k) end end -Module.print_mods = function() - for k,_ in pairs(global.mods) do - player_print(k) - end -end - - Event.add(defines.events.on_player_joined_game, function(event) local correctCaseName = game.players[event.player_index].name - if global.mods[correctCaseName:lower()] and not global.mods[correctCaseName] then - global.mods[correctCaseName:lower()] = nil - global.mods[correctCaseName] = true - update_group("mods") - end if global.regulars[correctCaseName:lower()] and not global.regulars[correctCaseName] then global.regulars[correctCaseName:lower()] = nil global.regulars[correctCaseName] = true @@ -114,7 +62,6 @@ end) Event.add(-1, function() if not global.regulars then global.regulars = {} end - if not global.mods then global.mods = {} end end) return Module