Mt5_Roie Posted February 2, 2012 Posted February 2, 2012 so on the developer page it says: "DCS supplies LuaSocket 2.0 Beta files in the Scripts\LuaSocket folder and in the DCS installation folder. " But when I look in the Scripts folder, that folder isn't there. I do see a luasocket folder in the main directory, but talker and listener isn't in there. IS there another installer I need to run to get this working? Coder - Oculus Rift Guy - Court Jester
AlphaOneSix Posted February 2, 2012 Posted February 2, 2012 I beileve that this documentation is only applicable to DCS:BS version 1 and the Lock On series. I don't think that the listener and talker exist anymore in DCS:BS2 and DCS:A10C. That being said, all of the Lua documentation on the DCS website is woefully out of date. Luckily there are several people here on the forums that do a lot of Lua scripting and might be able to offer help if you need anything specific. Other than that, all I can suggest is a lot of trial and error, which is how I do it....well....mostly error.
Mt5_Roie Posted February 2, 2012 Author Posted February 2, 2012 I tried downloading it from the LUA pages but didn't have much success running it. I might just have to use file outputs for testing now. Would be nice to use the sockets since I can test in real time. Coder - Oculus Rift Guy - Court Jester
Headspace Posted February 2, 2012 Posted February 2, 2012 You have access to Luasocket in current releases of DCS. You do not need to supply your own. Look in the directory structure for it.
Mt5_Roie Posted February 2, 2012 Author Posted February 2, 2012 I saw the LUAsocket folder in the main folder. But it didn't have the talker or listerner files in there. Aren't they needed for the operation, or as that changed as well? Coder - Oculus Rift Guy - Court Jester
Headspace Posted February 2, 2012 Posted February 2, 2012 Talker and listener IIRC were just socket implementation examples. I recommend learning about sockets from a technical standpoint in order to properly understand what is going on. That way, you can select a protocol for your mod to use. Most socket implementations (ex: http://www.linuxhowtos.org/C_C++/socket.htm) follow the same design, whether you are using winsock, or unix, or something else. Luasocket is a little simpler.
Speed Posted February 2, 2012 Posted February 2, 2012 Luasocket is included by ED, but not used by ED. You'll need to tell Lua to go and get the files it needs. Try this: -- package.path = package.path..";.\\LuaSocket\\?.lua" -- package.cpath = package.cpath..";.\\LuaSocket\\?.dll" socket = require("socket") If that doesn't work, uncomment the first two lines, then see what happens. I believe that the require function needs to know where to look for various files and that's what package.path and package.cpath do. If by default, they are pointing somewhere else, then you'll probably need to change package.path and package.cpath. This is territory I am not familiar with; I need to look up the require function in the Lua manual. I also have never done an implementation of Luasocket because there has been nothing I needed it for yet; I have a partial programming example but it never worked because before I even finished it, I realized I couldn't get Luasocke tto do what I needed done anyway. I'll show you a send function I made for an experiment: DISCLAIMER: The following was only an experiment, I don't even know if will work: --Luasocket experiment package.path = package.path..";.\\LuaSocket\\?.lua" package.cpath = package.cpath..";.\\LuaSocket\\?.dll" socket = require("socket") function Luasocket_test() local host,port = "localhost", 15001 local ip = socket.dns.toip(host) local udp = socket.udp() print(ip) print(udp) local cmd = "" for i=1, 5 do cmd = "line #"..tostring(i) local var1, var2 = udp:sendto(cmd, ip, port) print(var1) print(var2) end cmd = "quit" udp:sendto(cmd, ip, port) udp:close() print('Luasocket_test()') end I believe that ED has a programming example, certainly better than this one, somewhere. Is that what this "talker" and "listener" functions you keep referring to are from? Intelligent discourse can only begin with the honest admission of your own fallibility. Member of the Virtual Tactical Air Group: http://vtacticalairgroup.com/ Lua scripts and mods: MIssion Scripting Tools (Mist): http://forums.eagle.ru/showthread.php?t=98616 Slmod version 7.0 for DCS: World: http://forums.eagle.ru/showthread.php?t=80979 Now includes remote server administration tools for kicking, banning, loading missions, etc.
AlphaOneSix Posted February 2, 2012 Posted February 2, 2012 I believe that ED has a programming example, certainly better than this one, somewhere. Is that what this "talker" and "listener" functions you keep referring to are from? BS1 and prior had actual Listener.lua and Talker.lua scripts included that you could use to "talk" and "listen" to the sim while it was running, it ran in a Command Line window. It was rather convenient for testing code on the fly for fairly simple things. Those pre-packaged scripts disappeared in DCS:A10C and are also gone from BS2. In fact, they may be missing from BS1.0.2 as well, but I can't remember for sure. EDIT: I can probably just paste the code into this thread for those scripts (or just attach them I suppose) and see if they work with A10C/BS2. I have not tried them yet and I'm at work so I can't look at it right now. if anyone else reading this thread has BS1, they could check it, too.
aaron886 Posted February 3, 2012 Posted February 3, 2012 (edited) Can someone give a definitely-working example of a lua socket? Just something that spits out any value to a local port via TCP/IP. (127.0.0.1:27015) I'm working with FC2. I've got a test program that should be able to pick up data from that address. Hypothetically anyway. Honestly I have no idea what I'm doing. :D Edited February 3, 2012 by aaron886
Mt5_Roie Posted February 3, 2012 Author Posted February 3, 2012 AlphaOneSix, If you can get it to work in DSC A-10 I'd be very interested. I"m looking to be able to get quicker feedback then logfiles. Thanks for your help. BS1 and prior had actual Listener.lua and Talker.lua scripts included that you could use to "talk" and "listen" to the sim while it was running, it ran in a Command Line window. It was rather convenient for testing code on the fly for fairly simple things. Those pre-packaged scripts disappeared in DCS:A10C and are also gone from BS2. In fact, they may be missing from BS1.0.2 as well, but I can't remember for sure. EDIT: I can probably just paste the code into this thread for those scripts (or just attach them I suppose) and see if they work with A10C/BS2. I have not tried them yet and I'm at work so I can't look at it right now. if anyone else reading this thread has BS1, they could check it, too. Coder - Oculus Rift Guy - Court Jester
Headspace Posted February 3, 2012 Posted February 3, 2012 I use Luasocket for TARS, in all iterations of the DCS series. So it definitely works.
Mt5_Roie Posted February 3, 2012 Author Posted February 3, 2012 Headspace, Love TARS. We use it in our squad. Love the new version with the left and right speakers. Did you have to install Lausocket to get it to run in DSC A10C? If so how did you go by installing it? Coder - Oculus Rift Guy - Court Jester
Headspace Posted February 3, 2012 Posted February 3, 2012 No installation needed--it is packaged with DCS.
Mt5_Roie Posted February 3, 2012 Author Posted February 3, 2012 the protocol seems installed. But not the talker and listener. Been looking at code that uses it and am trying to get a app that can get the data so I can start coding. Coder - Oculus Rift Guy - Court Jester
Headspace Posted February 3, 2012 Posted February 3, 2012 I would learn how sockets work and start making test programs by downloading Lua and running it outside of DCS. I wouldn't rely on talker and listener exclusively--your needs might be different.
aaron886 Posted February 3, 2012 Posted February 3, 2012 (edited) Again, talker and listener are just examples. Although it's been buried, my request for help still stands, and further research hasn't yielded me much. Going to continue to try picking through the code of others... http://forums.eagle.ru/showpost.php?p=1391284&postcount=9 Edited February 4, 2012 by aaron886
Recommended Posts