User Tools

Site Tools


script:world_event:getactorsbybox

getActorsByBox


  • Parameters and types:
    • objtype: numberbiological type (OBJ_TYPE, 0 means all objects) OBJ_TYPE
    • x1,y1,z1: numberstarting coordinates
    • x2,y2,z2: numberend coordinates
  • Return value and type:
    • code: numberSuccess (ErrorCode.OK) ErrorCode
    • total: numberGet the quantity
    • allarr: tableobject objid group
  • The main function of this method is to obtain the Actor object within the range
  • The specific use cases are as follows:
--Parameters:
local objtype=1--Type parameter: 0 all 1 player 2 creature 3 drop 4 throwable
local x1,y1,z1=0,7,0--area starting coordinates
local x2,y2,z2=50,57,50--The coordinates of the end point of the area
--Get the number and list of items of type type within the range of (x0,z0) height y0 to (x1,z1) height y1
local result,num,objids=World:getActorsByBox(objtype,x1,y1,z1,x2,y2,z2)
--Display the number in the chat box
Chat:sendSystemMsg("There are a total of "..num.." players in the range")
--Display the list in the chat box
for i,a in ipairs(objids) do
Chat:sendSystemMsg("The "..i.." one: "..a)
end
script/world_event/getactorsbybox.txt · Last modified: 2024/06/04 04:05 by don