Fatie89 Posted December 7, 2022 Posted December 7, 2022 Hi! I've now been at this for days as a beginner when it comes to scripts and I can't figure it out. I have two UH-60L (mod) in a mission, one is cold and the other is hot, both are clients. As embarking troops in this mod does not seem to work (works fine with the Hueys) I'm trying to use a script to teleport the infantry group to the chopper. I've added radio items for both choppers so that you first spawn an infantry group and then you should be able to teleport that group with another radio item. For the Cold unit I have the following script and for the Hot one I've just replaced the word Cold with Hot. When inf group 1 has spawned a flag is activated so that both units can't spawn group 1 at the same time, it then moves to the next trigger for spawning group 2. The teleport trigger also has a flag that activates when a group has been teleported preventing both units trying to teleport the same group. mist.teleportToPoint({groupName='Green 1 Inf 1', point=Group.getByName('UH-60L Cold'):getUnit(1):getPosition().p, action='teleport', radius = 20, innerRadius = 10}) This seems to work fine when I delete one of the units in the ME. If I delete the Cold one, there is no problem with teleporting to the Hot one and vice versa. I can jump in the Cold one as pilot and press the teleport radio call and nothing happens, if I then change my slot to the hot one the group can instantly teleport to that chopper without me ever pressing the radio item. This means that the script is looking for the Hot one even though the conditions for that trigger has not yet been met. Both scripts have seperate triggers and should only activate if the conditions are met for that trigger. I have been looking around to find an answer but I've not been able to and that is why I'm here right now. I'm adding two screenshots of both the Cold and the Hot trigger. This is surely a beginner mistake on my part and I would appreciate some assistance, it's driving me crazy. Cyprus Blue Day practice.miz
Grimes Posted December 8, 2022 Posted December 8, 2022 That is a bit of a headache to figure out. It would be almost better to just use CTLD to handle it for all rather than a combination of triggers/scripting for the mod aircraft and in game functionality for the rest. At least how you have the triggers setup this is where scripting becomes extremely powerful because it doesn't take much to get the same result with a small amount of code. local acTbl = {"Blue Client 23", "Blue Client 25"} local cargoLoaded = {} local troops = {} for i = 1, 10 do table.insert(troops, "Green 1 Inf " .. i) end local troopIndex = 0 local function disembark(vars) local unit = Unit.getByName(vars.unitName) if unit then if cargoLoaded[vars.unitName] then -- unit is alive and has cargo mist.teleportToPoint({groupName= cargoLoaded[vars.unitName], point= unit:getPoint() , action='teleport', radius = 20, innerRadius = 10}) cargoLoaded[vars.unitName] = nil -- deletes the cargo from the DB else -- Hey you don't have any cargo loaded, so do nothing or display a message to them. end end end local function embark(vars) -- this is really hacky toward how you have it setup. local loadedGroupName if troopIndex < #troops then troopIndex = troopIndex + 1 loadedGroupName = troops[troopIndex] end if loadedGroupName then cargoLoaded[vars.unitName] = loadedGroupName else -- no more groups. Warning message or whatever end end for i = 1, #acTbl do missionCommands.addCommandForGroup(mist.DBs.humansByName[acTbl[i]].groupId, "Embark Troops", nil, embark, {unitName = acTbl[i]}) missionCommands.addCommandForGroup(mist.DBs.humansByName[acTbl[i]].groupId, "Disembark Troops", nil, disembark, {unitName = acTbl[i]}) end 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
Fatie89 Posted December 8, 2022 Author Posted December 8, 2022 (edited) 13 hours ago, Grimes said: That is a bit of a headache to figure out. It would be almost better to just use CTLD to handle it for all rather than a combination of triggers/scripting for the mod aircraft and in game functionality for the rest. At least how you have the triggers setup this is where scripting becomes extremely powerful because it doesn't take much to get the same result with a small amount of code. local acTbl = {"Blue Client 23", "Blue Client 25"} local cargoLoaded = {} local troops = {} for i = 1, 10 do table.insert(troops, "Green 1 Inf " .. i) end local troopIndex = 0 local function disembark(vars) local unit = Unit.getByName(vars.unitName) if unit then if cargoLoaded[vars.unitName] then -- unit is alive and has cargo mist.teleportToPoint({groupName= cargoLoaded[vars.unitName], point= unit:getPoint() , action='teleport', radius = 20, innerRadius = 10}) cargoLoaded[vars.unitName] = nil -- deletes the cargo from the DB else -- Hey you don't have any cargo loaded, so do nothing or display a message to them. end end end local function embark(vars) -- this is really hacky toward how you have it setup. local loadedGroupName if troopIndex < #troops then troopIndex = troopIndex + 1 loadedGroupName = troops[troopIndex] end if loadedGroupName then cargoLoaded[vars.unitName] = loadedGroupName else -- no more groups. Warning message or whatever end end for i = 1, #acTbl do missionCommands.addCommandForGroup(mist.DBs.humansByName[acTbl[i]].groupId, "Embark Troops", nil, embark, {unitName = acTbl[i]}) missionCommands.addCommandForGroup(mist.DBs.humansByName[acTbl[i]].groupId, "Disembark Troops", nil, disembark, {unitName = acTbl[i]}) end Thank you so much for your answer, it's like reading....well....a script for me so I don't understand it but I'm still grateful. I will see if I can implement it in my mission. Btw, what do you mean when you mention CTLD? Edited December 8, 2022 by Fatie89
Grimes Posted December 8, 2022 Posted December 8, 2022 https://github.com/ciribob/DCS-CTLD It is a script that handles troop transport that was created before ED added the functionality to DCS. You can have unlimited groups and it tasks the infantry to run to enemy forces automatically. 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
Fatie89 Posted December 10, 2022 Author Posted December 10, 2022 On 12/9/2022 at 12:16 AM, Grimes said: https://github.com/ciribob/DCS-CTLD It is a script that handles troop transport that was created before ED added the functionality to DCS. You can have unlimited groups and it tasks the infantry to run to enemy forces automatically. Thanks! I've managed to brute force it so that the infantry now teleports to the chopper. The inf then just stand still as they seem to not be able to see the enemy. With CTLD I might get it to work. Once again, thank you.
Recommended Posts