Skip to content

Commit 1feb0fb

Browse files
committed
Implemented OnPlayerSelectionChanged callback
1 parent f72e30a commit 1feb0fb

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

Api/Manage.lua

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ g_Hooks = {
1212
["OnAreaChanged"] = {}, -- Signature: function(a_AffectedAreaCuboid, a_Player, a_World, a_Operation)
1313
["OnAreaCopied"] = {}, -- Signature: function(a_Player, a_World, a_CopiedAreaCuboid)
1414
["OnAreaCopying"] = {}, -- Signature: function(a_Player, a_World, a_CopiedAreaCuboid)
15-
["OnPlayerSelectionChanging"] = {}, -- Signature: function(a_Player, a_PosX, a_PosY, a_PosZ, a_PointNr)
16-
["OnPlayerSelectionChanged"] = {}, -- Signature: function(a_Player, a_PosX, a_PosY, a_PosZ, a_PointNr)
15+
["OnPlayerSelectionChanged"] = {}, -- Signature: function(a_Player, a_Cuboid, a_PointNr) a_PointNr is nil if the entire selection changed.
16+
17+
-- Not implemented
18+
["OnPlayerSelectionChanging"] = {}, -- Signature: function(a_Player, a_Cuboid, a_PointNr) a_PointNr is nil if the entire selection changed.
1719
}
1820

1921

Classes/PlayerSelection.lua

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,14 @@ end
334334
-- a_PointChanged is optional, assigned to the point that has just changed
335335
-- If nil, the entire selection is assumed changed
336336
function cPlayerSelection:NotifySelectionChanged(a_PointChanged)
337-
-- TODO: Call the registered callbacks
337+
-- TODO: Call the OnPlayerSelectionChangING callback to prevent selection changes.
338+
339+
-- Call the player selection changed callback to notify other plugins of the selection change.
340+
self.PlayerState:DoWithPlayer(function(a_Player)
341+
local cuboid = cCuboid()
342+
cuboid:Assign(self.Cuboid)
343+
CallHook("OnPlayerSelectionChanged", a_Player, cuboid, a_PointChanged)
344+
end);
338345

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

0 commit comments

Comments
 (0)