Fixed protection issues

This commit is contained in:
Cooldude2606
2021-04-24 21:05:11 +01:00
parent 891663edb9
commit d83f1e3aea
6 changed files with 42 additions and 14 deletions

View File

@@ -82,27 +82,25 @@ function Selection.is_selecting(player, selection_name)
end
end
--- Filter on_player_selected_area to this custom selection, pretends with player and appends with selection arguments
--- Filter on_player_selected_area to this custom selection, appends the selection arguments
-- @tparam string selection_name The name of the selection to listen for
-- @tparam function handler The event handler
function Selection.on_selection(selection_name, handler)
Event.add(defines.events.on_player_selected_area, function(event)
local selection = selections[event.player_index]
if not selection or selection.name ~= selection_name then return end
local player = game.get_player(event.player_index)
handler(player, event, unpack(selection.arguments))
handler(event, unpack(selection.arguments))
end)
end
--- Filter on_player_alt_selected_area to this custom selection, pretends with player and appends with selection arguments
--- Filter on_player_alt_selected_area to this custom selection, appends the selection arguments
-- @param string selection_name The name of the selection to listen for
-- @param function handler The event handler
function Selection.on_alt_selection(selection_name, handler)
Event.add(defines.events.on_player_alt_selected_area, function(event)
local selection = selections[event.player_index]
if not selection or selection.name ~= selection_name then return end
local player = game.get_player(event.player_index)
handler(player, event, unpack(selection.arguments))
handler(event, unpack(selection.arguments))
end)
end