luqiming666 / lua_windows_build

Try to build Lua source codes using Visual Studio on Windows
Apache License 2.0
0 stars 0 forks source link

[Query]: How to add luasocket support #1

Open Dafeigy opened 3 months ago

Dafeigy commented 3 months ago

Hi, I read your blog post "Which Lua intepreter version is used in Hades", very nice work and it enlighten me so much!

I want to if know can we add external lua package to used in Hades? I currently want to use UDP socket to send enemies' position information to my AI Host machine, however when I modified any lua scripts in game folders when using:

require(socket)

the game will crash(obviously).

I still don't want to give up yet, so here I am to ask this question whether the socket can be used in lua without crashed in game.

Thank you for reading this issue~

luqiming666 commented 3 months ago

I'm not very experienced in lua programming. Thus I don't know why require(socket) leads to a crash. But I do have an idea for your task: you can create a Lua-ready DLL (please refer to https://github.com/luqiming666/simple-lua-c-dll), and put all socket-related codes in this DLL. When the DLL is ready, you can call it in lua codes as I mentioned in my article.

Dafeigy commented 3 months ago

I'm not very experienced in lua programming. Thus I don't know why require(socket) leads to a crash. But I do have an idea for your task: you can create a Lua-ready DLL (please refer to https://github.com/luqiming666/simple-lua-c-dll), and put all socket-related codes in this DLL. When the DLL is ready, you can call it in lua codes as I mentioned in my article.

Thanks, I will have a try if any progress is made I will update in this issue. Thanks again for your help :)

Dafeigy commented 3 months ago

I follow your post and Successfully build my lua.dll, and the lua-c-dll it works fine with my built Lua.exe. However, when I put the my modified lua-c-dll.dll to the game folders, and load it in Game's Lua script, it will crashed with some utf-encoding-error messages; I then add my liblua.dll built by me and then from another logging tools I observed "Multiple VMs detected". Have you ever encounter this problem? BTW I used this in Hades2.

luqiming666 commented 3 months ago

I didn't get a chance to try Hades2 yet.

luqiming666 commented 3 months ago

I didn't get a chance to try Hades2 yet.