1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2024-12-12 10:04:40 +02:00

removed mods

This commit is contained in:
Valansch 2018-05-23 18:45:14 +02:00
parent a931ef6d9e
commit d6bbee9269
2 changed files with 15 additions and 94 deletions

View File

@ -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 <promote, demote>, <player>")
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 <promote, demote>, <player>")
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 <promote, demote>, <player>")
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", "<player> - Teleports you to the player. (Admins and moderators)", teleport_player)
commands.add_command("invoke", "<player> - Teleports the player to you. (Admins and moderators)", invoke)
commands.add_command("tpplayer", "<player> - Teleports you to the player. (Admins only)", teleport_player)
commands.add_command("invoke", "<player> - 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", '<player> <duration> - Send someone on a walk. (Admins and moderators)', walkabout)
commands.add_command("walkabout", '<player> <duration> - 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", '<promote, demote>, <player> 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", '<promote, demote>, <player> Changes moderator status of a player. (Admins only)', mod)
commands.add_command("regular", '<promote, demote>, <player> 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", '<player> <tag> Sets a players tag. (Admins only)', tag)
commands.add_command("follow", '<player> 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", "<player> <minutes> 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", "<player> <minutes> Temporarily bans a player (Admins only)", tempban)
commands.add_command("spyshot", "<player> 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", "<number> 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)

View File

@ -1,4 +1,3 @@
global.mods = {}
global.regualrs = {}
local Event = require "utils.event"
@ -21,26 +20,8 @@ Module.get_actor = function()
return "<server>"
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