From c219221d19ef1210bdc5846181e9209b1f519689 Mon Sep 17 00:00:00 2001 From: marco_a <4279489-marco_a@users.noreply.gitlab.com> Date: Sat, 24 Aug 2024 16:41:10 +0200 Subject: [PATCH] DOCS: use correct nomenclature `weap_def` and `weapon` --- DOCS.md | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/DOCS.md b/DOCS.md index 81df155..8a91982 100644 --- a/DOCS.md +++ b/DOCS.md @@ -19,6 +19,10 @@ weapons_lib.register_weapon("mod_name:weapon_name", properties) `properties` is a table containing all the properties that will define the weapon. See the following section to learn about all the available properties. +## Nomenclature +* `weap_def` is the node registration, from where every `weapon` is generated +* `weapon` is the single itemstack + ## Weapon properties Being weapons nodes with extra parameters, all [MT nodes parameters](https://github.com/minetest/minetest/blob/master/doc/lua_api.md#item-definition) are supported by default. Some of them, however, act in a peculiar way and it's not possible to override them: * `range`: (int) melee weapons have `4` by default and it can be overridden. All the rest have `0` and it can't be changed @@ -40,15 +44,15 @@ Then there are the built-in weapons_lib parameters: * `can_alter_speed`: (function(player)) additional checks about whether to prevent slowing down/speeding up again the player * Slowing down is only checked for `slow_down_user` weapons. Speeding up, however, is checked for all weapons due to async issues (i.e. [here](https://gitlab.com/zughy-friends-minetest/weapons_lib/-/issues/12)) * Return `true` to let wapons_lib alter the speed. Related: `wl_slowed_down` metadata -* `on_after_hit`: (function(hitter, weapon, action, objects_hit, total\_damage)) additional behaviour after all the damage has been inflicted to all the targets of a hit +* `on_after_hit`: (function(hitter, weap_def, action, objects_hit, total\_damage)) additional behaviour after all the damage has been inflicted to all the targets of a hit * `objects_hit` is a table containing as many tables as the amount of targets hit. Format: * `ref`: the ObjectRef * `type`: `"player"` or `"entity"` * `damage`: the damage that it should have been inflicted. weapons_lib cannot know if an external mod altered the damage of the weapon (e.g. via `minetest.register_on_punchplayer(..)`) * `total_damage`: the sum of the damage that should have been inflicted to all the targets. weapons_lib cannot know if an external mod altered the damage of the weapon (e.g. via `minetest.register_on_punchplayer(..)`) -* `on_recovery_end`: (function(player, weapon, action)) additional behaviour for when the weapon is ready to be used again -* `on_reload`: (function(player, weapon)) additional behaviour when reloading -* `on_reload_end`: (function(player, weapon, skip_refill)) additional behaviour when the weapon has finished reloading +* `on_recovery_end`: (function(player, weap_def, action)) additional behaviour for when the weapon is ready to be used again +* `on_reload`: (function(player, weap_def)) additional behaviour when reloading +* `on_reload_end`: (function(player, weap_def, skip_refill)) additional behaviour when the weapon has finished reloading * `skip_refill` is a boolean passed when reloading is interrupted (e.g. when switching to another weapon) * `action1`: (table) action on left click * `action2`: (table) action on right click @@ -85,14 +89,14 @@ Actions are tables containing info about how they should work. Actions also supp * `amount`: (int) how many particles to draw along the line. In `bullet` type it's the amount to spawn every second. Defaults to `5` in non bullet types and to `2` in bullet types * `size`: (int) the size of each particle. Default is `1` * `life`: (int) how's gonna last, in seconds. Default is `0.3` -* `on_use`: (function(player, weapon, action, \)) ⚡️🥏👊 additional behaviour when the action is successfully run +* `on_use`: (function(player, weap_def, action, \)) ⚡️🥏👊 additional behaviour when the action is successfully run * `pointed_thing` is only passed with custom and punch action types * if `continuous_fire` is on, the callback is run repeatedly * a must for `"custom"` type to actually do something -* `on_hit`: (function(hitter, target, weapon, action, hit_point, damage, knockback)) ⚡️🥏👊 additional behaviour when hitting a player or an entity +* `on_hit`: (function(hitter, target, weap_def, action, hit_point, damage, knockback)) ⚡️🥏👊 additional behaviour when hitting a player or an entity * It must return the damage that will be inflicted (int) and the knockback (int or `nil`) * `hit_point` only works with type `"raycast"` at the moment, [waiting for MT](https://gitlab.com/zughy-friends-minetest/weapons_lib/-/issues/6) -* `on_end`: (function(player, weapon, action)) ⚡️🥏👊 additional behaviour for when the action reaches its end +* `on_end`: (function(player, weap_def, action)) ⚡️🥏👊 additional behaviour for when the action reaches its end TODO: physics_override con zoom al momento prob dà problemi @@ -144,9 +148,8 @@ Remember to override the itemstack once you've changed its meta, as you're proba * `weapons_lib.refill(p_name, weapon)`: instantly refills the magazine of `weapon` for `p_name`. If the weapon was reloading, it instantly completes the process * `weapons_lib.deactivate_zoom(p_name)`: disables the zoom state of the player, if any * `weapons_lib.reset_state(player)`: resets the weapon state of `player`, instantly completing any ongoing action and setting `wl_slowed_down` to 0 -* `weapons_lib.apply_damage(hitter, targets, weapon, action)`: useful for `"custom"` actions to deal damage +* `weapons_lib.apply_damage(hitter, targets, weap_def, action)`: useful for `"custom"` actions to deal damage * `targets` is a table of tables, one per target hit. Format of these single tables is `{object = ObjRef, hit_point = intersection_point}`. `hit_point` is optional - * `weapon` is the node representing the weapon ## Getters * `weapons_lib.get_weapon_by_name(w_name)`: returns the table of the weapon `w_name`, if any