Hey, I was just wondering if there's a fast way to communicate with external applications (other than simply writing to a file).
A friend noted the possibility of using a socket -- is there a sockets interface exposed in the NS2 Lua environment?
McGlaspiewww.team156.comJoin Date: 2010-07-26Member: 73044Members, Super Administrators, Forum Admins, NS2 Developer, NS2 Playtester, Squad Five Blue, Squad Five Silver, Squad Five Gold, Reinforced - Onos, WC 2013 - Gold, Subnautica Playtester
Nope. NS2 essentially operates in a sandbox. If it didn't, this would be a potential security exploit that a malicious mod could take advantage of, which would be quite bad.
Hmm, I assume scripts cannot write to files either, then (even within the NS2 directory)?
Maybe a HTTP request could work.
I'm just looking for a safe way for a script within NS2 to talk to an external script - writing to a file and having the external script read from it wouldn't work well for the angle and positional data frequency I'd imagine; or at the very least, it'd be very inefficient.
A local UDP or even TCP socket would be perfect (not entirely sure how this could pose a major security threat all things considered, but I believe you), but given the lack of that capability, I wonder if the references I'm finding to Shared.SendHTTPRequest would allow a client script to send data locally to an application acting like a HTTP server - alas I've found the documentation fairly hit-and-miss so I've not had much luck exploring it.
For what it's worth, I'm looking at attempting some Mumble integration; the NS2 client transmits the player's position and the direction they're viewing, and the Mumble plugin side takes this, and passes it on to the Mumble server which uses it to produce positional audio effects for people who are playing, are in the Mumble channel and have positional audio enabled.
Out of the two, if HTTP requests (only outgoing is needed) are still supported, they'd easily be the best way to do it.
The extra fluff of a HTTP request vs just sending what I need over a socket shouldn't mean too much considering its over localhost.
Is there much documentation on using sendHTTPRequest? I'm in the process of searching for any references to it in existing game lua code.
Yeah looking at the results, it appears that this would be by far the best way of getting the data out. The only big issue then is that I doubt this could be run client side.
Comments
Maybe a HTTP request could work.
I'm just looking for a safe way for a script within NS2 to talk to an external script - writing to a file and having the external script read from it wouldn't work well for the angle and positional data frequency I'd imagine; or at the very least, it'd be very inefficient.
A local UDP or even TCP socket would be perfect (not entirely sure how this could pose a major security threat all things considered, but I believe you), but given the lack of that capability, I wonder if the references I'm finding to Shared.SendHTTPRequest would allow a client script to send data locally to an application acting like a HTTP server - alas I've found the documentation fairly hit-and-miss so I've not had much luck exploring it.
For what it's worth, I'm looking at attempting some Mumble integration; the NS2 client transmits the player's position and the direction they're viewing, and the Mumble plugin side takes this, and passes it on to the Mumble server which uses it to produce positional audio effects for people who are playing, are in the Mumble channel and have positional audio enabled.
The extra fluff of a HTTP request vs just sending what I need over a socket shouldn't mean too much considering its over localhost.
Is there much documentation on using sendHTTPRequest? I'm in the process of searching for any references to it in existing game lua code.
Yeah looking at the results, it appears that this would be by far the best way of getting the data out. The only big issue then is that I doubt this could be run client side.
Not really arguing the merits or downsides of using external voice comms in pub games here.
You are talking about a completely different thing.
Yeah you are right.