-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is "EntityDefinition.on_punched" a Valid Callback? #57
Comments
this looks like a typo: i grepped through my known modlist and some other 3d-armor related mods and could not find any references to |
well as i know in minetest there's no such derfinition at https://github.com/minetest/minetest/blob/8dfeba02b9f084ddd52090ccd906534200f468b3/src/script/cpp_api/s_entity.cpp#L239 .. but maybe is a definition of the 3d_armor mod? @BuckarooBanzay ? |
I think i get it now: this isn't a callback on an entity, this is on the armor-definition 🤔 The local list = armor_inv:get_list("armor") -- <---- HERE
for i, stack in pairs(list) do
if stack:get_count() == 1 then
local itemname = stack:get_name()
local use = minetest.get_item_group(itemname, "armor_use") or 0
local damage = use > 0
local def = stack:get_definition() or {} -- <----- HERE
if type(def.on_punched) == "function" then
damage = def.on_punched(player, hitter, time_from_last_punch,
tool_capabilities) ~= false and damage == true
end This might just be an undocumented (and unused) feature after all 🤷 |
but i not found a definition documented neither used so that piece may confuse others.. what should be do in this case? erased (with danger to break some misterious not knowed others mods that use it) or let as is and coumented? that is working!? i changed to punch but seems i nete raised that part of the code.. |
I don't think that needs changing: |
i searched so much in code and i cannot find any reference to
the older repo has https://github.com/stujones11/minetest-3d_armor/search?q=on_punched it has a definition documented in the api but not in code, it describes https://github.com/stujones11/minetest-3d_armor/blob/47ecef46f75c977a3d256ac4bab2874c24b785af/3d_armor/README.txt#L85 as aditional field for register_armor over the tool to pass to minetest core .. but currently there is no such definition in any part of code.. inclusivelly was removed from admin shield finally due register_armor will always end in register_tool searchiv at the definition of tool item i cannot found anything https://minetest.gitlab.io/minetest/definition-tables/#item-definition neither in 3d_armor code.. so i guess any of us as implementer will define the "on_punched" function so can this be documented in the docs and readme more clear? @BuckarooBanzay |
example of usage: stujones11@8e8c79a
Important must retunr always false if no valid logic code is defined |
…punch" to on_punched * related to https://codeberg.org/minenux/minetest-mod-3d_armor/issues/57 * related to minetest-mods#57
|
Looking through the API I found a line that calls
EntityDefinition.on_punched
. But is this actually doing anything? Looking through Minetest's Lua API docs, I don't see anyon_punched
callback. Onlyon_punch
.The text was updated successfully, but these errors were encountered: