]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - doc/client_lua_api.md
Replace inconsistent mentions of core.* with minetest.* (#5749)
[dragonfireclient.git] / doc / client_lua_api.md
index b2aeb3f251b36b0dbe860b991b31bc89e130d02b..19947a525682390c48849492426676b59daba3da 100644 (file)
@@ -667,6 +667,12 @@ Call these functions only at load time!
     * Called when the local player punches a node
     * Newest functions are called first
     * If any function returns true, the punch is ignored
+* `minetest.register_on_placenode(function(pointed_thing, node))`    
+    * Called when a node has been placed
+* `minetest.register_on_item_use(func(item, pointed_thing))`
+    * Called when the local player uses an item.
+    * Newest functions are called first.
+    * If any function returns true, the item use is not sent to server.
 ### Sounds
 * `minetest.sound_play(spec, parameters)`: returns a handle
     * `spec` is a `SimpleSoundSpec`
@@ -692,7 +698,7 @@ Call these functions only at load time!
 * `minetest.get_wielded_item()`
     * Returns the itemstack the local player is holding
 * `minetest.localplayer`
-    * Reference to the LocalPlayer object. See `LocalPlayer` class reference for methods.
+    * Reference to the LocalPlayer object. See [`LocalPlayer`](#localplayer) class reference for methods.
 
 ### Client Environment
 * `minetest.get_player_names()`
@@ -700,9 +706,10 @@ Call these functions only at load time!
 * `minetest.disconnect()`
     * Disconnect from the server and exit to main menu.
     * Returns `false` if the client is already disconnecting otherwise returns `true`.
-* `minetest.get_protocol_version()`
-    * Returns the protocol version of the server.
-    * Might not be accurate at start up as the client might not be connected to the server yet, in that case it will return 0.
+* `minetest.take_screenshot()`
+    * Take a screenshot.
+* `minetest.get_server_info()`
+    * Returns [server info](#server-info).
 
 ### Misc.
 * `minetest.parse_json(string[, nullvalue])`: returns something
@@ -747,7 +754,7 @@ Call these functions only at load time!
     * Encodes a string in base64.
 * `minetest.decode_base64(string)`: returns string
     * Decodes a string encoded in base64.
-* `minetest.gettext(string) : returns string
+* `minetest.gettext(string)` : returns string
     * look up the translation of a string in the gettext message catalog
 * `fgettext_ne(string, ...)`
     * call minetest.gettext(string), replace "$1"..."$9" with the given
@@ -759,7 +766,9 @@ Call these functions only at load time!
 
 ### UI
 * `minetest.ui.minimap`
-    * Reference to the minimap object. See `Minimap` class reference for methods.
+    * Reference to the minimap object. See [`Minimap`](#minimap) class reference for methods.
+* `minetest.camera`
+    * Reference to the camera object. See [`Camera`](#camera) class reference for methods.
 * `minetest.show_formspec(formname, formspec)` : returns true on success
        * Shows a formspec to the player
 * `minetest.display_chat_message(message)` returns true on success
@@ -782,6 +791,40 @@ An interface to manipulate minimap on client UI
 * `set_shape(shape)`: Sets the minimap shape. (0 = square, 1 = round)
 * `get_shape()`: Gets the minimap shape. (0 = square, 1 = round)
 
+### Camera
+An interface to get or set information about the camera and cameranode.
+Please do not try to access the reference until the camera is initialized, otherwise the reference will be nil.
+
+#### Methods
+* `set_camera_mode(mode)`
+    * Pass `0` for first-person, `1` for third person, and `2` for third person front
+* `get_camera_mode()`
+    * Returns with same syntax as above
+* `get_fov()`
+    * Returns:
+    
+```lua
+     {
+         x = number,
+         y = number,
+         max = number,
+         actual = number
+     }
+```
+    
+* `get_pos()`
+    * Returns position of camera with view bobbing
+* `get_offset()`
+    * Returns eye offset vector
+* `get_look_dir()`
+    * Returns eye direction unit vector
+* `get_look_vertical()`
+    * Returns pitch in radians
+* `get_look_horizontal()`
+    * Returns yaw in radians
+* `get_aspect_ratio()`
+    * Returns aspect ratio of screen
+
 ### LocalPlayer
 An interface to retrieve information about the player. The player is
 not accessible until the client is fully done loading and therefore
@@ -806,8 +849,6 @@ Methods:
     * returns player HP
 * `get_name()`
     * returns player name
-* `got_teleported()`
-    * returns true if player was teleported
 * `is_attached()`
     * returns true if player is attached
 * `is_touching_ground()`
@@ -843,16 +884,6 @@ Methods:
     * returns last player speed
 * `get_breath()`
     * returns the player's breath
-* `get_look_dir()`
-    * returns look direction vector
-* `get_look_horizontal()`
-    * returns look horizontal angle
-* `get_look_vertical()`
-    * returns look vertical angle
-* `get_eye_pos()`
-    * returns the player's eye position
-* `get_eye_offset()`
-    * returns the player's eye shift vector
 * `get_movement_acceleration()`
     * returns acceleration of the player in different environments:
 
@@ -930,9 +961,18 @@ Can be obtained via `minetest.get_meta(pos)`.
     {
         params = "<name> <privilege>", -- Short parameter description
         description = "Remove privilege from player", -- Full description
-        func = function(param), -- Called when command is run.
-                                      -- Returns boolean success and text output.
+        func = function(param),        -- Called when command is run.
+                                       -- Returns boolean success and text output.
     }
+### Server info
+```lua
+{
+       address = "minetest.example.org", -- The domain name/IP address of a remote server or "" for a local server.
+       ip = "203.0.113.156",             -- The IP address of the server.
+       port = 30000,                     -- The port the client is connected to.
+       protocol_version = 30             -- Will not be accurate at start up as the client might not be connected to the server yet, in that case it will be 0.
+}
+```
 
 Escape sequences
 ----------------