Lua Module not working in HTML5 or Android

Hello, Everyone! I need some help. I have edited the existing Gestures Script into SimpleGesture.Lua. While it works in Defold Build. It does not work in HTML5 or Android. I even checked if they got the “touch” input and they did. But the Lua Module was not working. I even made it in C++ and even that was not working. I cant seem to find the problem. Help will be really appreciated, Thanks!

local M = {}

M.SETTINGS = {
    --- the action to use when detecting gestures
    action_id = hash("touch"),

    --- maximum distance between a pressed and release action to consider it a tap
    tap_threshold = 20,

    --- minimum distance between a pressed and release action to consider it a drag
    drag_threshold = 5,

    --- disable multi touch gestures
    multi_touch = false
}

local function create_state()
    return {
        pressed = false,
        is_dragging = false,
        start_pos = vmath.vector3(),
        previous_pos = vmath.vector3()
    }
end

function M.create(settings)
    settings = settings or M.SETTINGS
    local instance = { state = create_state() }

    function instance.on_input(action_id, action)
        if action_id ~= settings.action_id then return end

        local state = instance.state
        local gestures = {}

        if action.pressed then
            -- Handle multi-touch restriction
            if settings.multi_touch == false and state.pressed then return end

            state.pressed = true
            state.start_pos = vmath.vector3(action.x, action.y, 0)
            state.is_dragging = false
            gestures.tap = true
        elseif action.released then
            if state.pressed then
                gestures.tap_released = true
                state.pressed = false
                state.is_dragging = false
            end
        else -- Movement update
            if state.pressed then
                local current_pos = vmath.vector3(action.x, action.y, 0)
                local dx = math.abs(current_pos.x - state.start_pos.x)
                local dy = math.abs(current_pos.y - state.start_pos.y)
                local distance = math.max(dx, dy)

                -- Check if we should start dragging
                if not state.is_dragging and distance >= settings.drag_threshold then
                    state.is_dragging = true
                end

                -- Send continuous drag updates
                if state.is_dragging and (state.previous_pos.x ~= action.x or state.previous_pos.y ~= action.y) then
                    state.previous_pos = vmath.vector3(action.x, action.y, 0)
                    gestures.drag = {}
                end
            end
        end

        return next(gestures) and gestures or nil
    end

    return instance
end

local instances = {}

function M.on_input(self, action_id, action)
    instances[self] = instances[self] or M.create(M.SETTINGS)
    return instances[self].on_input(action_id, action)
end

return M

I do get a response if i use

if not action.released then

instead of:

if action.pressed then

This problem is the same if i use VSCode Defold Kit Extension. Then my question is why is action.pressed not working with Lua Module outside of Defold Build.

Do you make changes in your own copy of Gestures Script into SimpleGesture.Lua.

Or this file is a part of some dependency?

I used this as base to modify:

You can’t change file inside of dependency.
Copy it all in your root. Remove depency from game.project.

Then make all changes you need

I used the script in a New Project to test the gestures and they worked. It seems the problem was something else. Thank you for your help.