User Tools

Site Tools


script:world_event:calcdistance

calcDistance

  • Parameters and types:
    • pos1: tablestarting coordinates
    • pos2: tableend coordinate
  • Return value and type:
    • code: numberSuccess (ErrorCode.OK) ErrorCode
    • len: numberdistance value
  • The main purpose of this method: Calculate the distance between locations
  • The specific use cases are as follows:
--Calculate the straight-line distance between two points
--The first parameter is a table consisting of the starting point coordinates
--The second parameter is a table consisting of the end point coordinates
local result,distance=World:calcDistance({x=0,y=0,z=0},{x=10,y=10,z=10})
--Display in the chat box
Chat:sendSystemMsg("The straight-line distance from (0,0) height 0 to (10,10) height 10 is"..distance)
script/world_event/calcdistance.txt · Last modified: 2024/06/09 08:01 by don