WIP: controls:android:fix bow/rocket/spyglass/burger_follow #4066

Draft
Bakawun wants to merge 1 commits from Bakawun/MineClone2:android_support into master
1 changed files with 46 additions and 0 deletions

View File

@ -0,0 +1,46 @@
minetest.register_on_mods_loaded(function()
for name in pairs(minetest.registered_items) do
if name:find("bow") then
minetest.override_item(name, {
touch_controls = {
pointed_nothing = "short_dig_long_place",
pointed_node = "short_dig_long_place",
pointed_object = "short_dig_long_place",
},
})
end
end
for name in pairs(minetest.registered_items) do
if name:find("spyglass") then
minetest.override_item(name, {
touch_controls = {
pointed_nothing = "short_dig_long_place",
pointed_node = "short_dig_long_place",
pointed_object = "short_dig_long_place",
},
})
end
end
for name in pairs(minetest.registered_items) do
if name:find("rocket") then
minetest.override_item(name, {
touch_controls = {
pointed_nothing = "short_dig_long_place",
pointed_node = "short_dig_long_place",
pointed_object = "short_dig_long_place",
},
})
end
end
for name in pairs(minetest.registered_items) do
if name:find("hamburger") then
minetest.override_item(name, {
touch_controls = {

This is duplicated 4 times. It would be better as a variable and just reference it.

But on reflection, why are we overriding the item? Can we not just add touch controls to the definitions for these items?

The logic for this is quite expensive, as you'd iterate over item, check for 1 name. Iterate over every item, check for another. Checking for the different names during that iteration would be better, but unless there is a good reason not to, these touch controls could be put on the item. Would this impact on desktop if these were on, or does it just add additional controls to the items?

This is duplicated 4 times. It would be better as a variable and just reference it. But on reflection, why are we overriding the item? Can we not just add touch controls to the definitions for these items? The logic for this is quite expensive, as you'd iterate over item, check for 1 name. Iterate over every item, check for another. Checking for the different names during that iteration would be better, but unless there is a good reason not to, these touch controls could be put on the item. Would this impact on desktop if these were on, or does it just add additional controls to the items?
pointed_nothing = "short_dig_long_place",
pointed_node = "short_dig_long_place",
pointed_object = "short_dig_long_place",
},
})
end
end
end)