Skip to content

Implemented OnPlayerSelectionChanged callback #157

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Api/Manage.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ g_Hooks = {
["OnAreaChanged"] = {}, -- Signature: function(a_AffectedAreaCuboid, a_Player, a_World, a_Operation)
["OnAreaCopied"] = {}, -- Signature: function(a_Player, a_World, a_CopiedAreaCuboid)
["OnAreaCopying"] = {}, -- Signature: function(a_Player, a_World, a_CopiedAreaCuboid)
["OnPlayerSelectionChanging"] = {}, -- Signature: function(a_Player, a_PosX, a_PosY, a_PosZ, a_PointNr)
["OnPlayerSelectionChanged"] = {}, -- Signature: function(a_Player, a_PosX, a_PosY, a_PosZ, a_PointNr)
["OnPlayerSelectionChanged"] = {}, -- Signature: function(a_Player, a_Cuboid, a_PointNr) a_PointNr is nil if the entire selection changed.

-- Not implemented
["OnPlayerSelectionChanging"] = {}, -- Signature: function(a_Player, a_Cuboid, a_PointNr) a_PointNr is nil if the entire selection changed.
}


Expand Down
9 changes: 8 additions & 1 deletion Classes/PlayerSelection.lua
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,14 @@ end
-- a_PointChanged is optional, assigned to the point that has just changed
-- If nil, the entire selection is assumed changed
function cPlayerSelection:NotifySelectionChanged(a_PointChanged)
-- TODO: Call the registered callbacks
-- TODO: Call the OnPlayerSelectionChangING callback to prevent selection changes.

-- Call the player selection changed callback to notify other plugins of the selection change.
self.PlayerState:DoWithPlayer(function(a_Player)
local cuboid = cCuboid()
cuboid:Assign(self.Cuboid)
CallHook("OnPlayerSelectionChanged", a_Player, cuboid, a_PointChanged)
end);

-- Set the player's WECUI, if present:
if (self.PlayerState.IsWECUIActivated) then
Expand Down