From c3c88e5b460aaa69466993c08f1c8fbb02b983d2 Mon Sep 17 00:00:00 2001 From: alek13 Date: Mon, 22 Sep 2025 06:02:50 +0300 Subject: [PATCH] Modern Lua Plugins: fix errors in `mods/lord/Core/physics`. LG-1980 --- classes/ObjectRef/Player.lua | 82 +++++++++++++++++++++++++++++++++--- 1 file changed, 76 insertions(+), 6 deletions(-) diff --git a/classes/ObjectRef/Player.lua b/classes/ObjectRef/Player.lua index 60e0fe5..b2fa22e 100644 --- a/classes/ObjectRef/Player.lua +++ b/classes/ObjectRef/Player.lua @@ -10,46 +10,59 @@ function Player:get_inventory() end --- returns `""` if is not a player --- @return string function Player:get_player_name() end + --- **DEPRECATED**, use get_velocity() instead. --- table {x, y, z} representing the player's instantaneous velocity in nodes/s --- @deprecated function Player:get_player_velocity() end + --- **DEPRECATED**, use add_velocity(vel) instead. --- @deprecated function Player:add_player_velocity(vel) end + --- get camera direction as a unit vector function Player:get_look_dir() end + --- pitch in radians --- * Angle ranges between -pi/2 and pi/2, which are straight up and down --- respectively. function Player:get_look_vertical() end + --- yaw in radians --- * Angle is counter-clockwise from the +z direction. --- @return number function Player:get_look_horizontal() end + --- sets look pitch --- * radians: Angle from looking forward, where positive is downwards. function Player:set_look_vertical(radians) end + --- sets look yaw --- * radians: Angle from the +z direction, where positive is counter-clockwise. function Player:set_look_horizontal(radians) end + --- pitch in radians - Deprecated as broken. Use --- `get_look_vertical`. --- * Angle ranges between -pi/2 and pi/2, which are straight down and up --- respectively. function Player:get_look_pitch() end + --- yaw in radians - Deprecated as broken. Use --- `get_look_horizontal`. --- * Angle is counter-clockwise from the +x direction. --- @deprecated function Player:get_look_yaw() end + --- sets look pitch - Deprecated. Use `set_look_vertical`. function Player:set_look_pitch(radians) end + --- sets look yaw - Deprecated. Use --- `set_look_horizontal`. function Player:set_look_yaw(radians) end + --- returns player's breath function Player:get_breath() end + --- sets player's breath --- * values: --- * `0`: player is drowning @@ -57,6 +70,7 @@ function Player:get_breath() end --- * See [Object properties] for more information --- * Is limited to range 0 ... 65535 (2^16 - 1) function Player:set_breath(value) end + --- Sets player's FOV --- * `fov`: FOV value. --- * `is_multiplier`: Set to `true` if the FOV value is a multiplier. @@ -66,38 +80,47 @@ function Player:set_breath(value) end --- If set to 0, FOV change is instantaneous. Defaults to 0. --- * Set `fov` to 0 to clear FOV override. function Player:set_fov(fov, is_multiplier, transition_time) end + --- Returns the following: --- * Server-sent FOV value. Returns 0 if an FOV override doesn't exist. --- * Boolean indicating whether the FOV value is a multiplier. --- * Time (in seconds) taken for the FOV transition. Set by `set_fov`. function Player:get_fov() end + --- DEPRECATED, use get_meta() instead --- * Sets an extra attribute with value on player. --- * `value` must be a string, or a number which will be converted to a --- string. --- * If `value` is `nil`, remove attribute from player. function Player:set_attribute(attribute, value) end + --- DEPRECATED, use get_meta() instead --- * Returns value (a string) for extra attribute. --- * Returns `nil` if no attribute found. function Player:get_attribute(attribute) end + --- Returns a PlayerMetaRef. --- @return PlayerMetaRef function Player:get_meta() end + --- * Redefine player's inventory form --- * Should usually be called in `on_joinplayer` --- * If `formspec` is `""`, the player's inventory is disabled. function Player:set_inventory_formspec(formspec) end + --- returns a formspec string function Player:get_inventory_formspec() end + --- * the formspec string will be added to every formspec shown to the user, --- except for those with a no_prepend[] tag. --- * This should be used to set style elements such as background[] and --- bgcolor[], any non-style elements (eg: label) may result in weird behavior. --- * Only affects formspecs shown after this is called. function Player:set_formspec_prepend(formspec) end + --- returns a formspec string. function Player:get_formspec_prepend(formspec) end + --- returns table with player pressed keys --- * The table consists of fields with the following boolean values --- representing the pressed keys: `up`, `down`, `left`, `right`, `jump`, @@ -108,6 +131,7 @@ function Player:get_formspec_prepend(formspec) end --- --- @return table function Player:get_player_control() end + --- returns integer with bit packed player pressed --- keys. --- * Bits: @@ -126,12 +150,22 @@ function Player:get_player_control() end function Player:get_player_control_bits() end --- @class physics_override_table ---- @field speed number multiplier to default walking speed value (default: `1`) ---- @field jump number multiplier to default jump value (default: `1`) ---- @field gravity number multiplier to default gravity value (default: `1`) ---- @field sneak number whether player can sneak (default: `true`) ---- @field sneak_glitch number whether player can use the new move code replications of the old sneak side-effects: sneak ladders and 2 node sneak jump (default: `false`) ---- @field new_move number use new move/sneak code. When `false` the exact old code is used for the specific old sneak behavior (default: `true`) +--- @field speed? number multiplier to default walking speed value (default: `1`) +--- @field speed_walk? number multiplier to default walk speed value (default: `1`). Note: The actual walk speed is the product of `speed` and `speed_walk` +--- @field speed_climb? number multiplier to default climb speed value (default: `1`). Note: The actual climb speed is the product of `speed` and `speed_climb` +--- @field speed_crouch? number multiplier to default crouch speed value (default: `1`). Note: The actual crouch speed is the product of `speed` and `speed_crouch` +--- @field speed_fast? number multiplier to default fast (sprint) speed value (default: `1`). Note: The actual fast speed is the product of `speed` and `speed_fast` +--- @field jump? number multiplier to default jump value (default: `1`) +--- @field gravity? number multiplier to default gravity value (default: `1`) +--- @field liquid_fluidity? number multiplier to liquid movement resistance value (for nodes with `liquid_move_physics`); the higher this value, the lower the resistance to movement. At math.huge, the resistance is zero and you can move through any liquid like air. (default: `1`). Warning: Values below 1 are currently unsupported. +--- @field liquid_fluidity_smooth? number multiplier to default maximum liquid resistance value (for nodes with `liquid_move_physics`); controls deceleration when entering node at high speed. At higher values you come to a halt more quickly (default: `1`) +--- @field liquid_sink? number multiplier to default liquid sinking speed value; (for nodes with `liquid_move_physics`), (default: `1`) +--- @field acceleration_default? number multiplier to default acceleration value (default: `1`). Note: The actual acceleration is the product of `speed` and `acceleration_default` +--- @field acceleration_air? number multiplier to default air acceleration value (default: `1`). Note: The actual air acceleration is the product of `speed` and `acceleration_air` +--- @field acceleration_fast? number multiplier to default fast (sprint) acceleration (default: `1`). Note: The actual fast acceleration is the product of `speed` and `acceleration_fast` +--- @field sneak? boolean whether player can sneak (default: `true`) +--- @field sneak_glitch? boolean whether player can use the new move code replications of the old sneak side-effects: sneak ladders and 2 node sneak jump (default: `false`) +--- @field new_move? boolean use new move/sneak code. When `false` the exact old code is used for the specific old sneak behavior (default: `true`) --- set physics override for player --- * `override_table` is a table with the following fields: @@ -146,21 +180,27 @@ function Player:get_player_control_bits() end --- is used for the specific old sneak behavior (default: `true`) --- @param override_table physics_override_table function Player:set_physics_override(override_table) end + --- returns the table given to `set_physics_override` --- @return physics_override_table function Player:get_physics_override() end + --- add a HUD element described by HUD def, returns ID --- number on success function Player:hud_add(hud_definition) end + --- remove the HUD element of the specified id function Player:hud_remove(id) end + --- change a value of a previously added HUD --- element. --- * `stat` supports the same keys as in the hud definition table except for --- `"hud_elem_type"`. function Player:hud_change(id, stat, value) end + --- gets the HUD element definition structure of the specified ID function Player:hud_get(id) end + --- sets specified HUD flags of player. --- * `flags`: A table with the following fields set to boolean values --- * `hotbar` @@ -176,22 +216,30 @@ function Player:hud_get(id) end --- Does not affect players with the `debug` privilege. --- * If a flag equals `nil`, the flag is not modified function Player:hud_set_flags(flags) end + --- returns a table of player HUD flags with boolean values. --- * See `hud_set_flags` for a list of flags that can be toggled. function Player:hud_get_flags() end + --- sets number of items in builtin hotbar ---- * `count`: number of items, must be between `1` and `32` function Player:hud_set_hotbar_itemcount(count) end + --- returns number of visible items function Player:hud_get_hotbar_itemcount() end + --- * sets background image for hotbar function Player:hud_set_hotbar_image(texturename) end + --- returns texturename function Player:hud_get_hotbar_image() end + --- * sets image for selected item of hotbar function Player:hud_set_hotbar_selected_image(texturename) end + --- returns texturename function Player:hud_get_hotbar_selected_image() end + --- modes_list: {mode, mode, ...} --- * Overrides the available minimap modes (and toggle order), and changes the --- selected mode. @@ -214,6 +262,7 @@ function Player:hud_get_hotbar_selected_image() end --- * `selected_mode` is the mode index to be selected after modes have been changed --- (0 is the first mode). function Player:set_minimap_modes(modes_list, selected_mode) end + --- * The presence of the function `set_sun`, `set_moon` or `set_stars` indicates --- whether `set_sky` accepts this format. Check the legacy format otherwise. --- * Passing no arguments resets the sky to its default values. @@ -276,6 +325,7 @@ function Player:set_minimap_modes(modes_list, selected_mode) end --- (default: `"#00000000"`, which means no override) --- @param sky_parameters table function Player:set_sky(sky_parameters) end + --- * Deprecated. Use `set_sky(sky_parameters)` --- * `base_color`: ColorSpec, defaults to white --- * `type`: Available types: @@ -285,16 +335,19 @@ function Player:set_sky(sky_parameters) end --- * `clouds`: Boolean for whether clouds appear in front of `"skybox"` or --- `"plain"` custom skyboxes (default: `true`) function Player:set_sky(base_color, type, texture_names, clouds) end + --- * `as_table`: boolean that determines whether the deprecated version of this --- function is being used. --- * `true` returns a table containing sky parameters as defined in `set_sky(sky_parameters)`. --- * Deprecated: `false` or `nil` returns base_color, type, table of textures, --- clouds. function Player:get_sky(as_table) end + --- * Deprecated: Use `get_sky(as_table)` instead. --- * returns a table with the `sky_color` parameters as in `set_sky`. --- @deprecated function Player:get_sky_color() end + --- * Passing no arguments resets the sun to its default values. --- * `sun_parameters` is a table with the following optional fields: --- * `visible`: Boolean for whether the sun is visible. @@ -313,9 +366,11 @@ function Player:get_sky_color() end --- Note: For legacy reasons, the sun is bigger than the moon by a factor --- of about `1.57` for equal `scale` values. function Player:set_sun(sun_parameters) end + --- returns a table with the current sun parameters as in --- `set_sun`. function Player:get_sun() end + --- * Passing no arguments resets the moon to its default values. --- * `moon_parameters` is a table with the following optional fields: --- * `visible`: Boolean for whether the moon is visible. @@ -332,9 +387,11 @@ function Player:get_sun() end --- Note: For legacy reasons, the sun is bigger than the moon by a factor --- of about `1.57` for equal `scale` values. function Player:set_moon(moon_parameters) end + --- returns a table with the current moon parameters as in --- `set_moon`. function Player:get_moon() end + --- * Passing no arguments resets stars to their default values. --- * `star_parameters` is a table with the following optional fields: --- * `visible`: Boolean for whether the stars are visible. @@ -350,9 +407,11 @@ function Player:get_moon() end --- (default: `#ebebff69`) --- * `scale`: Float controlling the overall size of the stars (default: `1`) function Player:set_stars(star_parameters) end + --- returns a table with the current stars parameters as in --- `set_stars`. function Player:get_stars() end + --- set cloud parameters --- * Passing no arguments resets clouds to their default values. --- * `cloud_parameters` is a table with the following optional fields: @@ -367,35 +426,44 @@ function Player:get_stars() end --- * `speed`: 2D cloud speed + direction in nodes per second --- (default `{x=0, z=-2}`). function Player:set_clouds(cloud_parameters) end + --- returns a table with the current cloud parameters as in --- `set_clouds`. function Player:get_clouds() end + --- * `0`...`1`: Overrides day-night ratio, controlling sunlight to a specific --- amount. --- * `nil`: Disables override, defaulting to sunlight based on day-night cycle function Player:override_day_night_ratio(ratio) end + --- returns the ratio or nil if it isn't overridden function Player:get_day_night_ratio() end + --- set animation for player model in third person view. --- * Every animation equals to a `{x=starting frame, y=ending frame}` table. --- * `frame_speed` sets the animations frame speed. Default is 30. function Player:set_local_animation(idle, walk, dig, walk_while_dig, frame_speed) end + --- returns idle, walk, dig, walk_while_dig tables and --- `frame_speed`. function Player:get_local_animation() end + --- defines offset vectors for --- camera per player. An argument defaults to `{x=0, y=0, z=0}` if unspecified. --- * in first person view --- * in third person view (max. values `{x=-10/10,y=-10,15,z=-5/5}`) --- v -- [firstperson, thirdperson] function Player:set_eye_offset(v) end + --- returns first and third person offsets. function Player:get_eye_offset() end + --- * Sends an already loaded mapblock to the player. --- * Returns `false` if nothing was sent (note that this can also mean that --- the client already has the block) --- * Resource intensive - use sparsely function Player:send_mapblock(blockpos) end + --- sets lighting for the player --- * `light_definition` is a table with the following optional fields: --- * `saturation` sets the saturation (vividness). @@ -406,9 +474,11 @@ function Player:send_mapblock(blockpos) end --- * `intensity` sets the intensity of the shadows from 0 (no shadows, default) to 1 (blackness) --- * This value has no effect on clients who have the "Dynamic Shadows" shader disabled. function Player:set_lighting(light_definition) end + --- returns the current state of lighting for the player. --- * Result is a table with the same fields as `light_definition` in `set_lighting`. function Player:get_lighting() end + --- Respawns the player using the same mechanism as the death screen, --- including calling on_respawnplayer callbacks. function Player:respawn() end