Jump to content

Functions of the Unit.get * class return nil


Go to solution Solved by kira_mikamy,

Recommended Posts

Posted

Hey, guys! When I use this code to obtain the coordinates of a unit, it returns nil. What's the problem here?

local tank = Unit.getByName('Tank') local coord= tank:getPoint() trigger.action.smoke(coord,trigger.smokeColor.Blue)

The prompt "getPoint" is empty

and getName() getLife() getPoint.......

thank you,

Posted
7小时前,Tobias00723说:

i would recommend taking a look here -> 


 

Unit.getByName() can return nil if the name provided does not exist
so a unit named 'Tank' does not exist in the mission

Thank you! I want to obtain a data list of a unit or group, which includes its name, mount, task, coordinates, etc. How should it be done? Which function should be used? I didn't find the relevant function.

  • Solution
Posted (edited)

Unit.getByName("Tank") → here "Tank" must be the Unit name, not the Group name.
Group.getByName("Tank") → use this only if the Group is named "Tank" in the Mission Editor.

I’m guessing the issue is that your unit might already be named "Tank".
If that’s the case, let me know so we can fix it properly. 

Edited by kira_mikamy
syntax
Posted
5小时前,kira_mikamy说:

Unit.getByName("Tank") → here "Tank" must be the Unit name, not the Group name.
Group.getByName("Tank") → use this only if the Group is named "Tank" in the Mission Editor.

I’m guessing the issue is that your unit might already be named "Tank".
If that’s the case, let me know so we can fix it properly. 

Yes, I think I must have confused "unit" with "group"

Posted
12小时前,kira_mikamy说:

Unit.getByName("Tank") → here "Tank" must be the Unit name, not the Group name.
Group.getByName("Tank") → use this only if the Group is named "Tank" in the Mission Editor.

I’m guessing the issue is that your unit might already be named "Tank".
If that’s the case, let me know so we can fix it properly. 

Hello, buddy. I want to obtain a template for a unit or group, then modify the name and activate it into a new unit. How should I do it?

Posted (edited)

Unless you want to spend ~3 months of your life making your own system
there are function in mist that your can use :
https://wiki.hoggitworld.com/view/MIST_cloneGroup
is one of them

if you explicitly want a different group name you can ticker with mist
but dont really see the use of it here because

Group:getName()

Unit:getName()

are valid functions you can use....

Edited by Tobias00723
  • Thanks 1

DCS Mission Scripting Wizard | TGFB Owner | Dev of HIP Dynamic Server | Maker of TGFB Dynamic | tgfb-dcs.comContact me | TGFB Discord

DCS_Forums_cover.png

Posted
Il 15/10/2025 at 13:38, Qazplm ha scritto:

Hello, buddy. I want to obtain a template for a unit or group, then modify the name and activate it into a new unit. How should I do it?

Can you use MOOSE?
If not, I recommend moving to it.

MOOSE has a function called SpawnNewWithAlias that lets you spawn a group from a Mission Editor template and give it any name (alias) you want each time you spawn it.
https://flightcontrol-master.github.io/MOOSE_DOCS_DEVELOP/Documentation/Core.Spawn.html##(SPAWN).NewWithAlias

  • Thanks 1
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...