]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - doc/lua_api.txt
Unrestricted HTTP API for Client, Server and Main Menu
[dragonfireclient.git] / doc / lua_api.txt
index d3a367b27acdc3836b62428ca005d74eae32ab85..353ccc9243d8b1a20ac2931d1eeacbdd1a732d8a 100644 (file)
@@ -4762,12 +4762,15 @@ Environment access
     * `nodenames`: e.g. `{"ignore", "group:tree"}` or `"default:dirt"`
     * `search_center` is an optional boolean (default: `false`)
       If true `pos` is also checked for the nodes
-* `minetest.find_nodes_in_area(pos1, pos2, nodenames)`: returns a list of
-  positions.
+* `minetest.find_nodes_in_area(pos1, pos2, nodenames, [grouped])`
+    * `pos1` and `pos2` are the min and max positions of the area to search.
     * `nodenames`: e.g. `{"ignore", "group:tree"}` or `"default:dirt"`
-    * First return value: Table with all node positions
-    * Second return value: Table with the count of each node with the node name
-      as index.
+    * If `grouped` is true the return value is a table indexed by node name
+      which contains lists of positions.
+    * If `grouped` is false or absent the return values are as follows:
+      first value: Table with all node positions
+      second value: Table with the count of each node with the node name
+      as index
     * Area volume is limited to 4,096,000 nodes
 * `minetest.find_nodes_in_area_under_air(pos1, pos2, nodenames)`: returns a
   list of positions.
@@ -5422,28 +5425,72 @@ Schematics
 
 HTTP Requests
 -------------
-
-* `minetest.request_http_api()`:
-    * returns `HTTPApiTable` containing http functions if the calling mod has
-      been granted access by being listed in the `secure.http_mods` or
-      `secure.trusted_mods` setting, otherwise returns `nil`.
-    * The returned table contains the functions `fetch`, `fetch_async` and
+* `minetest.get_http_api()`
+    * returns `HTTPApiTable` containing http functions.
+    * The returned table contains the functions `fetch_sync`, `fetch_async` and
       `fetch_async_get` described below.
-    * Only works at init time and must be called from the mod's main scope
-      (not from a function).
     * Function only exists if minetest server was built with cURL support.
-    * **DO NOT ALLOW ANY OTHER MODS TO ACCESS THE RETURNED TABLE, STORE IT IN
-      A LOCAL VARIABLE!**
-* `HTTPApiTable.fetch(HTTPRequest req, callback)`
-    * Performs given request asynchronously and calls callback upon completion
-    * callback: `function(HTTPRequestResult res)`
-    * Use this HTTP function if you are unsure, the others are for advanced use
+* `HTTPApiTable.fetch_sync(HTTPRequest req)`: returns HTTPRequestResult
+    * Performs given request synchronously
 * `HTTPApiTable.fetch_async(HTTPRequest req)`: returns handle
     * Performs given request asynchronously and returns handle for
       `HTTPApiTable.fetch_async_get`
 * `HTTPApiTable.fetch_async_get(handle)`: returns HTTPRequestResult
     * Return response data for given asynchronous HTTP request
 
+### `HTTPRequest` definition
+
+Used by `HTTPApiTable.fetch` and `HTTPApiTable.fetch_async`.
+
+    {
+        url = "http://example.org",
+
+        timeout = 10,
+        -- Timeout for connection in seconds. Default is 3 seconds.
+
+        post_data = "Raw POST request data string" OR {field1 = "data1", field2 = "data2"},
+        -- Optional, if specified a POST request with post_data is performed.
+        -- Accepts both a string and a table. If a table is specified, encodes
+        -- table as x-www-form-urlencoded key-value pairs.
+        -- If post_data is not specified, a GET request is performed instead.
+
+        user_agent = "ExampleUserAgent",
+        -- Optional, if specified replaces the default minetest user agent with
+        -- given string
+
+        extra_headers = { "Accept-Language: en-us", "Accept-Charset: utf-8" },
+        -- Optional, if specified adds additional headers to the HTTP request.
+        -- You must make sure that the header strings follow HTTP specification
+        -- ("Key: Value").
+
+        multipart = boolean
+        -- Optional, if true performs a multipart HTTP request.
+        -- Default is false.
+    }
+
+### `HTTPRequestResult` definition
+
+Passed to `HTTPApiTable.fetch` callback. Returned by
+`HTTPApiTable.fetch_async_get`.
+
+    {
+        completed = true,
+        -- If true, the request has finished (either succeeded, failed or timed
+        -- out)
+
+        succeeded = true,
+        -- If true, the request was successful
+
+        timeout = false,
+        -- If true, the request timed out
+
+        code = 200,
+        -- HTTP status code
+
+        data = "response"
+    }
+
+
 Storage API
 -----------
 
@@ -8054,60 +8101,6 @@ Used by `minetest.add_particlespawner`.
         -- Otherwise, the default behavior is used. (currently: any random tile)
     }
 
-`HTTPRequest` definition
-------------------------
-
-Used by `HTTPApiTable.fetch` and `HTTPApiTable.fetch_async`.
-
-    {
-        url = "http://example.org",
-
-        timeout = 10,
-        -- Timeout for connection in seconds. Default is 3 seconds.
-
-        post_data = "Raw POST request data string" OR {field1 = "data1", field2 = "data2"},
-        -- Optional, if specified a POST request with post_data is performed.
-        -- Accepts both a string and a table. If a table is specified, encodes
-        -- table as x-www-form-urlencoded key-value pairs.
-        -- If post_data is not specified, a GET request is performed instead.
-
-        user_agent = "ExampleUserAgent",
-        -- Optional, if specified replaces the default minetest user agent with
-        -- given string
-
-        extra_headers = { "Accept-Language: en-us", "Accept-Charset: utf-8" },
-        -- Optional, if specified adds additional headers to the HTTP request.
-        -- You must make sure that the header strings follow HTTP specification
-        -- ("Key: Value").
-
-        multipart = boolean
-        -- Optional, if true performs a multipart HTTP request.
-        -- Default is false.
-    }
-
-`HTTPRequestResult` definition
-------------------------------
-
-Passed to `HTTPApiTable.fetch` callback. Returned by
-`HTTPApiTable.fetch_async_get`.
-
-    {
-        completed = true,
-        -- If true, the request has finished (either succeeded, failed or timed
-        -- out)
-
-        succeeded = true,
-        -- If true, the request was successful
-
-        timeout = false,
-        -- If true, the request timed out
-
-        code = 200,
-        -- HTTP status code
-
-        data = "response"
-    }
-
 Authentication handler definition
 ---------------------------------