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
Tool specific pointing and blocking pointable type #13992
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Should be mostly fine otherwise.
- Please add a feature flag in
core.features
. - Would it make sense to trigger
on_rightclick
andon_punch
callbacks for blocking nodes, with pointability in pointed thing? This would be useful to e.g. implement lava that hurts when you try touching it. - Pointabilities are not checked server-side, right? (I.e. a modified client can trigger an
on_punch
of a non pointable node.) It might be worth writing this down in the doc. - (Haven't tested thoroughly yet (e.g. with multiple players, and performance impact).)
games/devtest/mods/testnodes/textures/testnodes_blocking_pointable.png
Outdated
Show resolved
Hide resolved
Done.
I don't think this would make much sense. The whole purpose of blocking-pointable is that it can't be interacted with, like non-pointable. (For example you can't use it as surface to place nodes on it.)
Done.
I have tested it a little bit but haven't made benchmarks, the performance impact should be negligible. Thanks for the review, I hope I solved everything appropriately and didn't miss anything. |
It's rebased now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for letting you wait!
Also, I don't think it would be good to have interactable nodes that don't show a selection box.
👍
games/devtest/mods/testnodes/textures/testnodes_blocking_pointable.png
Outdated
Show resolved
Hide resolved
Tested thoroughly, found no issues. 🎉 Just one thing: Please modify the testtools (remover, branding iron, ...) in devtest to make them able to point the test entities. One limitation that I've noticed is that lua raycasts don't support pointabilities yet. But I would put that in another PR, because this limitation is not new, i.e. lua raycasts can not iterate through air or other non-pointable nodes in master either. Tested:
local pos1 = me:get_pos():offset(0, me:get_properties().eye_height, 0)
local raycast = core.raycast(pos1, pos1 + me:get_look_dir()*4, true, true)
for pt in raycast do
if pt.type == "node" then
print(core.get_node(pt.under).name)
elseif pt.type == "object" then
if pt.ref:is_player() then print("player") else print("luaent") end
else
print("unknown")
end
end (This would be nice to have as a testtool, for testing lua raycasts in general, btw..) |
OK, now all testtools that work on objects can point Pointable Test Objects. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code-only review so far. I still have to test this properly, but it looks good so far; my comments are all rather minor, nothing critical.
Throughout the code, I see duplications for object / node pointabilities which effectively use the same structure (groups + names). Why not abstract that with a class?
A metadata API (like for tool capabilities) would be nice for this, but that can come later.
and add blocking pointable type
Thanks for the review. I hope I addressed everything appropriately.
If I understudy you correctly you want to have a class consisting of two unordered maps, one for groups and one for names, with then provides some functions. Imo it would be more important to add more abstractions to the object class code, since there is a lot of duplication in server active objects and client active objects. |
Deduplicate pointable fields in testtool defs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! Tested everything ({hand, blocking pointable staff, ultimate pointable staff, test tools ...} x pointable nodes x pointable entities), works as expected.
Nitpick I found while testing: The light testtool and node meta privatizer can't be used on the blocking and non pointable test node. The latter is probably completely irrelevant; you might want to change the former, but I don't have any strong feelings on this as I don't think the light levels of pointable test nodes are particularly interesting.
Goal of the PR
How does the PR work?
pointabilities
in the item definition, to accomplish tool specific pointable properties different to what is specified in the Item or Object definition.blocking
pointable type which is not selectable and not point through.pointabilities
field in the item definition looks like this:(The API has been discuses and should be fine.)
It contains lists to override the 'pointable' property of pointed nodes and objects. The index can be a node/entity name or a group with the prefix "group:". (For objects
armor_groups
are used.) If multiple fields fit, a priority order is applied.The
liquids_pointable
is kept as is. It could be marked as deprecated and refer to using groups instead, but usually nodes with the liquids drawtype are not assigned to a liquids group. So I guess it can stay as a semi-useful feature.Does this relate to a goal in the roadmap?
Some concrete Usecases
To do
Ready for review.
It is waiting for feature freeze of version 5.8.0 to be done.5.8.0 got released(Maybe some followup PRs, to generally refactor code and move properties of the item definition (like range) into tool_capabilities to allow dynamic change, should be done.)
How to test