TigersharkBAS Posted January 17, 2013 Posted January 17, 2013 Hi there, Two questions (hoping Speed and other knowledgable ED people may answer). 1. Getting Mission data from export.lua by accessing Mission environment in RAM I know you can load a mission file in the export.lua and get mission info that way. I would like to read the mission table from RAM though. I believe that net.dostring_in holds the secret but I have no idea how I would actually code this. Can anyone write a function that shows me how this would work? 2. Is it possible to get JTAC data from the game? For example, after a 9 line is read out by the JTAC you can send that down a socket in export.lua? Help and replies very much appreciated. [sIGPIC][/sIGPIC] Creator of: F-18C VFA-195 "Dambusters" 1998 CAG Livery https://forums.eagle.ru/showthread.php?t=213788 F-18C VFA-195 "Dambusters" July 2001 CAG Livery https://forums.eagle.ru/showthread.php?t=215950 Pilot avatars for DCS Logbook https://forums.eagle.ru/showthread.php?t=221160 How to make a DCS A-10C Panel http://forums.eagle.ru/showthread.php?t=65998
Speed Posted January 17, 2013 Posted January 17, 2013 Tigershark, Sorry for not answering sooner, I just have a lot of stuff going on right now, and what you really need is the kind of detailed answer that will take nearly an hour to make. In the meantime, I can give you an overview. First of all, the phrase, "Getting Mission data from export.lua by accessing Mission environment in RAM" doesn't make much sense, unless I'm interpreting it wrong. export.lua is in the "export" Lua environment. It can't access the "mission" environment. First of all, I would like to know why you think you absolutely need to get mission data through RAM. It only adds between 50 to maybe 1000 milliseconds of simulation load time to get the mission through C: instead, and it can be done easily. After you have found the mission data over C:, then it's forever accessible to you via RAM (because you saved it to a Lua variable) and it takes only nanoseconds to access. Anyway, if it truly is a hard requirement to get it solely through RAM, then you have a few options. - net environment mod: access mission data via net.dostring_in("mission", <lua code>). Drawback: you could interfere with other net environment mods like Slmod or Servman; that said, it wouldn't be hard for me to make Slmod v7 look for your mod and run it. Net can also access the main simulation Lua environment. The problem with net is that if you used it, your mod would only work when you were a multiplayer host. - MissionScripting.lua: mission scripting is passed env.mission, which is all the mission data. You could send this data out of mission scripting via LuaSocket. Drawback: you would interfere with Slmod which also uses MissionScripting.lua, but it wouldn't be hard for me to make Slmod v7 look for your mod and run it if it exists. - main simulation environment mod- this is probably the prefered option. The debriefing module receives the mission table, but it remains a local variable inside functions. You could make it save the mission table to the global environment. - Final option: I created a function that will get you the mission data in any Lua environment that has io and lfs modules available to it, but it goes through C:. ------------------------------------------------------------ The functions that build the 9-line exist in ./Sounds/Speech/NATO.lua. This is part of a module in the main simulation Lua environment. So you would need to modify the appropriate function that generates a 9-line to either save that data to the global environment or send it over UDP via LuaSocket to whatever environment you will use. Anyway, as you can see, I never mentioned export in a single breath. Export is pretty useless for what you want to do, forget about it. Anyway, what you need is obviously a main simulation Lua environment mod. You could base it out of autoexec.lua. You don't need to actually modify the debriefing.lua and NATO.lua files, you merely need to modify the functions that those files create. Redefine them to do your code in addition to ED's code. 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.
Speed Posted January 17, 2013 Posted January 17, 2013 (edited) Ok, here's a quick example. At the end of autoexec.lua, add this: --Beginning of TigersharkBAS mod do local missionData -- stores mission data for TigersharkBAS's mod. local oldFunc = {} oldFunc.extractMissionData = debriefing.extractMissionData debriefing.extractMissionData = function(mission) -- redefinition of debriefing.extractMissionData missionData = mission ------------------------------------------------------------------------------------------- --[[ASSUMING that debriefing.extractMissionData only runs one time, at mission start, then you maybe can use it as a "on mission load" event to start your "main" program loop (and kill the old loop).]] if tigershark.mainId then timer.removeFunction(tigershark.mainId) end tigershark.main() -------------------------------------------------------------------------------------------- return oldFunc.extractMissionData(mission) -- now do the old extractMissionData function. end -- do the JTAC 9-line redefinition the same way. -- If you need a "main" program loop, then you can construct one like this: tigershark = {} tigershark.main = function() -- your main code... tigershark.mainId = timer.scheduleFunction(tigershark.main, nil, timer.getTime() + 0.05) -- tigershark.main will run 20 times a second. end end Edited January 17, 2013 by Speed 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.
Skitter Posted January 17, 2013 Posted January 17, 2013 Hi, not sure if I'm hijacking the thread. I'm trying to program a unit to to switch from hold and start moving after another unit receive some damage. I've placed this Unit.getLife(truck1) < 2 Where "truck1" is the name of the unit to receive damage. Anyway, that crashes the engine, because there's something wrong with the grammar of it. Could you tell me how can I program this (if truck1's life less than 2) please?
Grimes Posted January 17, 2013 Posted January 17, 2013 Try Unit.getLife(Unit.getByName('truck1')) < 1. http://en.wiki.eagle.ru/wiki/Simulator_Scripting_Engine/DCS:_World_1.2.1/Part_2#Unit getLife is a value between 0 and 1.0. The right man in the wrong place makes all the difference in the world. Current Projects: Grayflag Server, Scripting Wiki Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread) SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum
Skitter Posted January 17, 2013 Posted January 17, 2013 Thanks, but I get the same error as before "Unexpected symbol next to '<'". Any idea? P.s I don't put the dot at the end, do I ?
Grimes Posted January 17, 2013 Posted January 17, 2013 How exactly are you using it? if Unit.getLife(Unit.getByName('truck1')) < 1 then -- do whatever end The right man in the wrong place makes all the difference in the world. Current Projects: Grayflag Server, Scripting Wiki Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread) SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum
Skitter Posted January 17, 2013 Posted January 17, 2013 I'm trying to use it in a waypoint (waypoint actions). It is going to be the "stop condition" for hold command. Do I use 'if', 'then', 'end' ? Thanks for help so far, it is my first contact with lua scripting.
Grimes Posted January 17, 2013 Posted January 17, 2013 From my example change -- do whatever to return true The right man in the wrong place makes all the difference in the world. Current Projects: Grayflag Server, Scripting Wiki Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread) SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum
Speed Posted January 18, 2013 Posted January 18, 2013 Hi, not sure if I'm hijacking the thread. I'm trying to program a unit to to switch from hold and start moving after... Cukier, for future reference, questions involving the simulator scripting engine belong in the Mission Builder's Corner. ;) 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.
TigersharkBAS Posted January 18, 2013 Author Posted January 18, 2013 Speed..thanks a lot for your answers. I still have a lot more questions but I let me try and take the advice you have given me, digest it and see if I can figure some things out myself before I hassle you again. Thanks very much! [sIGPIC][/sIGPIC] Creator of: F-18C VFA-195 "Dambusters" 1998 CAG Livery https://forums.eagle.ru/showthread.php?t=213788 F-18C VFA-195 "Dambusters" July 2001 CAG Livery https://forums.eagle.ru/showthread.php?t=215950 Pilot avatars for DCS Logbook https://forums.eagle.ru/showthread.php?t=221160 How to make a DCS A-10C Panel http://forums.eagle.ru/showthread.php?t=65998
TigersharkBAS Posted January 22, 2013 Author Posted January 22, 2013 Hi speed. I sent you a PM. Did you get it? Having trouble understanding your table serialisation function. [sIGPIC][/sIGPIC] Creator of: F-18C VFA-195 "Dambusters" 1998 CAG Livery https://forums.eagle.ru/showthread.php?t=213788 F-18C VFA-195 "Dambusters" July 2001 CAG Livery https://forums.eagle.ru/showthread.php?t=215950 Pilot avatars for DCS Logbook https://forums.eagle.ru/showthread.php?t=221160 How to make a DCS A-10C Panel http://forums.eagle.ru/showthread.php?t=65998
Recommended Posts