Jump to content

JAG

Members
  • Posts

    185
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by JAG

  1. Nop, I'm still using 1.0, there are changes between version 1.0 and 1.01 concerning lua?
  2. Finally the console windows, show info. With all the arguments listed before it doesn't work, then I test with only local t = LoGetModelTime(). It shows data, many times, but at some point like 3 or more minutes it suddenly stops and no info were added. Is that a failure in the communication with Lua or is the way that method works? But when I go back and try to add more values to show, it doesn't work. This is the last one I tried. local t = LoGetModelTime() local MainPanel = GetDevice(0) local lamp = MainPanel:get_argument_value(175) socket.try(c:send(string.format("t = %.2f, lamp = %.2f", t, lamp))) Cheers
  3. Hi pogo, I'm not an expert, still learning, but I think I can help you with this one. In the export.lua script, there is a function that allows you to send info to the sim, and is this: function LuaExportBeforeNextFrame() -- Works just before every simulation frame. -- Call Lo*() functions to set data to Lock On here -- For example: -- LoSetCommand(3, 0.25) -- rudder 0.25 right -- LoSetCommand(64) -- increase thrust end This function listen for any input that need to be applied before the simulation continue, it use for example move the rudder a little bit to the right or increase thrust. I imagine you could send it, through keyboard, joystick or a homemade device. Good luck with your project Un saludo
  4. Hi again, I tried with another code for TCPListener, and things are going different. The new code was made in a console project, and when it start it works this way. 1- Start the console project, and inmediately shows the message "Waiting for a connection..." 2- When the mission starts, it shows, "Waiting for a connection... Connected!" 3- During the mission no messages of cockpit values are added 4- Finish the mission and the next messages appear: Received: quit Sent: QUIT Waiting for a connection... Could the missing part, be in export.lua? After this I look into the error.log and at the end it shows many times the next line: Lua::Config::call error LuaExportAfterNextFrame:./Config/Export/Export.lua:73: attempt to call method 'get_argument_value' (a nil value) and the line 73 in the export.lua is: "local slip = MainPanel:get_argument_value(108 ) Now I have a doubt, all lines begining from 73 to n lines are wrong, or the script don't check the rest of the lines, and stop in the first wrong sentence it found? Un saludo
  5. That "t" :thumbup: local t = LoGetModelTime() By the way I found another thing, it's not showing values, it only show the "receiving from server..." message, and repeat it again and again. Sorry if I don't checked it properly, but I was doing all this at 2am, and thinking more in sleep, than put attention to the console windows. Thanks :smilewink:
  6. Hi, I was using IpAddress the first time, then I change to IpAddress.Parse("127.0.0.1"), about that "t" it's one include in export.lua?, If that the case, the only t I found there is in the next function and it looks like this function LuaExportActivityNextEvent(t) local tNext = t -- Put your event code here and increase tNext for the next event -- so this function will be called automatically at your custom -- model times. -- If tNext == t then the activity will be terminated. -- For example: -- 1) File -- local o = LoGetWorldObjects() -- for k,v in pairs(o) do -- io.write(string.format("t = %.2f, ID = %d, name = %s, country = %s(%s), LatLongAlt = (%f, %f, %f), heading = %f\n", t, k, v.Name, v.Country, v.Coalition, v.LatLongAlt.Lat, v.LatLongAlt.Long, v.LatLongAlt.Alt, v.Heading)) -- end -- local trg = LoGetLockedTargetInformation() -- io.write(string.format("locked targets ,time = %.2f\n",t)) -- for i,cur in pairs(trg) do -- io.write(string.format("ID = %d, position = (%f,%f,%f) , V = (%f,%f,%f),flags = 0x%x\n",cur.ID,cur.position.p.x,cur.position.p.y,cur.position.p.z,cur.velocity.x,cur.velocity.y,cur.velocity.z,cur.flags)) -- end -- local route = LoGetRoute() -- io.write(string.format("t = %f\n",t)) -- if route then -- io.write(string.format("Goto_point :\n point_num = %d ,wpt_pos = (%f, %f ,%f) ,next %d\n",route.goto_point.this_point_num,route.goto_point.world_point.x,route.goto_point.world_point.y,route.goto_point.world_point.z,route.goto_point.next_point_num)) -- io.write(string.format("Route points:\n")) -- for num,wpt in pairs(route.route) do -- io.write(string.format("point_num = %d ,wpt_pos = (%f, %f ,%f) ,next %d\n",wpt.this_point_num,wpt.world_point.x,wpt.world_point.y,wpt.world_point.z,wpt.next_point_num)) -- end -- end -- local stations = LoGetPayloadInfo() -- if stations then -- io.write(string.format("Current = %d \n",stations.CurrentStation)) -- for i_st,st in pairs (stations.Stations) do -- local name = LoGetNameByType(st.weapon.level1,st.weapon.level2,st.weapon.level3,st.weapon.level4); -- if name then -- io.write(string.format("weapon = %s ,count = %d \n",name,st.count)) -- else -- io.write(string.format("weapon = {%d,%d,%d,%d} ,count = %d \n", st.weapon.level1,st.weapon.level2,st.weapon.level3,st.weapon.level4,st.count)) -- end -- end -- end -- local Nav = LoGetNavigationInfo() -- if Nav then -- io.write(string.format("%s ,%s ,ACS: %s\n",Nav.SystemMode.master,Nav.SystemMode.submode,Nav.ACS.mode)) -- io.write(string.format("Requirements :\n\t roll %d\n\t pitch %d\n\t speed %d\n",Nav.Requirements.roll,Nav.Requirements.pitch,Nav.Requirements.speed)) -- end -- tNext = tNext + 1.0 -- 2) Socket -- local o = LoGetWorldObjects() -- for k,v in pairs(o) do -- socket.try(c:send(string.format("t = %.2f, ID = %d, name = %s, country = %s(%s), LatLongAlt = (%f, %f, %f), heading = %f\n", t, k, v.Name, v.Country, v.Coalition, v.LatLongAlt.x, v.LatLongAlt.Long, v.LatLongAlt.Alt, v.Heading))) -- end -- tNext = tNext + 1.0 return tNext end Un saludo Update: I checked again the code, and I was wrong, it's no sending values at 1 or 2 minutes after the mission starts, if start to show the values, when the mission is over.
  7. The vb version finally works, at some point it start to show the info, but not at the begining of the mission, maybe a minute or more after and now it don't stop showing it. I finish the mission and the console windows don't stop. Looks like the while loop, never receive the false condition, it's supose when the mission finish the lua script close the TCP connection. With your code, it show you the values, as soon as the mission starts and stop showing it, when the mission is over?
  8. I will add a Try Catch just in case, by the way, I will try you code in C# and see what happend. It's funny because in the university I never liked C jajajajjaaja, but I have to program in it, I always tried, to program in VB since then. Un saludo :thumbup:
  9. The console is not throwing an exception, it's just the way I explained. JAjajajaja Why you hate VB, it's cool :lol: By the way it's VB, but the .Net version 2008 Here is the code, it's the same, just with the vb sintax ------------------------------------------------------ Imports System.Net.Sockets Imports System.IO Imports System.Net Module Module1 Sub Main() Dim reader As StreamReader Dim data As String Dim listener As TcpListener = New TcpListener(IPAddress.Any, 8080) listener.Start() Dim sock As Socket = listener.AcceptSocket() Dim serverstream As NetworkStream = New NetworkStream(sock) reader = New StreamReader(serverstream) While True Console.Write("receiving from server...") data = reader.ReadLine() Console.Write(data) End While End Sub End Module
  10. Hi again, I tried with the code you posted with a Console project and it works but with an exception. At the begining I was using ip address assigned to my network card, and it doesn't work, then I change the ip address to "127.0.0.1" and it works, but it only shows the message "receiving from server..." and that is all, after the message no data is added to the console window. This are the lines I added to the export.lua, without the commented lines. function LuaExportStart() package.path = package.path..";.\\LuaSocket\\?.lua" package.cpath = package.cpath..";.\\LuaSocket\\?.dll" socket = require("socket") host = "127.0.0.1" port = 8080 c = socket.try(socket.connect(host, port)) -- connect to the listener socket c:setoption("tcp-nodelay",true) -- set immediate transmission mode end function LuaExportAfterNextFrame() local t = LoGetModelTime() local MainPanel = GetDevice(0) local slip = MainPanel:get_argument_value(108) local ias = MainPanel:get_argument_value(51) local mc = MainPanel:get_argument_value(44) local vsi = MainPanel:get_argument_value(24) local turn = MainPanel:get_argument_value(437) local aa = MainPanel:get_argument_value(438) local gmt = MainPanel:get_argument_value(440) local hoa = MainPanel:get_argument_value(439) local rst = MainPanel:get_argument_value(441) socket.try(c:send(string.format("t = %.2f, slip = %.2f, ias = %.2f, mc = %.2f, vsi = %.2f, turn = %.2f, aa = %.2f, gmt = %.2f, hoa = %.2f, rst = %.2f\n", t, slip, ias, mc, vsi, turn, aa, gmt, hoa, rst))) end function LuaExportStop() socket.try(c:send("quit")) -- to close the listener socket c:close() end I set the value in the Config.lua to true, It's there anything else to configure?
  11. This time there are many questions guys, and this is getting better and better :smilewink:. I been programming with vb before, but I'm new with lua, so I have many doubts, for example of where to put the code for the TCP connection and how to start sending data to be received by the program created in vb, where to specify the values I need for the cockpit, how to run the script and many others, so I return to the DCS page that trigger post, and find a few answers, and looks like everything must be written in exportl.lua, so I get to the conclusion, you don't have to run the scripts or create them, they are executed by the game, the only thing you have to do is to find the script file that have the functionality you require, especify the values you need, and show or use that values the way you need. Am I right? Then I keep reading the content of the file, I found something interesting: 1- It says, that this file starts to work before the simulation begin. If that's true, that answer my question of how to start the script. 2- It says also, that the TCP connection must be started there, in the same file, export.lua, hey more good news. 3- At the begining of the file it talks about LockOn, and I remember that ruprecht said, this information is a little bit outdated. Is this file still used to send data? 4- In the same page, mention that a value in the Config.lua file, must be set to true, to enable the export.lua file, to work. If this true, because I did it? 5- If the TCP connection must be specified in export.lua, can I use the code written there, and what about this two lines of code? -- package.path = package.path..";.\\LuaSocket\\?.lua" -- package.cpath = package.cpath..";.\\LuaSocket\\?.dll" Must be enabled, or modify it's route, pointing to some file? It looks like all must be done in export.lua, then start the external program that listen the TCP port, the game and finally look at the values received. Is this how things must be done? It's there a way to test the tcp connection from export.lua, sending data without starting the game? Thanks :thumbup:
  12. Thanks :thumbup:
  13. If I understand, the TCP will be used when you want to send LUA values to another pc, but in my case, I don't need to send it to another pc, instead I need to read those values in the computer that is generating them, and read them in real time with vb.net. How could those values be readed?
  14. Ok, I will read a few more things about LUA and as soon as posible I'll start to work in my project. If I have another doubt I will post. Thanks guys Un saludo (Cheers)
  15. One more question, I have planned to use the values obtained with LUA with another program, for example VB.Net. In the info, it says that LUA generate a script file whit the values, but my doubt is, if I want to know for example the speed of the chopper, LUA will be generating a script file, every second? If that the case, it's no problem, but can the values given by LUA, be readed in real time, by another program, instead or be reading script files every second. Or If I'm misunderstanding how LUA works, how could the values generated by LUA, be readed for another program, in this case VB.NET, in real time? Saludos
  16. Both links provides very interesting info about what I need, and now I have more questions. :lol: I'll keep looking for info, because I need to learn many things to achieve the results I'm looking for. I really appreciate your help, thank you very much. :thumbup:
  17. Hello, anyone could tell me where can I found info or a tutorial about getting cockpit data from the game ant handle it whit LUA? Thanks
  18. Thanks :doh:
  19. Hi guys, anyone knows, where can I find a good tutorial on how to obtain cockpit data from the game using LUA. Thanks :smilewink:
  20. Cool that sounds really fun, it remind me a street near the downtown in my city, the street is straight and suddenly it goes down, and when I'm on the bus you can feel your stomach going up jajajajaja, if I'm not wrong that are the negative g's, what a strange vehicle to experiment g forces.
  21. You are right guys, there is not many objects that can give the sense of speed, and the fiel of view is an important factor, but anyway the sense of speed of the game is good enough to make you pay attention, when you fly low. :thumbup: I will try to zoom out the cockpit view, to see how the sense of speed looks like. Yes it's a nice vid, and the other ones of the series are nice too, I was watching them yesterday. Thanks for answer guys :smilewink:
  22. Hi guys, I was watching in youtube Wings of the Red Star, a discovery channel series, very interesting by the way, about the Hind, and at 0:37, 1:10, when the Hind is flying very low, the sense of speed is amazing, but in the game when you are in the cockpit, it looks like you are going really slow. I've been trying low flying at 80, 100 and 150 km and the sense of speed is almost the same, slow. Please don't take this as a bad criticism, I like the game, it's just curiosity, that's why I'm asking :thumbup:. I was thinking it could be my machine, it's not a super powerful high end pc, but it could run the games very well. Athlon X2 5200 2.7Ghz, 2GB DDR2 800Mhz and 8600GT 1GB DDR2. http://www.youtube.com/watch?v=yRYh8JUjT1M&feature=related Thanks, any comment will be apreciated.
  23. Thank you very much, I was looking for something like this :thumbup:
  24. Hi guys The question is this, I'm testing a gamepad to be used with the black shark, it's not an xbox 360 gamepad, but it's the same kind, with four direction buttons, two analog joysticks and eight push buttons. I can fly the chopper with it, the four direction buttons controls the panview, the left analog joystick controls the cyclic and the right analog joystick controls the rudder, the problem is when I want to see what buttons or axis or whatever of the gamepad are assigned to control the aircraft, there is nothing in the list. Only the four direction buttons are showed and the eight push buttons are in the list, but the analog ones are not showed. When I try to assign an action, in the list appear a really large list of buttons. For example the four direction buttons are recognized as JOY_BTN_POV_L, JOY_BTN_POV_R, JOY_BTN_POV_U, JOY_BTN_POV_D, and the normal push buttons as JOY_BTN4, JOY_BTN3,JOY_BTN5, etc. I found another JOY_BTN_POV1_D and many others, tried a few of them, but no action is showed in the sim. I can assign the four direction buttons, and the other 8 buttons of the gamepad, there is no problem with that. The one I want to map are the two analog joystick. I'm doing this because I want to make a custom joystick to fly the black shark :megalol: and I want to integrate all the buttons of the gamepad and the two analog gauges. By the way the gamepad has an analog on/off button, if the button is pressed, the chopper can be controlled with the analog joysticks, if not, only the four direcction buttons works, and the normal push button. Any ideas on how to map this pair of naughty analog joysticks. :joystick: Thanks
×
×
  • Create New...