Wrecking Crew Posted October 21, 2014 Share Posted October 21, 2014 Attempting to get the mist.dynAdd to work in the attached mission. Getting an 'expected = at ...' such and such near line 4. I don't know what's is wrong, looking for guidance... There is a successful event for a mist transport group at 20 seconds into the mission. At 25 seconds I attempt to dynamically add a clone and that generates the error. Thanks for looking at this! 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. Link to comment Share on other sites More sharing options...
Grimes Posted October 21, 2014 Share Posted October 21, 2014 First off get the latest revision of mist here You are getting the error because you are using "vars.units" which is a table you haven't defined. It should simply be 'units' instead. However with that correction there is not enough data to spawn the group. The "clone" variable is simply a boolean value that defines whether or not the script needs to generate new names and its for the units and the group itself. This is the absolute minimum of what you'd need to spawn the group via mist.dynAdd() mist.dynAdd( { country = 'USA', category = 'vehicle', units = { [1] = { x = -175000, y = 575000, type = 'M-1 Abrams', }, [2] = { x = -175002, y = 575002, type = 'M-1 Abrams', }, [3] = { x = -175004, y = 575004, type = 'M-1 Abrams', }, }, -- end of units } -- end of function ) Note I used Abrams cause that was a readily available unit type name for me. If you want to clone a groups data but just change the coordinates for each unit you'll have to have something like this: local newGroup = mist.getGroupData('BLF VGrp90 Stinger Team') local newCoords = { [1] = { x = -175000, y = 575000, }, [2] = { x = -175002, y = 575002, }, [3] = { x = -175004, y = 575004, } } for i = 1, #newGroup.units do newGroup.units[i].x = newCoords[i].x newGroup.units[i].y = newCoords[i].y end newGroup.clone = true mist.dynAdd(newGroup) 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 Link to comment Share on other sites More sharing options...
Wrecking Crew Posted October 22, 2014 Author Share Posted October 22, 2014 Thank you, Grimes. I'm making progress, s l o w l y, reading through the wealth of Lua information that you and others have provided. 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. Link to comment Share on other sites More sharing options...
Wrecking Crew Posted October 24, 2014 Author Share Posted October 24, 2014 I'm stuck on the following code where the error message is 'Attempting to perform arithmetic on a string value.' local basePos = mist.getLeadPos('UH-1H 02 Stinger Team') local baseX = basePos.x local baseY = basePos.z trigger.action.outText('x = ' + baseX + ', y = ' + baseY) I tried renaming the group to 'Huey Stinger Team' but get other errors. This code should output text of the AI helicopter's position every ten seconds. The mission is attached (v1h) -- it is the last event in the list that is causing the problem. The error should come up at ten seconds into the mission. Help, please... TIA 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. Link to comment Share on other sites More sharing options...
Grimes Posted October 24, 2014 Share Posted October 24, 2014 (edited) Use .. to join strings together. trigger.action.outText('x = ' .. baseX .. ', y = ' .. baseY, 20) Edited October 25, 2014 by Grimes 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 Link to comment Share on other sites More sharing options...
Wrecking Crew Posted October 25, 2014 Author Share Posted October 25, 2014 That did it. I'd tried coercion on the group name... --- Next step is to pass the coordinates to a Stinger team drop off. 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. Link to comment Share on other sites More sharing options...
Wrecking Crew Posted October 25, 2014 Author Share Posted October 25, 2014 The following script is working, except for the line: local baseHeading = mist.getHeading(unitName) That line ^^^ causes a fail with this error -- Here is the script -- local grpName = 'UH-1H 02 Stinger Team' local unitName = 'UH-1H 02' local basePos = mist.getLeadPos(grpName) local baseHeading = mist.getHeading(unitName) trigger.action.outText('x = ' .. basePos.x .. ', y = ' .. basePos.z .. ', unit = ' .. unitName, 6) local newGroup = mist.getGroupData('BLF VGrp90 Stinger Team') local newCoords = { [1] = { x = basePos.x - 5, y = basePos.z, }, [2] = { x = basePos.x, y = basePos.z - 5, }, [3] = { x = basePos.x, y = basePos.z + 5, } } for i = 1, #newGroup.units do newGroup.units[i].x = newCoords[i].x newGroup.units[i].y = newCoords[i].y end newGroup.clone = true mist.dynAdd(newGroup) 1. Why is the line 'local baseHeading = mist.getHeading(unitName)' causing an error? 2. How can I dynamically get the unit name from the Client helicopter group 'UH-1H 02 Stinger Team'? This script is to clone an infantry group at the position of the helicopter. The helicopter does not have to fly to a specified spot/zone. Eventually I'll add code that will run the script when the helicopter lands and the human Client selects a radio choice to disembark the infantry. The test mission is attached (v1m). 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. Link to comment Share on other sites More sharing options...
Grimes Posted October 25, 2014 Share Posted October 25, 2014 It is a unit object, not a units name. So change line 4 to read local baseHeading = mist.getHeading(Unit.getByName(unitName)) http://wiki.hoggit.us/view/GetHeading 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 Link to comment Share on other sites More sharing options...
Wrecking Crew Posted October 25, 2014 Author Share Posted October 25, 2014 Thank you! I get the heading in RADS and it is displayed in the outText. Can the unitName 'UH-1H 02' be obtained dynamically? This code is working: local grpName = 'UH-1H 02 Stinger Team' local unitName = 'UH-1H 02' local basePos = mist.getLeadPos(grpName) local baseHeading = mist.getHeading(Unit.getByName(unitName)) -- trigger.action.outText('x = ' .. basePos.x .. ', y = ' .. basePos.z .. ', unit = ' .. unitName, 6) trigger.action.outText('x = ' .. basePos.x .. ', y = ' .. basePos.z .. ', unit = ' .. unitName .. ', heading = ' .. baseHeading, 6) local newGroup = mist.getGroupData('BLF VGrp90 Stinger Team') local newCoords = { [1] = { x = basePos.x - 5, y = basePos.z, }, [2] = { x = basePos.x, y = basePos.z - 5, }, [3] = { x = basePos.x, y = basePos.z + 5, } } for i = 1, #newGroup.units do newGroup.units[i].x = newCoords[i].x newGroup.units[i].y = newCoords[i].y end newGroup.clone = true mist.dynAdd(newGroup) 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. Link to comment Share on other sites More sharing options...
Wrecking Crew Posted October 26, 2014 Author Share Posted October 26, 2014 One more ? -- How can the unitName 'UH-1H 02' be obtained dynamically from the group 'UH-1H 02 Stinger Team'? 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. Link to comment Share on other sites More sharing options...
FSFIan Posted October 26, 2014 Share Posted October 26, 2014 One more ? -- How can the unitName 'UH-1H 02' be obtained dynamically from the group 'UH-1H 02 Stinger Team'? What problem are you trying to solve here? The simple, correct and absolutely useless answer to your question would be if groupName == "UH-1H 02 Stinger Team" then unitName = "UH-1H 02" end If you have a group (name) and want the unit object of the first unit, you can use local group = Group.getByName(groupName) local unit = group:getUnit(1) You could also do local unitName = Group.getByName("UH-1H 02 Stinger Team"):getUnit(1):getName() Have you read through Part 1 and Part 2 of the scripting engine documentation? DCS-BIOS | How to export CMSP, RWR, etc. through MonitorSetup.lua Link to comment Share on other sites More sharing options...
Wrecking Crew Posted October 26, 2014 Author Share Posted October 26, 2014 Yes, I've read through it all! I can spend hours trying to get something simple to work with this scripting stuff, but I have more important mission development work to do. Be assured that having these answers written down in these forums will help me and others. I want to dynamically get the unit name from the Client group so I don't have to hard code it into the script. Earlier this week I tried what is basically the solution that you've offered, but I was using the unit name and not getting what Grimes referred to as the unit object. I have also been having problems with the syntax and punctuation, like using square brackets instead of what you are showing above where () is needed. It is starting to make sense, much thanks to Grimes and you for getting me past obstacles. My script should be finished up today and I'll post it. Just need to do some geometry... Thanks, Ian. 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. Link to comment Share on other sites More sharing options...
Wrecking Crew Posted October 26, 2014 Author Share Posted October 26, 2014 Alright, here it is... local grpName = 'UH-1H 02 Stinger Team' local unitName = Group.getByName(grpName):getUnit(1):getName() local basePos = mist.getLeadPos(grpName) local baseHeadingRad = mist.getHeading(Unit.getByName(unitName)) local baseHeadingDeg = baseHeadingRad * 180 / math.pi trigger.action.outText('x = ' .. basePos.x .. ', z = ' .. basePos.z .. ', unit = ' .. unitName .. ', heading Radians = ' .. baseHeadingRad .. ', heading Degrees = ' .. baseHeadingDeg, 6) local newGroup = mist.getGroupData('BLF VGrp90 Stinger Team') local newCoords = { [1] = { x = basePos.x + ((75 * math.cos(baseHeadingDeg)) - (0 * math.sin(baseHeadingDeg))), y = basePos.z + ((75 * math.sin(baseHeadingDeg)) + (0 * math.cos(baseHeadingDeg))), heading = baseHeadingDeg, }, [2] = { x = basePos.x + ((-75 * math.cos(baseHeadingDeg)) - (75 * math.sin(baseHeadingDeg))), y = basePos.z + ((-75 * math.sin(baseHeadingDeg)) + (75 * math.cos(baseHeadingDeg))), heading = baseHeadingDeg + 40, }, [3] = { x = basePos.x + ((-75 * math.cos(baseHeadingDeg)) - (-75 * math.sin(baseHeadingDeg))), y = basePos.z + ((-75 * math.sin(baseHeadingDeg)) + (-75 * math.cos(baseHeadingDeg))), heading = baseHeadingDeg - 40, } } for i = 1, #newGroup.units do newGroup.units[i].x = newCoords[i].x newGroup.units[i].y = newCoords[i].y newGroup.units[i].heading = newCoords[i].heading end newGroup.clone = true mist.dynAdd(newGroup) This will work for what I want. The unit offsets could be variables, but I've spent enough time on it already :) The test mission is attached (v1o). Thanks again Grimes and Ian. 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. Link to comment Share on other sites More sharing options...
sniperwolfpk5 Posted April 24, 2015 Share Posted April 24, 2015 How to switch in different groups in single player mission. I mean switch aircraft using radio menu Any idea Win10, Intel 3rd Gen. Core i7 3.8Ghz, 20GB ram, Nvidia Geforce 1060 6GB Opentrack (Download it from HERE), PS3 Eye, Saitek x52-pro Joystick, DIY Rudder Pedals, Google Cardboard with DCS World English is not my native language Link to comment Share on other sites More sharing options...
Wrecking Crew Posted April 24, 2015 Author Share Posted April 24, 2015 You want to switch your aircraft in SP with a Radio Command? I don't think you can... I use SP for testing, and I'm pretty sure that once you choose your slot and Fly the mission you are stuck in that slot until you end the mission and restart it. Hope that answers your question. If not, ask it again...? 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. Link to comment Share on other sites More sharing options...
sniperwolfpk5 Posted April 24, 2015 Share Posted April 24, 2015 (edited) Yes i got it. I was thinking a training mission with multiple options. Like refueling in different aircraft and some gun training with different aircraft etc. Thx for the help Edited April 24, 2015 by sniperwolfpk5 Win10, Intel 3rd Gen. Core i7 3.8Ghz, 20GB ram, Nvidia Geforce 1060 6GB Opentrack (Download it from HERE), PS3 Eye, Saitek x52-pro Joystick, DIY Rudder Pedals, Google Cardboard with DCS World English is not my native language Link to comment Share on other sites More sharing options...
Wrecking Crew Posted April 24, 2015 Author Share Posted April 24, 2015 Oh, you can sure add in as many a/c types as you want to. But for each one you add, there should be just one a/c per group. You can set these a/c to Player or to Client, and they will show up in the list of available slots when you start in SP mode. You must use the Client type for multiplayer. 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. Link to comment Share on other sites More sharing options...
Recommended Posts