Stonehouse Posted October 30, 2015 Posted October 30, 2015 (edited) It's probably just a wiki update - of course assuming I'm not misunderstanding things - but the event table seems to have changed structure in 1.5. I'm debugging an issue around auto despawn of landed aircraft in GCICAP and am finding that the event table now looks like the below for a LAND event: eventtable : { ["subPlace"] = 0, ["time"] = 44123.741, ["initiator"] = table: 00000001F3D84540 { ["initiator"]["id_"] = 16799744, }, ["place"] = table: 00000001F3D84860 { ["place"]["id_"] = 5000018, }, ["id"] = 4, } initiator according to the wiki seemed to have been the unit id whereas now it is a table of ids. Does this mean in future if two events of the same type happen at the same exact time there will be two entries in the initiator table as well as possibly two entries in the place table? or will there always be two entries in the events table? Also the initiator id value doesn't seem to be a unit id??? Pretty much I'm storing the event.initiator value in a table ie landingtable.unit = event.initiator and then later on trying to do a landingtable.unit:getVelocity() - which used to work but now am obviously finding that landingtable.unit contains a table not a unit id so the getVelocity just bombs. Any clues would be very welcome <edit> Ok really confused now. Trying to test event table coding using the BIRTH event as that's quicker than LAND. So have the following code: local airspawnname = Unit.getName(event.initiator) local airspawnunit = Unit.getByName(airspawnname) Debug(" airspawnunit : " .. string.format(airspawnunit), lside) Debug(" airspawnname : " .. string.format(airspawnname), lside) Getting an error now that string.format(airspawnunit) is failing because it is getting a table. Has Unit.getByName always returned a table? What does getVelocity() require? Unit or the unit id? Thanks, Stonehouse PS @moderators please move this over to the Mission builders corner if it is becoming something unrelated to 1.5 beta ie If it's due to me misunderstanding which is seeming to be more likely. PPS ok it is me, finally seem to understand that Unit is a collection of attributes (class finally clicks with me) and ID is just one of the attributes. So I am guessing that the id listed in the event table is actually a reference to another table internal to DCS that holds all the units. Mods please DO shift this over to the Mission Builders corner if you think it will help anyone else or delete it as you see fit. Apologies for wasting space here. Edited October 30, 2015 by Stonehouse
Grimes Posted October 30, 2015 Posted October 30, 2015 PPS ok it is me, finally seem to understand that Unit is a collection of attributes (class finally clicks with me) and ID is just one of the attributes. So I am guessing that the id listed in the event table is actually a reference to another table internal to DCS that holds all the units. Mods please DO shift this over to the Mission Builders corner if you think it will help anyone else or delete it as you see fit. Apologies for wasting space here. More or less yes. The event.initiator and event.place are both objects. Initiator is a unit while place in this case, looks to be an airbase, but it can also be an object placed on the map like a FARP or ship. Object.getVelocity(event.initiator) for example is a valid function call. 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
Recommended Posts