Size: 4138
Comment:
|
Size: 5517
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 48: | Line 48: |
== MapDistance == ||<tablebgcolor="#F9F9F9" tablestyle="margin:1em 1em 1em 0px;border-style:solid;border-color:rgb(170, 170, 170);color:rgb(0, 0, 0);font-family:sans-serif;font-size:13px;line-height:19.5px;text-align:start; " tableclass="wikitable"#F2F2F2 style="border-style:solid;border-color:rgb(170, 170, 170);padding:0.2em; ">Usage: ||<style="border-style:solid;border-color:rgb(170, 170, 170);padding:0.2em;">!MapDistance(x1,y1,x2,y2) || ||<#F2F2F2 style="border-style:solid;border-color:rgb(170, 170, 170);padding:0.2em; ">Example: ||<style="border-style:solid;border-color:rgb(170, 170, 170);padding:0.2em;">!MapDistance(123,456,111,222) || This function finds the distance between two sets of coordinates on the map. This example finds the distance between your own city and target coordinates, rounded to 2 decimal places: . {{{ targX = 123 targY = 456 distance = round(MapDistance(city.x,city.y,targX,targY),2) echo "Distance from {city.coords} to {targX},{targY} is {distance} miles." Result: 15:36:13 Starting script 15:36:13 Running line 1 15:36:13 targX = 123 15:36:14 Running line 2 15:36:14 targY = 456 15:36:15 Running line 3 15:36:15 distance = 351.81 15:36:16 Running line 4 15:36:16 Distance from 460,355 to 123,456 is 351.81 miles. 15:36:17 Script stopped }}} |
|
Line 52: | Line 78: |
This function converts a field id into coordinates. | This function finds the distance between two field ids and displays it in a nice readable format. |
Line 54: | Line 80: |
This example finds the distance between two field ids: | Basic example: |
Line 67: | Line 93: |
targ= "123,456" | targ = "123,456" |
Line 69: | Line 95: |
distance=FormatDistance(city.fieldId,targetId) | distance = FormatDistance(city.fieldId,targetId) |
See also: ...
See also: ...
GetFieldId
Usage: |
GetFieldId(coords) |
Example: |
coords = "460,355" |
This function converts coordinates into a field id.
The field id is a number between 0-63999. Each number directly corresponds to a square on the 800x800 grid map. The game server uses field ids to reference all the squares on the map... 0,0 has field id of 0.... 1,0 has field id of 1... 799,0 has field id of 799... 1,1 is field id 800... and so on. Many of the advanced scripting functions require you to convert your coordinates into fieldIds to use them.
This example finds the coordinates of a field id:
coords = "460,355" echo GetFieldId(coords) Result: 15:07:40 Starting script 15:07:40 Running line 1 15:07:40 coords = 460,355 15:07:42 Running line 2 15:07:42 284460 15:07:43 Script stopped
FieldIdToCoords
Usage: |
FieldIdToCoords(fieldId) |
Example: |
fid = 284460 |
This function converts a field id into coordinates.
This example finds the coordinates of a field id:
fid = 284460 echo FieldIdToCoords(fid) Result: 14:58:01 Starting script 14:58:01 Running line 1 14:58:01 fid = 284460 14:58:02 Running line 2 14:58:02 460,355 14:58:03 Script stopped
MapDistance
Usage: |
MapDistance(x1,y1,x2,y2) |
Example: |
MapDistance(123,456,111,222) |
This function finds the distance between two sets of coordinates on the map.
This example finds the distance between your own city and target coordinates, rounded to 2 decimal places:
targX = 123 targY = 456 distance = round(MapDistance(city.x,city.y,targX,targY),2) echo "Distance from {city.coords} to {targX},{targY} is {distance} miles." Result: 15:36:13 Starting script 15:36:13 Running line 1 15:36:13 targX = 123 15:36:14 Running line 2 15:36:14 targY = 456 15:36:15 Running line 3 15:36:15 distance = 351.81 15:36:16 Running line 4 15:36:16 Distance from 460,355 to 123,456 is 351.81 miles. 15:36:17 Script stopped
FormatDistance
Usage: |
FormatDistance(fieldId1,fieldId2) |
Example: |
FormatDistance(12345,23456) |
This function finds the distance between two field ids and displays it in a nice readable format.
Basic example:
echo FormatDistance(12345,23456) Result: 15:27:46 Starting script 15:27:46 Running line 1 15:27:46 90.09 miles 15:27:47 Script stopped
This example finds the distance between your own city and a target coordinates:
targ = "123,456" targetId = GetFieldId(targ) distance = FormatDistance(city.fieldId,targetId) echo "Distance from {city.coords} to {targ} is {distance}. Result: 15:29:56 Starting script 15:29:56 Running line 1 15:29:56 targ = 123,456 15:29:57 Running line 2 15:29:57 targetId = 364923 15:29:58 Running line 3 15:29:58 distance = 351.80 miles 15:29:59 Running line 4 15:29:59 Distance from 460,355 to 123,456 is 351.80 miles. 15:30:00 Script stopped