Drafted Region-API.md

2016-12-15 20:46:18 +11:00
parent df1697bb7d
commit 6e197c37d5
2 changed files with 73 additions and 1 deletions
+1 -1
@@ -13,7 +13,7 @@ This is a straight forward way of learning how to use TurtleMap.
This is a breakdown of each class, it's methods and it's APIs, for quick lookup.
* [Region](Region)
* Region API
* [Region API](Region-API)
* Region Pager Base
* Region Pager Lua
* Region Pager API
+72
@@ -0,0 +1,72 @@
# Require
To access this API from lua, you must call require:
```lua
regionAPI = require("region")
```
# Functions
```lua
regionAPI.SetTile(r, x, y, z, v)
```
This function takes a `Region` userdata as it's first parameter. It then takes non-zero-indexed numbers as `x`, `y` and `z`, which indicate a tile and a layer in the given region. Finally, it takes a zero-indexed number as `v`, indicating the new value for that tile's layer.
This calls `Region::SetTile`, and may throw an exception if `x`, `y` or `z` are out of bounds.
```lua
regionAPI.GetTile(r, x, y, z)
```
This function takes a `Region` userdata as it's first parameter. It then takes non-zero-indexed numbers as `x`, `y` and `z`, which indicate a tile and a layer in the given region. This returns the value at the given tile's layer.
This calls `Region::GetTile`, and may throw an exception if `x`, `y` or `z` are out of bounds.
```lua
regionAPI.SetSolid(r, x, y, v)
```
This function takes a `Region` userdata as it's first parameter. It then takes non-zero-indexed numbers as `x` and `y`, which indicate a tile in the given region. Finally, it takes boolean as `v`, which indicates of the tile should be solid (true) or not (false).
This calls `Region::SetSolid`, and may throw an exception if `x` or `y` are out of bounds.
```lua
regionAPI.GetSolid(r, x, y)
```
This function takes a `Region` userdata as it's first parameter. It then takes non-zero-indexed numbers as `x` and `y`, which indicate a tile in the given region. This returns whether the given tile is solid (true) or not (false).
This calls `Region::GetSolid`, and may throw an exception if `x` or `y` are out of bounds.
```lua
regionAPI.GetX(r)
```
This function takes a `Region` userdata as it's parameter. It returns the `x` value of the given region. It is guaranteed to be a multiple of `regionAPI.GetWidth()`.
```lua
regionAPI.GetY(r)
```
This function takes a `Region` userdata as it's parameter. It returns the `y` value of the given region. It is guaranteed to be a multiple of `regionAPI.GetHeight()`.
```lua
regionAPI.GetWidth([r])
```
This returns the value of `REGION_WIDTH`.
```lua
regionAPI.GetHeight([r])
```
This returns the value of `REGION_HEIGHT`.
```lua
regionAPI.GetDepth([r])
```
This returns the value of `REGION_DEPTH`.