Wrecking Crew Posted November 30, 2014 Posted November 30, 2014 (edited) Hi, trying to get the Client's name to output from a script.. This is the code, the problem is line #4 "local unitID = Unit.getID(unitName)", the error is below. local grpName = 'UH-1H 03 FARP London' local unitNameManpads = 'BLF VGrp90 Stinger' local unitName = Group.getByName(grpName):getUnit(1):getName() local unitID = Unit.getID(unitName) trigger.action.outText(unitID ' just dropped off a Stinger team!', 20) The first three lines run fine. The error comes from line #4 for the unitID. How do I retrieve the Client's name? The unitID is sposed to be a Client's name, like "Wrecking Crew", to output 20 seconds of text of "Wrecking Crew just dropped off a Stinger team!" Also, I tried this for line #4 -- local grpName = 'UH-1H 03 FARP London' local unitNameManpads = 'BLF VGrp90 Stinger' local unitName = Group.getByName(grpName):getUnit(1):getName() local unitID = Group.getByName(grpName):getUnit(1):getID() trigger.action.outText(unitID ' just dropped off a Stinger team!', 20) Which generated this error -- WC Edited November 30, 2014 by Wrecking Crew Visit the Hollo Pointe DCS World server -- an open server with a variety of COOP & H2H missions including Combined Arms. All released missions are available for free download, modification and public hosting, from my Wrecking Crew Projects site.
FSFIan Posted November 30, 2014 Posted November 30, 2014 You need to use the ".." operator to concatenate text. In Lua, if you call a function with a single argument that is a string literal or a table literal (don't know about other cases), the parentheses are optional. Currently, Lua is reading your last line as the following: trigger.action.outText(unitID(' just dropped off a Stinger team!'), 20) Try replacing it with trigger.action.outText(unitID .. ' just dropped off a Stinger team!', 20) That should make your second example work. In your first example, you are calling Unit.getID with a string, but it expects a unit object. DCS-BIOS | How to export CMSP, RWR, etc. through MonitorSetup.lua
Wrecking Crew Posted November 30, 2014 Author Posted November 30, 2014 Thank you Ian, again! I thought that '..' in the text out was to concatenate numerical values with the rest of the text. Adding the '..' fixed the error. Now when I land the helicopter, the Stinger team gets dropped off, and this text is displayed, "279 just dropped off a Stinger team!" With a slight change, I am able to get the player (Client) name -- local grpName = 'UH-1H 03 FARP London' local unitNameManpads = 'BLF VGrp90 Stinger' local unitName = Group.getByName(grpName):getUnit(1):getName() local unitPlayerName = Group.getByName(grpName):getUnit(1):getPlayerName() trigger.action.outText(unitPlayerName .. ' just dropped off a Stinger team!', 20) WC Visit the Hollo Pointe DCS World server -- an open server with a variety of COOP & H2H missions including Combined Arms. All released missions are available for free download, modification and public hosting, from my Wrecking Crew Projects site.
Recommended Posts