benargee Posted March 31, 2020 Share Posted March 31, 2020 How do you reference the unit that activates a trigger by entering it's zone? I have the trigger activating but I want to get the units reference so I can do actions on it. How would I get that info from inside actions DO SCRIPT or DO SCRIPT FILE? Would like to know how without using MIST or MOOSE. Feel free to include solutions with those frameworks, but that won't answer my primary question. Thanks [sIGPIC][/sIGPIC] Call Sign: Pork Chop. intel I5 4670K @ 3.4GHz - GALAXY GTX 670 2GB @ 1080P - 16GB ( 2X8 ) Corsair DDR3 1600MHz - ASUS VG248QE 1080p ASUS ROG MAXIMUS VI HERO Mother Board - Samsung 840 Pro SSD 128GB(game/boot) - WD 640GB HDD 6.0GB/s - 750w Corsair Power Supply :yes:Trackir 5 w/ Tclip Pro - :joystick:TM HOTAS Warthog - Saitek Pro Rudder Pedals - Logitech G700s Mouse (edit:May19/14) http://wiki.benargee.com/ Link to comment Share on other sites More sharing options...
Majinbot Posted March 31, 2020 Share Posted March 31, 2020 (edited) Conditions: UNIT INSIDE ZONE(unit, new trigger zone) DO SCRIPT: trigger.action.outText(Unit.getByName("unit"):getName() .. " is inside the zone", 10) Edited March 31, 2020 by Majinbot PC: i7-13700K - MSI RTX 4080 Gaming X Trio - 32GB DDR5 6200 - VPC MongoosT-50CM3 - VKB GF pro - MFG Crosswind - Msi MPG321UR-QD + Acer XB271HU - TrackIR5 - Rift S Link to comment Share on other sites More sharing options...
TOViper Posted April 1, 2020 Share Posted April 1, 2020 (edited) Conditions: UNIT INSIDE ZONE(unit, new trigger zone) DO SCRIPT: trigger.action.outText(Unit.getByName("unit"):getName() .. " is inside the zone", 10) You didn't answer his question, did you? I have no answer, but what I did in the past was asking a very similar question also, but with no success so far: https://forums.eagle.ru/showthread.php?t=258843 I think most people don't realize what is behind the question ... a "thing" or strategy to find out WHO triggered the trigger. benargee, I feel your pain! Edited April 1, 2020 by TOViper Visit https://www.viggen.training ...Viggen... what more can you ask for? my computer: AMD Ryzen 5600G | NVIDIA GTX 1080 Ti OC 11GB | 32 GB 3200 MHz DDR4 DUAL | SSD 980 256 GB SYS + SSD 2TB DCS | TM Warthog Stick + Throttle + TPR | Rift CV1 Link to comment Share on other sites More sharing options...
benargee Posted April 2, 2020 Author Share Posted April 2, 2020 (edited) Conditions: UNIT INSIDE ZONE(unit, new trigger zone) DO SCRIPT: trigger.action.outText(Unit.getByName("unit"):getName() .. " is inside the zone", 10) Your code checks if a specific unit is in the zone which makes part of the DO SCRIPT redundant since the units name is already known for that single unit. I want to know who entered the zone, not if a specific unit entered it. It's very common in programming for events to return context when they are activated. Why is it so hard in DCS? EDIT: A part of me thinks I may have to replicate the Triggers-Conditions-Actions framework all in lua where: REPETITIVE ACTION is a loop with a sleep that checks: PART OF COALITION IN ZONE that is a table(list/array) of all coalition units that gets iterated through and checks their position against a specific zones area using it's position and radius. When that is active, the easy part is call: DO SCRIPT is literally just the script I want called. Because I checked each unit's position, I know which one(s) is/are in the zone giving me the reference I needed. I don't know if this is how it's done under the hood in lua or maybe a faster low level langauge, but it's a pretty roundabout way of doing it to get a unit's name. Unless there is a hidden local variable that holds the unit name(s) I'll have to do everything myself. I came to this conclusion after looking through the DCS Lua API and what it can do. I think it's all starting to sink in. Edited April 2, 2020 by benargee More info and possible solution. [sIGPIC][/sIGPIC] Call Sign: Pork Chop. intel I5 4670K @ 3.4GHz - GALAXY GTX 670 2GB @ 1080P - 16GB ( 2X8 ) Corsair DDR3 1600MHz - ASUS VG248QE 1080p ASUS ROG MAXIMUS VI HERO Mother Board - Samsung 840 Pro SSD 128GB(game/boot) - WD 640GB HDD 6.0GB/s - 750w Corsair Power Supply :yes:Trackir 5 w/ Tclip Pro - :joystick:TM HOTAS Warthog - Saitek Pro Rudder Pedals - Logitech G700s Mouse (edit:May19/14) http://wiki.benargee.com/ Link to comment Share on other sites More sharing options...
shnicklefritz Posted April 3, 2020 Share Posted April 3, 2020 (edited) There is no way to reference which specific unit triggered your condition in a zone based on current mission editor triggers. There is a way to reference or iterate, rather, through each group, then each groups units’ positions to see if any one of them is in the zone. I personally am unaware of any other way. This is why MiST exist. In fact, MiST has a function that does exactly what you describe. https://wiki.hoggitworld.com/view/Mission_Scripting_Tools_Documentation function unitsInZone() local allBlueAircraft = coalition.getGroups(2, 0) -- (1=RED 2=BLUE, 0==AIRCRAFT) local zone = trigger.misc.getZone("myMissionEditorZoneName") for i, group in pairs(allBlueAircraft) do if group ~= nil and group:isExist() == true then local units = group:getUnits() for _i, unit in pairs(units) do local uPos = unit:getPoint() if (((uPos.x - zone.point.x)^2 + (uPos.z - zone.point.z)^2)^0.5 <= zone.radius) then local unitName = unit:getName() trigger.action.outText("This unit is in the mother lovin zone: "..unitName, 10) --other functions can be run here too. end end end end timer.scheduleFunction(unitsInZone, nil, timer.getTime() + 5) --will run the function every five seconds for the entirety of the mission end unitsInZone() --initiates the function Edited April 3, 2020 by shnicklefritz Link to comment Share on other sites More sharing options...
Recommended Posts