Well, my goal is implement http post/get request to report and get various stats in a game.
I have already added a web api method to my server, and am now thinking how to implement the client-side code.
The other day I found there is a lua package called luasocket that enabled a http request, but I didn't know how to import the package into my project.
That's why I generalized the question and asked it here.
While waiting your response, I tried some code.
Firstly, according to
this post, I overwrote the original lua code "UI/FrontEnd/MainMenu.lua" with adding the following code to the method "OnOptions()".
- function OnOptions()
- local socket = include("socket")
- client = socket.connect("google.com", 80)
- client:send("GET /robots.txt HTTP/1.0\r\n\r\n")
- client:close()
-
- UIManager:QueuePopup(Controls.Options, PopupPriority.Current);
- Close();
- end
When I enabled the mod and pressed "Options" in the main menu, the Firetuner2 log displayed something wrong.
They indicated that the problem was on the line 4, so I guessed including the package had been done successfully at first.
However, entering "print(socket)" returned nil in the console, which means the package was not loaded.
There are some network function in the original lua codes to communicate with other clients and steam servers,
thus I wonder luasocket or some other packages for network communication might be installed.
Is it possible to access those package within my code, or just let my mod contain the package and include it?