Haggart Posted December 20, 2009 Share Posted December 20, 2009 Hey Guys, I'm sitting now about 2 days at a stretch on lua-scripting, and I'm finally at a point where I've nearly given up hope. I try to export the longi- and latitudal position of the player aircraft. After around 8 hours and two tacview-export-lua-examinations, I figured out it must be something with the CurrentObjectData-table(?). But whenever I try to get data from this table - for example, with the simple expression 'io.write(CurrentObjectData.Heading)', I end up with an error in the log "attempt to index global `CurrentObjectData' (a nil value)". Why the hell is this a nul value? How is that table structured? And - how do I access tables in the export script? I tried many ways, for example like I would access an indexed array (CurrentObjectData.Heading[0] and things like that), but I ended up running in circles. Is there any documentation available to the Lock On-Export-tables, or how I can access them? Please! Tired greetings from Germany, Hag There's no "Overkill". There's only "open fire!" and "time to reload". Specs: i7-980@4,2Ghz, 12GB RAM, 2x GTX480, 1x 8800GTS, X-Fi HD, Cougar, Warthog, dcs-F16-pedals Link to comment Share on other sites More sharing options...
Dagger_c3 Posted December 20, 2009 Share Posted December 20, 2009 (edited) Hi, in my case I've done something similar in order to get the Coordinates when a ONLINE player ejects. (I'm making a kind of online data exporter so in a future I can do some dynamic campaign in PHP) I hope that it help, also it would be fine if you tell what file you're coding (events.lua, export.lua, etc etc) And don't give it up, I've wasted 2 full weeks in order to get something usefull ;) That's coded in the events.lua: function on_eject(id) report(_("%s ejected."), player_info(id)) eject(id) end local function eject(id) local runtimeId = get_player_runtime_id(id) io.write(string.format("id=%s pilot=%s coords=%s side=%s EJECT\n", runtimeId, get_player_name(id), get_unit_coordinates(runtimeId), get_player_side(id))) end local function get_player_runtime_id(networkId) missionId = get_player_mission_id(networkId) if missionId == nil or missionId == "" then return -1 end runtimeId, ok = net.dostring_in("mission", "return db.clients.red["..missionId.."].ID") if ok and runtimeId ~= "" then return runtimeId end runtimeId, ok = net.dostring_in("mission", "return db.clients.blue["..missionId.."].ID") if ok and runtimeId ~= "" then return runtimeId end return -1 end local function get_unit_latitude(runtimeId) latitude, ok = net.dostring_in("export", "local o = LoGetWorldObjects() return o["..runtimeId.."].LatLongAlt.Lat") if ok and latitude ~= "" then return latitude end return -1 end local function get_unit_longitude(rundimeId) longitude, ok = net.dostring_in("export", "local o = LoGetWorldObjects() return o["..runtimeId.."].LatLongAlt.Long") if ok and longitude ~= "" then return longitude end return -1 end local function get_unit_coordinates(runtimeId) if runtimeId == nil or runtimeId == "" then return -1 end return get_unit_latitude(runtimeId).."//"..get_unit_longitude(rundimeId) end local function get_player_mission_id(networkId) if players[networkId].unit ~= nil then return players[networkId].unit end return nil end Edited December 20, 2009 by Dagger_c3 1 Link to comment Share on other sites More sharing options...
Haggart Posted December 24, 2009 Author Share Posted December 24, 2009 Uh, I frickeled some time, but... the events.lua does only exist in DCS, proove me wrong? Trying anyway to work along. Can you or someone explain how to access the tables which seem to contain the actual data? There's no "Overkill". There's only "open fire!" and "time to reload". Specs: i7-980@4,2Ghz, 12GB RAM, 2x GTX480, 1x 8800GTS, X-Fi HD, Cougar, Warthog, dcs-F16-pedals Link to comment Share on other sites More sharing options...
RipKirby Posted January 21, 2010 Share Posted January 21, 2010 dynamic campaign in php? persistant battlefield you say? I have some concepts lying around if you are interested. I guess you are trying to do something like europeinruins.com or similar? Link to comment Share on other sites More sharing options...
Vyrtuoz Posted January 24, 2010 Share Posted January 24, 2010 Hello Haggart, Sorry for this late answer, I was in vacation. Tacview export script is very specific and was refined over years, that's why it is not easy to understand. To get a better view of Lock-On export capabilities, you should come back to the roots: export.lua which contains few by commented and understandable lists of useful LUA functions. If you need to only export player's aircraft position you should use the following two functions (from lock-on): First, use LoGetPlayerPlaneId() to get player aircraft ID (if any). local PlayerPlaneID= LoGetPlayerPlaneId(); Then use LoGetObjectById() to get player aircraft information: local PlayerPlaneInfo = LoGetObjectById(PlayerPlaneID); That way you will get latitude, longitude and altitude for the player's aircraft. local PlayerLatLongAlt = PlayerPlaneInfo.LatLongAlt; local PlayerLatitude = PlayerLatLongAlt.Lat; local PlayerLongitude = PlayerLatLongAlt.Long; local PlayerAltitude = PlayerLatLongAlt.Alt; If you also need player's aircraft orientation you can use: local PlayerPitch,PlayerRoll,PlayerYaw=LoGetADIPitchBankYaw(); I hope this answer your question. Link to comment Share on other sites More sharing options...
RipKirby Posted August 10, 2010 Share Posted August 10, 2010 Hey, any news? :) Link to comment Share on other sites More sharing options...
Recommended Posts