找到你要的答案

Q:Lua Sockets Module cpath

Q:Lua插座模块cpath

I'm trying to use the sockets module in a script and I keep encountering a issue where the script is unable to find socket.core. Is there anyway for me to point to exactly where the core.dll is? I've tried using cpath and I can never seem to get it to work. I just want to be able to say "C:/folder/folder/folder/core.dll"

package.cpath = 'F:/Folder/Foldertwo/Game/agame/Beta/Scripts/libs/socket/?.dll;' .. package.cpath

我试图在一个脚本中使用的插座模块和我一直遇到一个问题,剧本是无法找到socket.core。反正我点的确切位置core.dll是吗?我试着用cpath我似乎从来没有得到它的工作。我只想能说“C:/文件夹/文件/文件夹/核心。dll”

package.cpath = 'F:/Folder/Foldertwo/Game/agame/Beta/Scripts/libs/socket/?.dll;' .. package.cpath
answer1: 回答1:

@EgorSkriptunoff is correct in his comment: socket.lua (which is a lua module) loads socket.core (which is a dynamic library), so you won't be able to load it from folder/core.dll as the default searcher will be looking for socket/core.dll.

If you really want to load it from folder/core.dll, you may try to load it yourself and assign the returned value to package.preload['socket.core']. This way when socket.lua loads the module, it will get the value to return from package.preload key without loading the module.

“EgorSkriptunoff是他的评论是正确的:socket.lua(这是一个Lua模块)负载socket.core(动态库是),所以你不能负荷从文件夹/ core.dll作为默认搜索将寻找插座/ core.dll。

如果你真的想要它加载文件夹/ core.dll,你可能会尝试加载它自己并将返回值分配给包。预[核心] 'socket。这样当socket.lua加载模块,它将获得价值回报从package.preload关键没有加载模块。

lua