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
Touchscreen: Allow mods to swap the meaning of short and long taps (punch with single tap) #14087
Conversation
What does "hint" mean? Is there some kind of textual hint that allows android players to know what to do? If so, that text should be customizable: e.g. Instead of the bows having a short_tap assigned to a "dig" textual hint, the mod should be able to set it to "draw bow". |
No, there are no textual hints. If you think that players will need them, you can add them yourself, e.g. via item descriptions or HUDs. Maybe the field should be named |
Yes, that is less confusing. |
Very nice, works great. Is it possible to also make the spyglass and rocket work? Edit: got spyglass to work by adding the same code but with bow replaced by spyglass. Rockets can't get working, I tried both variants but it just waves the rocket |
👍
The MineClone 2 implementation of rockets only supports launching rockets while flying with an elytra: https://git.minetest.land/MineClone2/MineClone2/src/commit/d4797e13af1e6f7c6cf2806790e8d0a2be448e5d/mods/ITEMS/mcl_fireworks/register.lua#L12-L22 I suppose the rockets would still benefit from "short_dig_long_place". |
When doing the long press to charge a bow or zoom in with the spyglass I can't move to aim, is that expected? Also the rocket worked too after I used it while flying (using the short_dig_long_place) |
Yes, that's unfortunately expected if you haven't enabled I recommend enabling |
Could you help with making the off hand shield work, with this change long pressing no longer raises it |
I assume we're still talking about MineClone 2 or similar. According to my testing, there are two ways to use a shield in that game: in the main hand or in the off-hand. Both ways require holding the place button, so the shield can't possibly work on Android without this PR. Modders can make the shield work in the main hand easily, using the same approach as for the bow. Making the shield work in the off-hand is more complicated. The only sane approaches I can think of are:
So this is outside the scope of this PR. |
When I add
|
If we're still talking about MineClone 2 or similar: No, that's not expected. If we're talking about a different bow mod: I don't know, I'd need to know which one. Different bow mods have different controls, some don't require you to draw the bow first. Make sure to add |
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.
Can we use other name than touch-control hint? How about touch-control mechanic, touch-control action plan, or touch-control tap action?
What I meant by "touch control hint" was that the field is a hint as to what touch controls might work for the item, given by modders to Minetest because Minetest can't figure it out on its own. While I agree that the name is bad, I'm not convinced by any of these suggestions either, partly because they're all longer than the current name. Since this name is only internal, it probably doesn't matter much anyway. We could just adopt the external name ( |
Yes it's MineClone2
|
c06fa3c
to
2aacdde
Compare
You're only adding |
2aacdde
to
279e0fb
Compare
Rebased again because of the |
152d3db
to
951129b
Compare
Needs a rebase, feel free to merge afterwards. |
951129b
to
5bd2bf9
Compare
I found two more bugs while rebasing, but now it should actually be ready to merge 😅 |
Currently, short tap is hardcoded as "place" and long tap is hardcoded as "dig". This PR allows mods to swap the meaning of short and long taps, depending on the wielded item and the
pointed_thing
type. This is done by adding a new field to item definitions:Although this is only a very limited amount of customizability, it already solves two important problems:
Items that require holding the place button can be made usable. Fixes Hold Interact on mobile #8543.
A prime example of this are bows and crossbows in MineClone 2. They are currently completely unusable on Android because they must be drawn by holding the place button. With this PR, all you need to do is to add the following code to their item definitions:
And you have usable bows on Android!
It becomes possible to punch with short taps.
Currently, you have to do a long tap to punch another player or an entity. This is very bad for combat, as you have to wait 500 ms each time you want to punch your opponent. During these 500 ms you can't change your look direction, so it's trivial for your opponent to dodge the punch. To make things even worse, you can't keep your finger on the screen to punch continously because of commit 94feb62.
With this PR, you can make punching with short taps possible by adding the following code to item definitions:
This not only fixes the problems described above, but it is also the behavior that players know from popular games such as Minecraft and MultiCraft.
Because of these advantages, this PR makes punching with short taps the default.
Alternatives
These problems could also be solved by adding separate on-screen buttons for placing and digging. I plan to implement that as another option at some point and have already created a prototype: #13229 (comment).
However, I think that touch controls without additional on-screen buttons can and should work as well, as they are easier to understand for beginners and can be quite comfortable if you aren't doing PvP.
To do
This PR is a Ready for Review.
Please give feedback on the concept, the API, the implementation, etc.!
How to test
Play a MineClone 2 world on your Android phone. Verify that you can now punch mobs with a short tap. Verify that the rest of the touch controls still works as usual and that bows are still unusable.
Now put the following code into a mod:
Rejoin your world and see that bows have become usable.