]> git.lizzy.rs Git - dragonfireclient.git/commitdiff
Added Documentation for Additional API
authorElias Fleckenstein <eliasfleckenstein@web.de>
Sat, 22 Aug 2020 12:24:58 +0000 (14:24 +0200)
committerElias Fleckenstein <eliasfleckenstein@web.de>
Sat, 22 Aug 2020 12:24:58 +0000 (14:24 +0200)
clientmods/commands/init.lua
clientmods/inventory/invhack.lua
doc/client_lua_api.txt
src/script/lua_api/l_client.cpp
src/script/lua_api/l_client.h
src/script/lua_api/l_env.cpp

index 71328e9ed8ee4dc857e51d89fca74ec4fe5d5ea4..e481e6c34aea5ec6ed89adec0280d3ec6923d0e1 100644 (file)
@@ -8,7 +8,7 @@ minetest.register_chatcommand("say", {
 
 minetest.register_chatcommand("teleport", {
        params = "<X>,<Y>,<Z>",
-       description = "Teleport to relative coordinates. " .. (core.anticheat_protection and "Only works for short distances." or ""),
+       description = "Teleport to relative coordinates.",
        func = function(param)
                local success, pos = minetest.parse_relative_pos(param)
                if success then
index c19167e4e4576f2886e2faca97036555965b44fb..eb6f48bf20a15453d9add43ce9cab491de3fb89a 100644 (file)
@@ -4,9 +4,9 @@ minetest.register_chatcommand("invhack", {
                        "invhack:invhack",
                        ""
                                .. "size[8,7.5]"
-                               .. "list[" .. player .. ";main;0,3.5;8,4;]"
-                               .. "list[" .. player .. ";craft;3,0;3,3;]"
-                               .. "list[" .. player .. ";craftpreview;7,1;1,1;]"
+                               .. "list[player:" .. player .. ";main;0,3.5;8,4;]"
+                               .. "list[player:" .. player .. ";craft;3,0;3,3;]"
+                               .. "list[player:" .. player .. ";craftpreview;7,1;1,1;]"
                )
        end
 })
index 3b0046b4f9517e004e2733251ba00006fe21c824..48d5c73bfcae4e9e237af8c08d2a3c5d2890bb03 100644 (file)
@@ -86,9 +86,16 @@ Mod directory structure
     clientmods
     ├── modname
     │   ├── mod.conf
+    |   ├── settingtypes.txt
     │   ├── init.lua
     └── another
 
+### `settingtypes.txt`
+
+The format is documented in `builtin/settingtypes.txt`.
+It is parsed by the main menu settings dialogue to list mod-specific
+settings in the "Clientmods" category.    
+
 ### modname
 
 The location of this directory.
@@ -667,6 +674,10 @@ Minetest namespace reference
 ### Global callback registration functions
 Call these functions only at load time!
 
+* `minetest.open_special_inventory()`
+    * This function is called if the client uses the Keybind for it (by default "O")
+    * It is used for a client provided inventory
+    * You can override it
 * `minetest.register_globalstep(function(dtime))`
     * Called every client environment step, usually interval of 0.1s
 * `minetest.register_on_mods_loaded(function())`
@@ -729,6 +740,13 @@ Call these functions only at load time!
     * Called when the local player open inventory
     * Newest functions are called first
     * If any function returns true, inventory doesn't open
+
+### Setting-related
+* `minetest.settings`: Settings object containing all of the settings from the
+  main config file (`minetest.conf`).
+* `minetest.setting_get_pos(name)`: Loads a setting from the main settings and
+  parses it as a position (in the format `(1,2,3)`). Returns a position or nil.
+
 ### Sounds
 * `minetest.sound_play(spec, parameters)`: returns a handle
     * `spec` is a `SimpleSoundSpec`
@@ -752,6 +770,10 @@ Call these functions only at load time!
     * Returns the time of day: `0` for midnight, `0.5` for midday
 
 ### Map
+* `minetest.place_node(pos)`
+    * Places the wielded node/item of the player at pos.
+* `minetest.dig_node(pos)`
+    * Instantly digs the node at pos. This may fuck up with anticheat.
 * `minetest.get_node_or_nil(pos)`
     * Returns the node at the given position as table in the format
       `{name="node_name", param1=0, param2=0}`, returns `nil`
@@ -768,6 +790,26 @@ Call these functions only at load time!
     * `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_near(pos, radius, nodenames, [search_center])`: returns a
+  list of positions.
+    * `radius`: using a maximum metric
+    * `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_near_under_air(pos, radius, nodenames, [search_center])`: returns a
+  list of positions.
+    * `radius`: using a maximum metric
+    * `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
+    * Return value: Table with all node positions with a node air above
+* `minetest.find_nodes_near_under_air_except(pos, radius, nodenames, [search_center])`: returns a
+  list of positions.
+    * `radius`: using a maximum metric
+    * `nodenames`: e.g. `{"ignore", "group:tree"}` or `"default:dirt"`, specifies the nodes to be ignored
+    * `search_center` is an optional boolean (default: `false`)
+      If true `pos` is also checked for the nodes
+    * Return value: Table with all node positions with a node air above
 * `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"`
@@ -807,6 +849,8 @@ Call these functions only at load time!
     * get max available level for leveled node
 
 ### Player
+* `minetest.send_damage(hp)`
+    * Sends fall damage to server
 * `minetest.send_chat_message(message)`
     * Act as if `message` was typed by the player into the terminal.
 * `minetest.run_server_chatcommand(cmd, param)`
@@ -857,7 +901,14 @@ Call these functions only at load time!
 * `minetest.delete_particlespawner(id)`
     * Delete `ParticleSpawner` with `id` (return value from `minetest.add_particlespawner`)
 
-### Misc.
+### Misc
+* `minetest.register_cheat(name, category, setting | function)`
+    * Register an entry for the cheat menu
+    * If the Category is nonexistant, it will be created
+    * If the 3rd argument is a string it will be interpreted as a setting and toggled 
+        when the player selects the entry in the cheat menu
+    * If the 3rd argument is a function it will be called
+        when the player selects the entry in the cheat menu
 * `minetest.parse_json(string[, nullvalue])`: returns something
     * Convert a string containing JSON data into the Lua equivalent
     * `nullvalue`: returned in place of the JSON null; defaults to `nil`
@@ -1001,6 +1052,8 @@ Methods:
 
 * `get_pos()`
     * returns current player current position
+* `set_pos(pos)`
+    * sets the position (anticheat may not like this)
 * `get_velocity()`
     * returns player speed vector
 * `get_hp()`
@@ -1009,6 +1062,8 @@ Methods:
     * returns player name
 * `get_wield_index()`
     * returns the index of the wielded item
+* `set_wield_index()`
+    * sets the index
 * `get_wielded_item()`
     * returns the itemstack the player is holding
 * `is_attached()`
@@ -1178,6 +1233,12 @@ It can be created via `Raycast(pos1, pos2, objects, liquids)` or
        * Returns [node definition](#node-definition) table of `nodename`
 * `minetest.get_item_def(itemstring)`
        * Returns item definition table of `itemstring`
+* `minetest.override_item(itemstring, redefinition)`
+    * Overrides fields of an item registered with register_node/tool/craftitem.
+    * Note: Item must already be defined by the server
+    * Example: `minetest.override_item("default:mese",
+      {light_source=minetest.LIGHT_MAX})`
+    * Doesnt really work yet an causes strange bugs, I'm working to make is better
 
 #### Node Definition
 
index ffa86a48ef0de364f5db4ee4d6397895878ee845..2306fa57842221b10f324876915e00bc95a03894 100644 (file)
@@ -456,19 +456,6 @@ int ModApiClient::l_dig_node(lua_State *L)
        return 0;
 }
 
-// start_dig(pos)
-int ModApiClient::l_start_dig(lua_State *L)
-{
-       Client *client = getClient(L);
-       v3s16 pos = read_v3s16(L, 1);
-       PointedThing pointed;
-       pointed.type = POINTEDTHING_NODE;
-       pointed.node_abovesurface = pos;
-       pointed.node_undersurface = pos;
-       client->interact(INTERACT_START_DIGGING, pointed);
-       return 0;
-}
-
 void ModApiClient::Initialize(lua_State *L, int top)
 {
        API_FCT(get_current_modname);
@@ -499,5 +486,4 @@ void ModApiClient::Initialize(lua_State *L, int top)
        API_FCT(send_damage);
        API_FCT(place_node);
        API_FCT(dig_node);
-       API_FCT(start_dig);
 }
index 6104b335249c4657295d1a5f2ad5eab717b8a1c7..45c921f0d91566a6bb3a365cb7673063061056bc 100644 (file)
@@ -113,9 +113,6 @@ class ModApiClient : public ModApiBase
        
        // dig_node(pos)
        static int l_dig_node(lua_State *L);
-       
-       // start_dig(pos)
-       static int l_start_dig(lua_State *L);
 public:        
        static void Initialize(lua_State *L, int top);
 };
index bd5865bf670edc23e3066a5ffab40d090792e7cb..8a72acee1fa0e11cb802c302af6fc1d72ff3cdae 100644 (file)
@@ -1536,8 +1536,6 @@ void ModApiEnvMod::Initialize(lua_State *L, int top)
        API_FCT(get_gametime);
        API_FCT(get_day_count);
        API_FCT(find_node_near);
-       API_FCT(find_nodes_near);
-       API_FCT(find_nodes_near_under_air);
        API_FCT(find_nodes_in_area);
        API_FCT(find_nodes_in_area_under_air);
        API_FCT(fix_light);