From fae336d1a2d613fd00640ed6ccbb9eb386086c82 Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Tue, 31 May 2022 14:24:19 +0200 Subject: Add map component --- doc/api.md | 1 + doc/client.md | 1 + doc/client_pkts.md | 2 +- doc/map.md | 13 +++++++++++++ doc/server_pkts.md | 2 +- 5 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 doc/map.md (limited to 'doc') diff --git a/doc/api.md b/doc/api.md index 8dda81e..2105a81 100644 --- a/doc/api.md +++ b/doc/api.md @@ -15,6 +15,7 @@ Hydra uses gopher-lua, Lua 5.1 - `escapes`: contains utility functions to deal with minetest escape sequences, see [escapes.md](escapes.md) - `client`: a function to create a client from command line arguments in the form ` `. This is trivial but so commonly used that this function was added to avoid repetition in scripts. +- `base64`: contains the `base64.encode(data)` function to base64 encode a string as well as `base64.decode(data)` to decode ## Standard library additions diff --git a/doc/client.md b/doc/client.md index 9844591..9c1922e 100644 --- a/doc/client.md +++ b/doc/client.md @@ -22,3 +22,4 @@ After being disconnect, a client cannot be reconnected. Enabled components can be accessed by using `self.`. - `self.auth`: Handles authentication. Recommended for the vast majority of scripts. See [auth.md](auth.md). +- `self.map`: Stores MapBlocks received from server. See [map.md](map.md). diff --git a/doc/client_pkts.md b/doc/client_pkts.md index 7f967a0..2594b9d 100644 --- a/doc/client_pkts.md +++ b/doc/client_pkts.md @@ -1,4 +1,4 @@ # Client Packets TODO: automatically generate documentation from spec. -For now, have a look at [spec/client](../spec/client) +For now, have a look at [spec/client](../convert/spec/client) diff --git a/doc/map.md b/doc/map.md new file mode 100644 index 0000000..26fd51a --- /dev/null +++ b/doc/map.md @@ -0,0 +1,13 @@ +# Map Component +Source code: [map.go](../map.go) + +Map handles the `blk_data` and `node_metas_changed` packets. +Map may send `got_blks`, `deleted_blks` packets. + +## Functions + +`self:clear()`: Forget all blocks. + +`self:block(blkpos)`: Return the `map_blk` at `blkpos` as found in the `blk_data` packet (See [client_pkts.md](client_pkts.md)). `nil` if block is not present. + +`self:node(pos)`: Return a node in the form `{ param0 = 126, param1 = 0, param2 = 0, meta = { ... } }`. The meta field is a `node_meta` as found in the `blk_data` packet. `nil` if node is not present. diff --git a/doc/server_pkts.md b/doc/server_pkts.md index 0b34367..ac8741e 100644 --- a/doc/server_pkts.md +++ b/doc/server_pkts.md @@ -1,4 +1,4 @@ # Server Packets TODO: automatically generate documentation from spec. -For now, have a look at [spec/server](../spec/server) +For now, have a look at [spec/server](../convert/spec/server) -- cgit v1.2.3