How to load Lua-periphery lib correctly?

82 Views Asked by At

Im using raspbian in a raspberry pi 4 model b with lua 5.3, and luarocks 2.3.0, im trying to install lua-periphery. Im installing the package locally with sudo luarocks install --tree luarocks lua-periphery it's installing the package on version 5.1 and then it outputs this error

lua: error loading module 'periphery' from file 'luarocks/lib/lua/5.1/periphery.so':
luarocks/lib/lua/5.1/periphery.so: undefined symbol: lua_tointeger

This is my script, in my luarocks folder there is no lua/5.3 version

package.path = 'luarocks/share/lua/5.1/?.lua;luarocks/share/lua/5.1/?/init.lua;' .. package.path
package.cpath = 'luarocks/lib/lua/5.1/?.so;' .. package.cpath

local gpio = require("periphery").GPIO

buttons = {22, 23, 24, 26}

for i=1, #buttons do
        local pin = buttons[i]
        buttons[i] = gpio("btt"..pin, pin, "in")
end

while true do
        os.execute("sleep 0.1")

        for i=1, #buttons do
                if buttons[i]:read() == true then
                        print(i)
                end
        end
end

I tried changing the lua version used by luarocks and didn't worked, I installed luaver and set the lua version to 5.3.3 and didn't worked. I think the problem is due to the version of luarocks is using, but I dont know how to change the version to the version im using, or if the problem is another thing.

0

There are 0 best solutions below