Forums » General
I want to write a plug-in!
I want to write a plug-in!
If there are any samples and video, please post the website below!
By noob
If there are any samples and video, please post the website below!
By noob
Try:
http://lua-users.org/wiki/TutorialDirectory
http://www.vo-wiki.com/racecar2/index.php/Main_Page
http://lua-users.org/wiki/TutorialDirectory
http://www.vo-wiki.com/racecar2/index.php/Main_Page
I'm relatively new to Vendetta (3/4/2/2/1) and playing on an Oculus Go which is superb but obviously suffers from lack of keyboard. I'm thinking of writing a voice control app for a Google Home (and/or Amazon Echo) so I can speak commands and have them injected via the plugin API. Primarily my interest is chat but looking at the API, the possibilities are endless - 'jetison cargo', 'plot course to Dau L-11', 'get me out of here fast' etc. Like Firefox or Blakes 7 if you're old and sad enough to remember them.
So I notice that the plugins are lua scripts and I've never done lua before but it looks pretty simple. Is it possible to write a lua plug-in script that calls a HTTP server and blocks waiting for the response ? When it gets the response, this can be lua code which it executes and then calls back awaiting the next command ? Obviously if this was on a UI thread it would be a terribly bad thing to do but I don't know the architecture here hence the question. Thx
So I notice that the plugins are lua scripts and I've never done lua before but it looks pretty simple. Is it possible to write a lua plug-in script that calls a HTTP server and blocks waiting for the response ? When it gets the response, this can be lua code which it executes and then calls back awaiting the next command ? Obviously if this was on a UI thread it would be a terribly bad thing to do but I don't know the architecture here hence the question. Thx
You certainly can make http calls, although from what I remember no-one ever wrote an https implementation.
I don't think you want to block though. As far as I know all of the lua code runs on one thread, which does indeed include the UI. Probably better to poll frequently, and have your http server respond with a "nothing exciting happened since last request" type of message most of the time.
(I'm actually not sure it would even be possible to set up the http call so that it blocks everything else, so you might be ok to just do what you planned to originally. It's been a long time since I've messed with vendetta's sockets, but a quick scan of this page suggests that you can't.)
I don't think you want to block though. As far as I know all of the lua code runs on one thread, which does indeed include the UI. Probably better to poll frequently, and have your http server respond with a "nothing exciting happened since last request" type of message most of the time.
(I'm actually not sure it would even be possible to set up the http call so that it blocks everything else, so you might be ok to just do what you planned to originally. It's been a long time since I've messed with vendetta's sockets, but a quick scan of this page suggests that you can't.)
As the linked page indicates, the TCP sockets are non-blocking. One thing to keep in mind is that plugins have to stop running or give up control intermittently, or else the client will hang and you will be disconnected from the game. The other issue, as genka indicated, is that I don't think it's even possible to make HTTPS connections, because all SSL libraries I've seen would need to be compiled into the Lua implementation or in some way loaded, which is a functionality that I'm pretty sure was removed from the sandbox. If you're just trying to access a personal server and HTTP is sufficient, you should be fine. There are a few copies of httplib floating around or incorporated into various publicly available plugins.
A threaded call should prevent the game locking up.
I did not see anything limiting http calls but I also don't recall seeing the protocol in that library either.
Having an outside link to a database has been done a few times already, so worst case using an external slave program to access the web and then relaying it in game should be doable. The old roidDb plugin could shed some light on the process if you can find a copy.
I did not see anything limiting http calls but I also don't recall seeing the protocol in that library either.
Having an outside link to a database has been done a few times already, so worst case using an external slave program to access the web and then relaying it in game should be doable. The old roidDb plugin could shed some light on the process if you can find a copy.