@@ -11,7 +11,7 @@ g_Hooks = {
11
11
[" OnAreaChanging" ] = {}, -- Signature: function(a_AffectedAreaCuboid, a_Player, a_World, a_Operation)
12
12
[" OnAreaChanged" ] = {}, -- Signature: function(a_AffectedAreaCuboid, a_Player, a_World, a_Operation)
13
13
[" OnAreaCopied" ] = {}, -- Signature: function(a_Player, a_World, a_CopiedAreaCuboid)
14
- [" OnAreaCopying" ] = {}, -- Signature: function(a_Player, a_World, a_CopiedAreaCuboid)
14
+ [" OnAreaCopying" ] = {}, -- Signature: function(a_Player, a_World, a_CopiedAreaCuboid)
15
15
[" OnPlayerSelectionChanging" ] = {}, -- Signature: function(a_Player, a_PosX, a_PosY, a_PosZ, a_PointNr)
16
16
[" OnPlayerSelectionChanged" ] = {}, -- Signature: function(a_Player, a_PosX, a_PosY, a_PosZ, a_PointNr)
17
17
}
@@ -31,21 +31,21 @@ function AddHook(a_HookName, a_PluginName, a_CallbackName)
31
31
(type (a_PluginName ) ~= " string" ) or (a_PluginName == " " ) or not cPluginManager :Get ():IsPluginLoaded (a_PluginName ) or
32
32
(type (a_CallbackName ) ~= " string" ) or (a_CallbackName == " " )
33
33
) then
34
- LOGWARNING (" [WorldEdit] Invalid callback registration parameters." )
34
+ LOGWARNING (" Invalid callback registration parameters." )
35
35
LOGWARNING (" AddHook() was called with params " ..
36
36
tostring (a_HookName or " <nil>" ) .. " , " ..
37
37
tostring (a_PluginName or " <nil>" ) .. " , " ..
38
38
tostring (a_CallbackName or " <nil>" )
39
39
)
40
-
40
+
41
41
return false
42
42
end
43
-
43
+
44
44
if (not g_Hooks [a_HookName ]) then
45
- LOGWARNING (" [WorldEdit] Plugin \" " .. a_PluginName .. " \" tried to register an unexisting hook called \" " .. a_HookName .. " \" " )
45
+ LOGWARNING (" Plugin \" " .. a_PluginName .. " \" tried to register an unexisting hook called \" " .. a_HookName .. " \" " )
46
46
return false
47
47
end
48
-
48
+
49
49
table.insert (g_Hooks [a_HookName ], {PluginName = a_PluginName , CallbackName = a_CallbackName })
50
50
return true
51
51
end
60
60
-- function(a_AffectedAreaCuboid, a_Player, a_World, a_Operation)
61
61
-- The callback should return true to abort the operation, false to continue.
62
62
function RegisterAreaCallback (a_PluginName , a_FunctionName , a_WorldName )
63
- LOGWARNING (" [WorldEdit] RegisterAreaCallback is obsolete. Please use AddHook(\" OnAreaChanging\" , ...)" )
63
+ LOGWARNING (" RegisterAreaCallback is obsolete. Please use AddHook(\" OnAreaChanging\" , ...)" )
64
64
LOGWARNING (" The callback signature changed as well. All individual coordinates are now a single cCuboid" )
65
65
return AddHook (" OnAreaChanging" , a_PluginName , a_FunctionName )
66
66
end
76
76
-- a_PointNr can be 0 for Left click or 1 for right click.
77
77
-- The callback should return true to abort the operation, or false to continue.
78
78
function RegisterPlayerSelectingPoint (a_PluginName , a_FunctionName )
79
- LOGWARNING (" [WorldEdit] RegisterPlayerSelectingPoint is obsolete. Please use AddHook(\" OnPlayerSelectionChanging\" , ...)" )
79
+ LOGWARNING (" RegisterPlayerSelectingPoint is obsolete. Please use AddHook(\" OnPlayerSelectionChanging\" , ...)" )
80
80
LOGWARNING (" The callback signature changed as well. All individual coordinates are now a single cCuboid" )
81
81
return AddHook (" OnPlayerSelectionChanging" , a_PluginName , a_FunctionName )
82
82
end
@@ -93,14 +93,14 @@ function SetPlayerCuboidSelection(a_Player, a_Cuboid)
93
93
(tolua .type (a_Player ) ~= " cPlayer" ) or
94
94
(tolua .type (a_Cuboid ) ~= " cCuboid" )
95
95
) then
96
- LOGWARNING (" [WorldEdit] Invalid SetPlayerCuboidSelection API function parameters." )
96
+ LOGWARNING (" Invalid SetPlayerCuboidSelection API function parameters." )
97
97
LOGWARNING (" SetPlayerCuboidSelection() was called with param types \" " ..
98
98
tolua .type (a_Player ) .. " \" (\" cPlayer\" wanted) and \" " ..
99
99
tolua .type (a_Cuboid ) .. " \" (\" cCuboid\" wanted)."
100
100
)
101
101
return false
102
102
end
103
-
103
+
104
104
-- Set the selection, both points:
105
105
local State = GetPlayerState (a_Player )
106
106
State .Selection :SetFirstPoint (a_Cuboid .p1 .x , a_Cuboid .p1 .y , a_Cuboid .p1 .z )
@@ -121,23 +121,23 @@ function SetPlayerCuboidSelectionPoint(a_Player, a_PointNumber, a_CoordVector)
121
121
(tonumber (a_PointNumber ) == nil ) or
122
122
(tolua .type (a_CoordVector ) ~= " Vector3i" )
123
123
) then
124
- LOGWARNING (" [WorldEdit] Invalid SetPlayerCuboidSelectionPoint API function parameters." )
124
+ LOGWARNING (" Invalid SetPlayerCuboidSelectionPoint API function parameters." )
125
125
LOGWARNING (" SetPlayerCuboidSelection() was called with param types \" " ..
126
126
tolua .type (a_Player ) .. " \" (\" cPlayer\" wanted), \" " ..
127
127
type (a_PointNumber ) .. " \" (\" number\" wanted) and \" " ..
128
128
tolua .type (a_CoordVector ) .. " \" (\" cVector3i\" wanted)."
129
129
)
130
130
return false
131
131
end
132
-
132
+
133
133
-- Set the specified selection point:
134
134
local State = GetPlayerState (a_Player )
135
135
if (tonumber (a_PointNumber ) == 1 ) then
136
136
State .Selection :SetFirstPoint (a_CoordVector )
137
137
elseif (tonumber (a_PointNumber ) == 2 ) then
138
138
State .Selection :SetSecondPoint (a_CoordVector )
139
139
else
140
- LOGWARNING (" [WorldEdit] Invalid SetPlayerCuboidSelectionPoint API function parameters." )
140
+ LOGWARNING (" Invalid SetPlayerCuboidSelectionPoint API function parameters." )
141
141
LOGWARNING (" SetPlayerCuboidSelection() was called with invalid point number " .. a_PointNumber )
142
142
return false
143
143
end
@@ -169,14 +169,14 @@ function GetPlayerCuboidSelection(a_Player, a_CuboidToSet)
169
169
(tolua .type (a_Player ) ~= " cPlayer" ) or
170
170
(tolua .type (a_CuboidToSet ) ~= " cCuboid" )
171
171
) then
172
- LOGWARNING (" [WorldEdit] Invalid SetPlayerCuboidSelection API function parameters." )
172
+ LOGWARNING (" Invalid SetPlayerCuboidSelection API function parameters." )
173
173
LOGWARNING (" SetPlayerCuboidSelection() was called with param types \" " ..
174
174
tolua .type (a_Player ) .. " \" (\" cPlayer\" wanted) and \" " ..
175
175
tolua .type (a_CuboidToSet ) .. " \" (\" cCuboid\" wanted)."
176
176
)
177
177
return false
178
178
end
179
-
179
+
180
180
-- Set the output cuboid to the selection:
181
181
local State = GetPlayerState (a_Player )
182
182
a_CuboidToSet :Assign (State .Selection .Cuboid )
@@ -201,15 +201,15 @@ function WEPushUndo(a_Player, a_World, a_Cuboid, a_Description)
201
201
(tolua .type (a_Cuboid ) ~= " cCuboid" ) or
202
202
(type (a_Description ) ~= " string" )
203
203
) then
204
- LOGWARNING (" [WorldEdit] Invalid WEPushUndo API function parameters." )
204
+ LOGWARNING (" Invalid WEPushUndo API function parameters." )
205
205
LOGWARNING (" WePushUndo() was called with these param types:" )
206
206
LOGWARNING (" " .. tolua .type (a_Player ) .. " (cPlayer wanted)," )
207
207
LOGWARNING (" " .. tolua .type (a_World ) .. " (cWorld wanted)," )
208
208
LOGWARNING (" " .. tolua .type (a_Cuboid ) .. " (cCuboid wanted)," )
209
209
LOGWARNING (" " .. type (a_Description ) .. " (string wanted)," )
210
210
return false , " bad params"
211
211
end
212
-
212
+
213
213
-- Push the undo:
214
214
local State = GetPlayerState (a_Player )
215
215
return State .UndoStack :PushUndoFromCuboid (a_World , a_Cuboid , a_Description )
@@ -238,7 +238,7 @@ function WEPushUndoAsync(a_Player, a_World, a_Cuboid, a_Description, a_CallbackP
238
238
(type (a_CallbackPluginName ) ~= " string" ) or
239
239
(type (a_CallbackFunctionName ) ~= " string" )
240
240
) then
241
- LOGWARNING (" [WorldEdit] Invalid WEPushUndoAsync() API function parameters." )
241
+ LOGWARNING (" Invalid WEPushUndoAsync() API function parameters." )
242
242
LOGWARNING (" WePushUndo() was called with these param types:" )
243
243
LOGWARNING (" " .. tolua .type (a_Player ) .. " (cPlayer wanted)," )
244
244
LOGWARNING (" " .. tolua .type (a_World ) .. " (cWorld wanted)," )
@@ -248,23 +248,23 @@ function WEPushUndoAsync(a_Player, a_World, a_Cuboid, a_Description, a_CallbackP
248
248
LOGWARNING (" " .. type (a_CallbackFunctionName ) .. " (string wanted)," )
249
249
return false , " bad params"
250
250
end
251
-
251
+
252
252
-- if the input cuboid isn't sorted, create a sorted copy:
253
253
if not (a_Cuboid :IsSorted ()) then
254
254
a_Cuboid = cCuboid (a_Cuboid )
255
255
a_Cuboid :Sort ()
256
256
end
257
-
257
+
258
258
-- Create a callback for the ChunkStay:
259
259
local State = GetPlayerState (a_Player ) -- a_Player may be deleted in the meantime, but the State table won't
260
260
local OnAllChunksAvailable = function ()
261
261
local IsSuccess , Msg = State .UndoStack :PushUndoFromCuboid (a_World , a_Cuboid , a_Description )
262
262
cPluginManager :CallPlugin (a_CallbackPluginName , a_CallbackFunctionName , IsSuccess , Msg )
263
263
end
264
-
264
+
265
265
-- Get a list of chunks that need to be present:
266
266
local Chunks = ListChunksForCuboid (a_Cuboid )
267
-
267
+
268
268
-- Initiate a ChunkStay operation, pushing the undo when all the chunks are available
269
269
a_World :ChunkStay (Chunks , nil , OnAllChunksAvailable )
270
270
return true
@@ -283,10 +283,6 @@ function ExecuteString(a_String, ...)
283
283
if (not Function ) then
284
284
return false , Error
285
285
end
286
-
286
+
287
287
return pcall (Function , ... )
288
288
end
289
-
290
-
291
-
292
-
0 commit comments