Coordinates

Thalassicus

Bytes and Nibblers
Joined
Nov 9, 2005
Messages
11,057
Location
Texas
There's two coordinate systems used by the game, rectangular (also called cartesian or grid) and hex. Different parts of the lua code use different systems, so it's important to identify which one the function you're working with uses. Most things like plot:GetX() use the rectangular system. It's the one we're used to in most things in life. The hex form is tilted to line up along tile boundaries. I suspect it's used by the game core since adjacency is probably easier to calculate.

You can use these functions to convert between the two:

rectX rectY = ToGridFromHex(hexX, hexY)
hexX hexY = ToHexFromGrid(rectX, rectY)

Y values are vertical, and X values horizontal. They start at the bottom left of the map and progress in these positive directions:

attachment.php


Rectangular


attachment.php


Hex
 
Back
Top Bottom