我正在尝试在LUA脚本中导入插座,以在游戏中制作Twitch聊天应用程序。
LUA的游戏实施“旨在与Luajit的Openresty fork合作,并编译了5.2兼容选项的Luajit。” ()
我不熟悉lua,但我一直在试图让它工作几天,但进展不多。
我尝试了带有插座/网络插款的不同存储库,但无法使它们工作。
尝试 local套接字= require(“ socket”)
我会得到以下错误
[
module 'socket.core' not found: no field package.preload['socket.core']
no file '\socket\core.lua'
no file 'E:\steam\SteamApps\common\assettocorsa\ua\socket\core.lua'
no file 'E:\steam\SteamApps\common\assettocorsa\Jua\socket\core\init.lua'
no file 'C:\Program Files (x86)\Lua\5.1\Jua\socket\core.luac'
no file 'E:\steam\SteamApps\common\assettocorsa\apps\lua\My FirstApp/socket\core.lua'
no file 'E:\steam\SteamApps\common\assettocorsa\extension/internal/lua-socket\core.lua'
no file '\socket\core.dil'
no file 'E:\steam\SteamApps\common\assettocorsa\socket\core.dil'
no file 'E:\steam\SteamApps\common\assettocorsa\Vloadall.dll'
no file '.\socket.dll'
no file 'E:\steam\SteamApps\common\assettocorsa\socket.dll'
no file 'E:\steam\SteamApps\common\assettocorsa\loadall.dll' [C]: in function 'require
...mApps\common\assettocorsa\apps\lua\My FirstApp/socket.lua:12: in main chunk [C]: in function 'require'
...s\common\assettocorsa\apps\lua\My FirstApp\MyFirstApp.lua:13: in main chunk
] [1],
如果我正确理解了socket.core通常是LUA语言中包含的内容机器。但是我需要将其包含在应用程序中,以便也可以与其他人共享。
从我的理解中,我需要为Lua 5.1制作的东西,并为Windows编译。该游戏默认为64位,但可以被迫进行32位,因此我假设理想情况下我需要2个DLL。
这主要是为什么我一直在努力获取此特定解决方案( https://github.com/luapower/插座)工作,因为它们包括Pre Build dlls,我假设它包含插座运行所需的一切。但是我无法获得上面的错误要消失。
由于我对LUA和总体编程的了解不足,我也无法建立自己的DLL,更重要的是,我不确定该构建什么是为了确保它对此特定的用户酶有效。
一般而言,整个LUA的东西似乎超级不友好,这只会增加我的困惑,因此对我如何继续进行工作的任何见解将不胜感激。我可以提供进一步的信息。
编辑:看来我对需要在哪里寻找文件的理解是错误的。我已经将文件移至一个单独的文件夹中,现在得到错误:错误加载模块socket.core“从文件”。\ socket \ core.dll:%1不是有效的win32应用程序。 [C]:在0x7ffd961fb3c0 [c]:在功能'require'... s \ common \ common \ common \ assettocorsa \ apps \ lua \ myfirstapp \ myfirstapp \ myfirstapp.lua:16:in main chunk
,所以我猜它是在运行lua in in lua in inua 32位?我试图从DIFF存储库中获取一些编译的套接字/core.dll,它们都给出了错误。.我用依赖性沃克检查了,有些是32位,而另一些则是64位DLL。无论如何,同样的错误。
[1]: https://i.sstatic.net/mdexh.png
I'm Trying to import sockets in a lua script to make a twitch chat app inside a game.
The game implementation of lua is "Designed to work with OpenResty’s fork of LuaJIT, with LuaJIT compiled with 5.2 compatibility option." (https://github.com/ac-custom-shaders-patch/acc-lua-sdk/)
I am not familiar with lua but I have been trying to get this to work for a few days but with not much progress.
I have tried different repositories with sockets/websockets but could not get them to work.
when trying local socket = require("socket")
I get the following error
[
module 'socket.core' not found: no field package.preload['socket.core']
no file '\socket\core.lua'
no file 'E:\steam\SteamApps\common\assettocorsa\ua\socket\core.lua'
no file 'E:\steam\SteamApps\common\assettocorsa\Jua\socket\core\init.lua'
no file 'C:\Program Files (x86)\Lua\5.1\Jua\socket\core.luac'
no file 'E:\steam\SteamApps\common\assettocorsa\apps\lua\My FirstApp/socket\core.lua'
no file 'E:\steam\SteamApps\common\assettocorsa\extension/internal/lua-socket\core.lua'
no file '\socket\core.dil'
no file 'E:\steam\SteamApps\common\assettocorsa\socket\core.dil'
no file 'E:\steam\SteamApps\common\assettocorsa\Vloadall.dll'
no file '.\socket.dll'
no file 'E:\steam\SteamApps\common\assettocorsa\socket.dll'
no file 'E:\steam\SteamApps\common\assettocorsa\loadall.dll' [C]: in function 'require
...mApps\common\assettocorsa\apps\lua\My FirstApp/socket.lua:12: in main chunk [C]: in function 'require'
...s\common\assettocorsa\apps\lua\My FirstApp\MyFirstApp.lua:13: in main chunk
][1]
If I understood this correctly that socket.core is normally something included in the lua language that would be installed on the machine. But I need this to be included with the app so it can be shared to other people as well.
From my understanding I need something made for lua 5.1 and compiled for windows. The game runs in 64bits by default but can be forced to 32 bits so i'm assuming ideally i'd need 2 dlls.
This is mostly why I've been trying hard to get this particular solution (https://github.com/luapower/socket) to work as they include pre build dlls which I'm assuming contain everything needed for socket to run. But I can't get the error above to go away.
I have also not been able to build my own dll due to my lack of understanding of lua and programming in general and more importantly i'm not sure what to build exactly to make sure it would work for this particular usecase.
The whole lua stuff seems to be super unfriendly to use on windows in general which only adds to my confusion so any insight on how I could proceed to get this to work would be greatly appreciated. I can supply further info neeeded.
edit: it seems that my understanding of where require was looking for files was wrong. I've moved the files to a separate folder and I now get Error: error loading module socket.core' from file '.\socket\core.dll: %1 is not a valid Win32 application. [C]: at 0x7ffd961fb3c0 [C]: in function 'require' ...s\common\assettocorsa\apps\lua\MyFirstApp\MyFirstApp.lua:16: in main chunk
So I guess it's running lua in 32 bits? I tried to grab some compiled socket/core.dll from diff repos and they all give the error.. I checked with dependency walker and some were 32 bits and others were 64bits dlls. Same error regardless.
[1]: https://i.sstatic.net/Mdexh.png
发布评论
评论(1)
请注意, [github]:luapower/socket 以来em>。另外,目录结构似乎不正确。 (应该在那里提到的东西)它是用 lua 5.1 构建(并运行的)。
我已经构建了 v3.0.0 ,并将二进制文件放在: [github]:cristifati/prepuilt-binaries-(主)预构建二元组/luasocket/v3 (用 lua 5.4.4.4 构建的 /strong>,应用来运行它)。
这是一个例子:
如前所述,我还介绍了 pc064 / pc032 .dll 不匹配。有关更多详细信息,请检查 [so]:python ctypes-加载dll抛出Oserror:[Winerror 193]%1不是有效的Win32应用程序(@cristifati的答案)。
Note that there are no commits in [GitHub]: luapower/socket since Nov 2019. Also, the directory structure doesn't seem correct. And (something that should have been mentioned there) it was built (and runs) with Lua 5.1.
I've built v3.0.0 and placed the binaries at: [GitHub]: CristiFati/Prebuilt-Binaries - (master) Prebuilt-Binaries/LuaSocket/v3 (built with Lua 5.4.4 from the same repository, which should be used to run it).
Here's an example:
As seen, I also covered the pc064 / pc032 .dll mismatch. For more details, check [SO]: Python Ctypes - loading dll throws OSError: [WinError 193] %1 is not a valid Win32 application (@CristiFati's answer).