mirror of
https://github.com/Refactorio/RedMew.git
synced 2024-12-04 09:42:30 +02:00
misc bug fixes
This commit is contained in:
parent
76cdd26172
commit
0da2e27cca
3
band.lua
3
band.lua
@ -1,6 +1,7 @@
|
||||
local Event = require 'utils.event'
|
||||
local Gui = require 'utils.gui'
|
||||
local Token = require 'utils.global_token'
|
||||
local UserGroups = require 'user_groups'
|
||||
|
||||
local band_roles = require 'resources.band_roles'
|
||||
local band_roles_token = Token.register_global(band_roles)
|
||||
@ -200,7 +201,7 @@ local function draw_main_frame(player)
|
||||
flow.add {type = 'button', name = main_button_name, caption = 'Close'}
|
||||
flow.add {type = 'button', name = clear_button_name, caption = 'Clear Tag'}
|
||||
|
||||
if player.admin or is_regular(player.name) then
|
||||
if player.admin or UserGroups.is_regular(player.name) then
|
||||
flow.add {type = 'button', name = create_tag_button_name, caption = 'Create Tag'}
|
||||
end
|
||||
end
|
||||
|
@ -320,7 +320,8 @@ local function toggle(event)
|
||||
player_filters[event.player_index] = p_filters
|
||||
end
|
||||
|
||||
local left = event.player.gui.left
|
||||
local player = event.player
|
||||
local left = player.gui.left
|
||||
local main_frame = left[main_frame_name]
|
||||
|
||||
if main_frame and main_frame.valid then
|
||||
@ -333,6 +334,14 @@ local function toggle(event)
|
||||
|
||||
Gui.remove_data_recursivly(main_frame)
|
||||
main_frame.destroy()
|
||||
|
||||
if player.opened_gui_type == defines.gui_type.custom then
|
||||
local opened = player.opened
|
||||
if opened and opened.valid and opened.name == filters_table_name then
|
||||
Gui.remove_data_recursivly(opened)
|
||||
opened.destroy()
|
||||
end
|
||||
end
|
||||
else
|
||||
main_frame =
|
||||
left.add {
|
||||
@ -480,8 +489,10 @@ Gui.on_click(
|
||||
local frame = Gui.get_data(element)
|
||||
local filter_button = Gui.get_data(frame)
|
||||
|
||||
filter_button.sprite = element.sprite
|
||||
filter_button.tooltip = element.tooltip
|
||||
if filter_button and filter_button.valid then
|
||||
filter_button.sprite = element.sprite
|
||||
filter_button.tooltip = element.tooltip
|
||||
end
|
||||
|
||||
Gui.remove_data_recursivly(frame)
|
||||
frame.destroy()
|
||||
|
@ -72,16 +72,24 @@ global.walking = {}
|
||||
local custom_commands_return_player =
|
||||
Token.register(
|
||||
function(args)
|
||||
global.walking[args.player.name:lower()] = false
|
||||
args.player.character.destroy()
|
||||
local character = args.player.surface.find_entity('player', args.position)
|
||||
if character ~= nil and character.valid then
|
||||
args.player.character = character
|
||||
else
|
||||
args.player.create_character()
|
||||
local player = args.player
|
||||
if not player.valid then
|
||||
return
|
||||
end
|
||||
args.player.force = args.force
|
||||
args.player.teleport(args.position)
|
||||
|
||||
global.walking[player.index] = false
|
||||
player.character.destroy()
|
||||
|
||||
local character = args.character
|
||||
if character ~= nil and character.valid then
|
||||
player.character = character
|
||||
else
|
||||
player.create_character()
|
||||
player.teleport(args.position)
|
||||
end
|
||||
|
||||
player.force = args.force
|
||||
|
||||
game.print(args.player.name .. ' came back from his walkabout.')
|
||||
end
|
||||
)
|
||||
@ -93,7 +101,7 @@ local function walkabout(cmd)
|
||||
end
|
||||
local params = {}
|
||||
if cmd.parameter == nil then
|
||||
player_print('Walkabout failed.')
|
||||
player_print('Walkabout failed, check /help walkabout.')
|
||||
return
|
||||
end
|
||||
for param in string.gmatch(cmd.parameter, '%S+') do
|
||||
@ -115,7 +123,7 @@ local function walkabout(cmd)
|
||||
end
|
||||
|
||||
local player = game.players[player_name]
|
||||
if type(player) ~= 'table' or global.walking[player_name:lower()] then
|
||||
if player == nil or not player.valid or global.walking[player.index] then
|
||||
player_print(player_name .. ' could not go on a walkabout.')
|
||||
return
|
||||
end
|
||||
@ -124,25 +132,28 @@ local function walkabout(cmd)
|
||||
table.insert(chunks, chunk)
|
||||
end
|
||||
|
||||
local chunk = chunks[math.random(#chunks)]
|
||||
if not chunk then
|
||||
return
|
||||
end
|
||||
local surface = player.surface
|
||||
local chunk = surface.get_random_chunk()
|
||||
local pos = {x = chunk.x * 32, y = chunk.y * 32}
|
||||
local non_colliding_pos = player.surface.find_non_colliding_position('player', pos, 100, 1)
|
||||
local non_colliding_pos = surface.find_non_colliding_position('player', pos, 100, 1)
|
||||
|
||||
if non_colliding_pos then
|
||||
game.print(player_name .. ' went on a walkabout, to find himself.')
|
||||
Task.set_timeout(
|
||||
duration,
|
||||
custom_commands_return_player,
|
||||
{player = player, force = player.force, position = {x = player.position.x, y = player.position.y}}
|
||||
{
|
||||
player = player,
|
||||
force = player.force,
|
||||
position = {x = player.position.x, y = player.position.y},
|
||||
character = player.character
|
||||
}
|
||||
)
|
||||
player.character = nil
|
||||
player.create_character()
|
||||
player.teleport(non_colliding_pos)
|
||||
player.force = 'enemy'
|
||||
global.walking[player_name:lower()] = true
|
||||
player.force = 'neutral'
|
||||
global.walking[player.index] = true
|
||||
else
|
||||
player_print('Walkabout failed: count find non colliding position')
|
||||
end
|
||||
@ -475,35 +486,40 @@ end
|
||||
|
||||
global.undo_warned_players = {}
|
||||
local function undo(cmd)
|
||||
if (not game.player) or not game.player.admin then
|
||||
cant_run(cmd.name)
|
||||
return
|
||||
end
|
||||
if cmd.parameter and game.players[cmd.parameter] then
|
||||
if not global.undo_warned_players[game.player.index] or global.undo_warned_players[game.player.index] ~= game.players[cmd.parameter].index then
|
||||
global.undo_warned_players[game.player.index] = game.players[cmd.parameter].index
|
||||
game.player.print(
|
||||
string.format("Warning! You are about to remove %s entities and restore %s entities.",
|
||||
#Utils.find_entities_by_last_user(game.players[cmd.parameter], game.surfaces.nauvis),
|
||||
Antigrief.count_removed_entities(game.players[cmd.parameter]))
|
||||
)
|
||||
game.player.print("To execute the command please run it again.")
|
||||
return
|
||||
if (not game.player) or not game.player.admin then
|
||||
cant_run(cmd.name)
|
||||
return
|
||||
end
|
||||
if cmd.parameter and game.players[cmd.parameter] then
|
||||
if
|
||||
not global.undo_warned_players[game.player.index] or
|
||||
global.undo_warned_players[game.player.index] ~= game.players[cmd.parameter].index
|
||||
then
|
||||
global.undo_warned_players[game.player.index] = game.players[cmd.parameter].index
|
||||
game.player.print(
|
||||
string.format(
|
||||
'Warning! You are about to remove %s entities and restore %s entities.',
|
||||
#Utils.find_entities_by_last_user(game.players[cmd.parameter], game.surfaces.nauvis),
|
||||
Antigrief.count_removed_entities(game.players[cmd.parameter])
|
||||
)
|
||||
)
|
||||
game.player.print('To execute the command please run it again.')
|
||||
return
|
||||
end
|
||||
Antigrief.undo(game.players[cmd.parameter])
|
||||
game.print(string.format('Undoing everything %s did...', cmd.parameter))
|
||||
global.undo_warned_players[game.player.index] = nil
|
||||
else
|
||||
player_print('Usage: /undo <player>')
|
||||
end
|
||||
Antigrief.undo(game.players[cmd.parameter])
|
||||
game.print(string.format("Undoing everything %s did...", cmd.parameter))
|
||||
global.undo_warned_players[game.player.index] = nil
|
||||
else
|
||||
player_print("Usage: /undo <player>")
|
||||
end
|
||||
end
|
||||
|
||||
local function antigrief_surface_tp()
|
||||
if (not game.player) or not game.player.admin then
|
||||
cant_run(cmd.name)
|
||||
return
|
||||
end
|
||||
Antigrief.antigrief_surface_tp()
|
||||
if (not game.player) or not game.player.admin then
|
||||
cant_run(cmd.name)
|
||||
return
|
||||
end
|
||||
Antigrief.antigrief_surface_tp()
|
||||
end
|
||||
|
||||
if not _DEBUG then
|
||||
@ -532,15 +548,47 @@ commands.add_command('walkabout', '<player> <duration> - Send someone on a walk.
|
||||
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 only)', regular)
|
||||
commands.add_command('afk', 'Shows how long players have been afk.', afk)
|
||||
commands.add_command('follow', '<player> makes you follow the player. Use /unfollow to stop following a player.', follow)
|
||||
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 only)', toggle_tp_mode)
|
||||
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(
|
||||
'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)
|
||||
commands.add_command('hax', 'Toggles your hax', function() if game.player and game.player.admin then game.player.cheat_mode = not game.player.cheat_mode end end)
|
||||
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
|
||||
)
|
||||
commands.add_command(
|
||||
'hax',
|
||||
'Toggles your hax',
|
||||
function()
|
||||
if game.player and game.player.admin then
|
||||
game.player.cheat_mode = not game.player.cheat_mode
|
||||
end
|
||||
end
|
||||
)
|
||||
commands.add_command('pool', 'Spawns a pool', pool)
|
||||
commands.add_command('undo', '<player> undoes everything a player has done (Admins only)', undo)
|
||||
commands.add_command('antigrief_surface', 'moves you to the antigrief surface or back (Admins only)', antigrief_surface_tp)
|
||||
commands.add_command(
|
||||
'antigrief_surface',
|
||||
'moves you to the antigrief surface or back (Admins only)',
|
||||
antigrief_surface_tp
|
||||
)
|
||||
|
@ -56,7 +56,7 @@ local function entity_allowed_to_bomb(entity)
|
||||
return (
|
||||
name:find("turret") or
|
||||
name:find("rail") or
|
||||
name.find("ghost") or
|
||||
name:find("ghost") or
|
||||
name == "player" or
|
||||
name == "stone-wall" or
|
||||
entity.type == "electric-pole"
|
||||
|
@ -317,6 +317,7 @@ local function on_gui_click(event)
|
||||
else
|
||||
player_list_show(player,"time_played_desc")
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
if (name == "player_list_panel_header_2") then
|
||||
@ -325,6 +326,7 @@ local function on_gui_click(event)
|
||||
else
|
||||
player_list_show(player,"name_desc")
|
||||
end
|
||||
return
|
||||
end
|
||||
if (name == "player_list_panel_header_3") then
|
||||
if string.find(event.element.caption, symbol_desc) then
|
||||
@ -332,6 +334,7 @@ local function on_gui_click(event)
|
||||
else
|
||||
player_list_show(player,"time_played_desc")
|
||||
end
|
||||
return
|
||||
end
|
||||
if (name == "player_list_panel_header_4") then
|
||||
if string.find(event.element.caption, symbol_desc) then
|
||||
@ -339,6 +342,7 @@ local function on_gui_click(event)
|
||||
else
|
||||
player_list_show(player,"distance_desc")
|
||||
end
|
||||
return
|
||||
end
|
||||
if (name == "player_list_panel_header_5") then
|
||||
if string.find(event.element.caption, symbol_desc) then
|
||||
@ -346,6 +350,7 @@ local function on_gui_click(event)
|
||||
else
|
||||
player_list_show(player,"pokes_desc")
|
||||
end
|
||||
return
|
||||
end
|
||||
--Poke other players
|
||||
if event.element.type == "button" then
|
||||
|
@ -65,9 +65,9 @@ Gui.on_click(
|
||||
)
|
||||
|
||||
local function popup(cmd)
|
||||
local player = game.players[cmd.player_index]
|
||||
local player = game.player
|
||||
if player and not player.admin then
|
||||
player.print("You don't have permission to run this command")
|
||||
cant_run(cmd.name)
|
||||
return
|
||||
end
|
||||
|
||||
@ -79,9 +79,9 @@ local function popup(cmd)
|
||||
end
|
||||
|
||||
local function popup_update(cmd)
|
||||
local player = game.players[cmd.player_index]
|
||||
local player = game.player
|
||||
if player and not player.admin then
|
||||
player.print("You don't have permission to run this command")
|
||||
cant_run(cmd.name)
|
||||
return
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user