chromium Posted October 15, 2013 Posted October 15, 2013 for a given airplane group, I need to print on a txt file the following information: - group name (done & working) - Take off time (done & working, I retrieve a particoular waypoint "name" time+time0) - TOT time (done & working, as writed above) - Unit type (this is the issue) the "type" is a property of units instead of group. Obviously as my flights are composed by a specific plane type, I need to retrieve the type of the first unit of the group (that should work for clients, that use single-unit group, as for IA, that has multi-ship group). what is the lua to retrieve the units type of the first unit of a group? thanks Author of DSMC, mod to enable scenario persistency and save updated miz file Stable version & site: https://dsmcfordcs.wordpress.com/ Openbeta: https://github.com/Chromium18/DSMC The thing is, helicopters are different from planes. An airplane by it's nature wants to fly, and if not interfered with too strongly by unusual events or by a deliberately incompetent pilot, it will fly. A helicopter does not want to fly. It is maintained in the air by a variety of forces in opposition to each other, and if there is any disturbance in this delicate balance the helicopter stops flying; immediately and disastrously.
SNAFU Posted October 15, 2013 Posted October 15, 2013 (edited) I use the MIST function as below to write a table, which lists all units IDs and types. Don´t know if it works in this way, because I just took it out of context of another script, but maybe it helps: local allunitsnametable = nil local allunitsnametable = {} local allunitsnametable = {'[red][plane]', '[blue][plane]'} local unittypetable = nil local unittypetable = {} local allunitsstart = nil local allunitsstart = {} local allunitsstart = mist.makeUnitTable(allunitsnametable) for a = 1, #allunitsstart do if Unit.getByName(allunitsstart[a]) then unittypetable[#unittypetable + 1] = { unitID = Unit.getID(Unit.getByName(allunitsstart[a])), unittype = Unit.getTypeName(Unit.getByName(allunitsstart[a])) } end end You could try to use Group.getUnits(...) with Unit.getTypeName: local grouparray = Group.getUnits(group)--group needs to be defined local groupunitnr1 = grouparray[1] if groupunitnr1 ~= nil then groupunitnr1type = Unit.getTypeName(groupunitnr1) else trigger.action.outText("request returned nil", 20) end Edited October 15, 2013 by SNAFU [sIGPIC][/sIGPIC] Unsere Facebook-Seite
chromium Posted October 15, 2013 Author Posted October 15, 2013 I like your final solution, I think it's ok even if I'm not exactly defining a group but is a cycle for "any" group. I can take this local groupunitnr1 = grouparray[1] if groupunitnr1 ~= nil then groupunitnr1type = Unit.getTypeName(groupunitnr1) and adapt to the script. Thanks SNAFU, It will surely be a good hint! Author of DSMC, mod to enable scenario persistency and save updated miz file Stable version & site: https://dsmcfordcs.wordpress.com/ Openbeta: https://github.com/Chromium18/DSMC The thing is, helicopters are different from planes. An airplane by it's nature wants to fly, and if not interfered with too strongly by unusual events or by a deliberately incompetent pilot, it will fly. A helicopter does not want to fly. It is maintained in the air by a variety of forces in opposition to each other, and if there is any disturbance in this delicate balance the helicopter stops flying; immediately and disastrously.
Recommended Posts