From 6e197c37d5451d56781ed26a0831dc143f20d815 Mon Sep 17 00:00:00 2001 From: Kayne Ruse Date: Thu, 15 Dec 2016 20:46:18 +1100 Subject: [PATCH] Drafted Region-API.md --- Home.md | 2 +- Region-API.md | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 Region-API.md diff --git a/Home.md b/Home.md index 7919ca7..6ccd449 100644 --- a/Home.md +++ b/Home.md @@ -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 diff --git a/Region-API.md b/Region-API.md new file mode 100644 index 0000000..8219ce6 --- /dev/null +++ b/Region-API.md @@ -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`. +